From 43b34edc78a6b31adf591fc30ee3f2ef0ed51cba Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Mon, 21 Nov 2016 22:23:05 +0700 Subject: [PATCH] pull FlashMessenger container from flashMessenger plugin --- src/Module.php | 4 ++-- test/ModuleTest.php | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Module.php b/src/Module.php index 6476b29..af6cd93 100644 --- a/src/Module.php +++ b/src/Module.php @@ -63,8 +63,8 @@ public function flashMessengerHandler(EventInterface $e) return; } - $flash = $controller->plugin('flashMessenger'); - $container = new Container('FlashMessenger'); + $flash = $controller->plugin('flashMessenger'); + $container = $flash->getContainer(); $reCreateFlash = $container->getArrayCopy(); foreach ($reCreateFlash as $key => $row) { diff --git a/test/ModuleTest.php b/test/ModuleTest.php index d76e89c..c474817 100644 --- a/test/ModuleTest.php +++ b/test/ModuleTest.php @@ -78,7 +78,7 @@ public function testOnBootstrap($hasMessages) $sharedEvmAttach->will(function() use ($module, $e, $hasMessages, $abstractActionController, $flashMessenger, $pluginManager) { $abstractActionController->getPluginManager()->willReturn($pluginManager)->shouldBeCalled(); $pluginManager->has('flashMessenger')->willReturn(true)->shouldBeCalled(); - + if ($hasMessages) { $namespace = 'flash'; $message = 'a message'; @@ -89,6 +89,8 @@ public function testOnBootstrap($hasMessages) $container = new Container('FlashMessenger'); $container->offsetSet($namespace, $splQueue); + $flashMessenger->getContainer()->willReturn($container) + ->shouldBeCalled(); $flashMessenger->setNamespace($namespace) ->willReturn($flashMessenger) ->shouldBeCalled(); @@ -121,7 +123,7 @@ public function testOnBootstrap($hasMessages) $this->module->onBootstrap($e->reveal()); } - + public function testOnBootstrapWithDoesntHasFlashMessenger() { $e = $this->prophesize('Zend\Mvc\MvcEvent'); @@ -161,7 +163,7 @@ public function testOnBootstrapWithDoesntHasFlashMessenger() $e->getApplication() ->willReturn($application) - ->shouldBeCalled(); + ->shouldBeCalled(); $this->module->onBootstrap($e->reveal()); }