From af02bd46cc159ee22fe44c1f32bf57a476f264c7 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 20 May 2014 19:15:56 +0200 Subject: [PATCH] #6266 - Verifying that the `EventManagerAwareInitializer` can be replaced --- .../Mvc/Service/ServiceManagerConfigTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/ZendTest/Mvc/Service/ServiceManagerConfigTest.php b/tests/ZendTest/Mvc/Service/ServiceManagerConfigTest.php index d4a2f216400..fc32beffd97 100644 --- a/tests/ZendTest/Mvc/Service/ServiceManagerConfigTest.php +++ b/tests/ZendTest/Mvc/Service/ServiceManagerConfigTest.php @@ -247,4 +247,29 @@ public function testServiceLocatorInitializerCanBeReplaced() $serviceManager->get('service-locator-aware'); } + + /** + * @group 6266 + */ + public function testEventManagerInitializerCanBeReplaced() + { + $instance = $this->getMock('Zend\EventManager\EventManagerAwareInterface'); + $initializer = $this->getMock('stdClass', array('__invoke')); + $serviceManager = new ServiceManager(new ServiceManagerConfig(array( + 'initializers' => array( + 'EventManagerAwareInitializer' => $initializer + ), + 'factories' => array( + 'event-manager-aware' => function () use ($instance) { + return $instance; + }, + ), + ))); + + $initializer->expects($this->once())->method('__invoke')->with($instance, $serviceManager); + $instance->expects($this->never())->method('getEventManager'); + $instance->expects($this->never())->method('setEventManager'); + + $serviceManager->get('event-manager-aware'); + } }