1 | <?php |
||
7 | class SubMuncherTest extends \PHPUnit_Framework_TestCase |
||
8 | { |
||
9 | public function testIPRangeToSubnetArray() |
||
57 | |||
58 | public function testConsolidate() |
||
59 | { |
||
60 | $this->assertEquals(['10.10.10.0/31'], SubMuncher::consolidate(['10.10.10.0', '10.10.10.1'])); |
||
61 | $this->assertEquals( |
||
62 | ['10.10.10.0/31', '10.10.10.2/32'], |
||
63 | SubMuncher::consolidate(['10.10.10.0', '10.10.10.1', '10.10.10.2']) |
||
64 | ); |
||
65 | $this->assertEquals( |
||
66 | ['10.10.10.0/31', '10.10.10.2/32', '100.10.10.0/30', '100.10.10.4/31'], |
||
67 | SubMuncher::consolidate( |
||
68 | [ |
||
69 | '10.10.10.0', |
||
70 | '10.10.10.1', |
||
71 | '10.10.10.2', |
||
72 | '100.10.10.0', |
||
73 | '100.10.10.1', |
||
74 | '100.10.10.2', |
||
75 | '100.10.10.3', |
||
76 | '100.10.10.4', |
||
77 | '100.10.10.5' |
||
78 | ] |
||
79 | ) |
||
80 | ); |
||
81 | } |
||
82 | |||
83 | public function testConsolidateWithMaxRules() |
||
98 | |||
99 | public function testConsolidateSubnets() |
||
119 | |||
120 | public function testConsolidateSubnetsWithDuplicates() |
||
121 | { |
||
122 | $this->assertEquals(['10.10.10.0/31'], SubMuncher::consolidate_subnets( |
||
123 | ['10.10.10.0/32', '10.10.10.1/32', '10.10.10.1/32'])); |
||
124 | $this->assertEquals( |
||
125 | ['10.10.10.0/31', '10.10.10.2/32', '100.10.10.0/30', '100.10.10.4/31'], |
||
126 | SubMuncher::consolidate_subnets( |
||
127 | [ |
||
128 | '10.10.10.0/32', |
||
129 | '10.10.10.0/32', |
||
130 | '10.10.10.1/32', |
||
131 | '10.10.10.2/32', |
||
132 | '100.10.10.0/32', |
||
133 | '100.10.10.1/32', |
||
134 | '100.10.10.2/32', |
||
135 | '100.10.10.3/32', |
||
136 | '100.10.10.4/31', |
||
137 | ] |
||
138 | ) |
||
139 | ); |
||
140 | } |
||
141 | |||
142 | public function testConsolidateSubnetsWithMaxRules() |
||
177 | } |
||
178 |