diff --git a/test/ServiceManagerTest.php b/test/ServiceManagerTest.php index 871676ea..374938a5 100644 --- a/test/ServiceManagerTest.php +++ b/test/ServiceManagerTest.php @@ -1101,4 +1101,17 @@ 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 new file mode 100644 index 00000000..9efd5f4e --- /dev/null +++ b/test/TestAsset/AnotherTrollAbstractFactory.php @@ -0,0 +1,36 @@ +inexistingServiceCheckResult = $serviceLocator->has('NonExistingService'); + + if ($name == 'anothertroll') { + return true; + } + + return false; + } + + public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) + { + return new stdClass; + } +}