public function testFromString() { $ip = TestDataGenerator::ipString(); $range = new Range(new IP($ip), new IP($ip)); $mock = $this->getMock('Bankiru\\IPTools\\Interfaces\\RangeFactoryInterface'); $mock->expects($this->once())->method('parse')->with($this->equalTo($ip))->willReturn($range); $refClass = new \ReflectionClass('Bankiru\\IPTools\\Range'); $refProp = $refClass->getProperty('factory'); $refProp->setAccessible(true); $refProp->setValue(null, $mock); $refProp->setAccessible(false); $this->assertEquals($range, Range::fromString($ip)); }