Пример #1
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testStringifyFail()
 {
     $ip = TestDataGenerator::ipString();
     $range = new Range(new IP($ip), new IP($ip));
     $mockConverter = $this->getMock('Bankiru\\IPTools\\Interfaces\\RangeConverterInterface');
     $mockConverter->expects($this->once())->method('stringify')->with($this->equalTo($range))->willThrowException(new \InvalidArgumentException('INVALID RANGE'));
     $this->refProp->setValue(null, array($mockConverter));
     $this->instance->stringify($range);
     $this->fail('parse should fail on invalid input');
 }
Пример #2
0
 public function testToString()
 {
     $ip = TestDataGenerator::ipString();
     $range = new Range(new IP($ip), new IP($ip));
     $mock = $this->getMock('Bankiru\\IPTools\\Interfaces\\RangeFactoryInterface');
     $mock->expects($this->once())->method('stringify')->with($this->equalTo($range))->willReturn($ip);
     $refClass = new \ReflectionClass('Bankiru\\IPTools\\Range');
     $refProp = $refClass->getProperty('factory');
     $refProp->setAccessible(true);
     $refProp->setValue(null, $mock);
     $refProp->setAccessible(false);
     $this->assertEquals($ip, (string) $range);
 }
Пример #3
0
 protected function setUp()
 {
     $this->ipStart = new IP(TestDataGenerator::ipInt());
     $this->ipEnd = new IP($this->ipStart->getIntValue() + 2);
     $this->instance = new RangeIterator(new Range($this->ipStart, $this->ipEnd));
 }
Пример #4
0
 public function testToString()
 {
     $stringValue = TestDataGenerator::ipString();
     $ip = new IP($stringValue);
     $this->assertEquals($stringValue, (string) $ip);
 }