public function testConstructSuccess() { $ip = new IP(TestDataGenerator::ipInt()); $range = new Range($ip, $ip); $this->assertInstanceOf('Bankiru\\IPTools\\Range', $range); $this->assertEquals($ip->getIntValue(), $range->getStart()->getIntValue()); $this->assertEquals($ip->getIntValue(), $range->getEnd()->getIntValue()); }
public function testForeach() { $i = 0; $n = 2; /** @var IP $prevIp */ $prevIp = null; foreach ($this->instance as $key => $ip) { if ($i == 0) { $this->assertEquals($this->ipStart->getIntValue(), $key); $this->assertEquals($this->ipStart, $ip); } elseif ($i < $n) { $this->assertEquals($prevIp->getIntValue() + 1, $key); $this->assertEquals(new IP($prevIp->getIntValue() + 1), $ip); } else { $this->assertEquals($this->ipEnd->getIntValue(), $key); $this->assertEquals($this->ipEnd, $ip); } $prevIp = $ip; $i++; } }
/** * @dataProvider provideConstructValid */ public function testConstructOk($value, $expected) { $ip = new IP($value); $this->assertEquals($expected, $ip->getIntValue()); }