diff --git a/Tests/Handler/AlertifySessionHandlerTest.php b/Tests/Handler/AlertifySessionHandlerTest.php new file mode 100644 index 0000000..f776ab4 --- /dev/null +++ b/Tests/Handler/AlertifySessionHandlerTest.php @@ -0,0 +1,60 @@ +mockSession(); + $container = new ContainerBuilder(); + $loader = new TroopersAlertifyExtension(); + $loader->load([[]], $container); + /** @var AlertifyHelper $helper */ + $helper = new AlertifyHelper($this->session); + $handler = new AlertifySessionHandler( + $this->getTwigEnvironmentMock(), + $container->getParameter('troopers_alertify') + ); + + $helper->congrat('Alert1'); + $this->assertEquals(1, count(explode(' ', $handler->handle($this->session)))); + $helper->congrat('Alert2'); + $helper->congrat('Alert3', ['opt1' => 42]); + $helper->congrat('Alert4'); + $this->assertEquals(3, count(explode(' ', $handler->handle($this->session)))); + } + + /** + * @return Session + */ + protected function mockSession() + { + $this->session = new Session(new MockArraySessionStorage()); + } + + protected function getTwigEnvironmentMock() + { + $twigEnvironment = $this->getMockBuilder('Twig_Environment') + ->setMethods(['render']) + ->getMock(); + + return $twigEnvironment; + } +}