diff --git a/test/ServiceManagerTest.php b/test/ServiceManagerTest.php index 374938a5..67200267 100644 --- a/test/ServiceManagerTest.php +++ b/test/ServiceManagerTest.php @@ -571,6 +571,27 @@ public function testCallingANonExistingServiceFromAnAbstractServiceDoesNotMakeTh $this->assertInstanceOf('stdClass', $service); } + public function testMultipleAbstractFactoriesWithOneLookingForANonExistingServiceDuringCanCreate() + { + $abstractFactory = new TestAsset\TrollAbstractFactory; + $anotherAbstractFactory = $this->getMock('Zend\ServiceManager\AbstractFactoryInterface'); + $anotherAbstractFactory + ->expects($this->exactly(2)) + ->method('canCreateServiceWithName') + ->with( + $this->serviceManager, + $this->logicalOr('somethingthatcanbecreated', 'nonexistingservice'), + $this->logicalOr('SomethingThatCanBeCreated', 'NonExistingService') + ) + ->will($this->returnValue(false)); + + $this->serviceManager->addAbstractFactory($abstractFactory); + $this->serviceManager->addAbstractFactory($anotherAbstractFactory); + + $this->assertTrue($this->serviceManager->has('SomethingThatCanBeCreated')); + $this->assertFalse($abstractFactory->inexistingServiceCheckResult); + } + public function testWaitingAbstractFactory() { $abstractFactory = new TestAsset\WaitingAbstractFactory; @@ -1101,17 +1122,4 @@ public function getServiceOfVariousTypes() array(tmpfile()) ); } - - public function testMultipleAbstractFactoriesLookingForANonExistingServiceDuringCanCreatePhase() - { - $abstractFactory = new TestAsset\TrollAbstractFactory; - $anotherAbstractFactory = new TestAsset\AnotherTrollAbstractFactory; - - $this->serviceManager->addAbstractFactory($abstractFactory); - $this->serviceManager->addAbstractFactory($anotherAbstractFactory); - - $this->assertTrue($this->serviceManager->has('anothertroll')); - $this->assertFalse($abstractFactory->inexistingServiceCheckResult); - $this->assertFalse($anotherAbstractFactory->inexistingServiceCheckResult); - } } diff --git a/test/TestAsset/AnotherTrollAbstractFactory.php b/test/TestAsset/AnotherTrollAbstractFactory.php deleted file mode 100644 index 9efd5f4e..00000000 --- a/test/TestAsset/AnotherTrollAbstractFactory.php +++ /dev/null @@ -1,36 +0,0 @@ -inexistingServiceCheckResult = $serviceLocator->has('NonExistingService'); - - if ($name == 'anothertroll') { - return true; - } - - return false; - } - - public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) - { - return new stdClass; - } -}