Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Helper/FlashMessenger.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function render($namespace = PluginFlashMessenger::NAMESPACE_DEFAULT, arr

// Generate markup
$markup = sprintf($this->getMessageOpenFormat(), ' class="' . implode(' ', $classes) . '"');
$markup .= implode($this->getMessageSeparatorString(), $messagesToPrint);
$markup .= implode(sprintf($this->getMessageSeparatorString(), ' class="' . implode(' ', $classes) . '"'), $messagesToPrint);
$markup .= $this->getMessageCloseString();

return $markup;
Expand Down
48 changes: 48 additions & 0 deletions test/Helper/FlashMessengerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ public function testCanDisplayListOfMessagesCustomised()
$this->assertEquals($displayInfoAssertion, $displayInfo);
}

public function testCanDisplayListOfMessagesCustomisedSeparator()
{
$this->seedMessages();

$displayInfoAssertion = '<div><p class="foo-baz foo-bar">foo</p><p class="foo-baz foo-bar">bar</p></div>';
$displayInfo = $this->helper
->setMessageOpenFormat('<div><p%s>')
->setMessageSeparatorString('</p><p%s>')
->setMessageCloseString('</p></div>')
->render(PluginFlashMessenger::NAMESPACE_DEFAULT, array('foo-baz', 'foo-bar'));
$this->assertEquals($displayInfoAssertion, $displayInfo);
}

public function testCanDisplayListOfMessagesCustomisedByConfig()
{
$this->seedMessages();
Expand Down Expand Up @@ -184,6 +197,41 @@ public function testCanDisplayListOfMessagesCustomisedByConfig()
$this->assertEquals($displayInfoAssertion, $displayInfo);
}

public function testCanDisplayListOfMessagesCustomisedByConfigSeparator()
{
$this->seedMessages();

$config = array(
'view_helper_config' => array(
'flashmessenger' => array(
'message_open_format' => '<div><ul><li%s>',
'message_separator_string' => '</li><li%s>',
'message_close_string' => '</li></ul></div>',
),
),
);
$sm = new ServiceManager();
$sm->setService('Config', $config);
$helperPluginManager = new HelperPluginManager(new Config(array(
'factories' => array(
'flashmessenger' => 'Zend\View\Helper\Service\FlashMessengerFactory',
),
)));
$controllerPluginManager = new PluginManager(new Config(array(
'invokables' => array(
'flashmessenger' => 'Zend\Mvc\Controller\Plugin\FlashMessenger',
),
)));
$helperPluginManager->setServiceLocator($sm);
$controllerPluginManager->setServiceLocator($sm);
$sm->setService('ControllerPluginManager', $controllerPluginManager);
$helper = $helperPluginManager->get('flashmessenger');

$displayInfoAssertion = '<div><ul><li class="foo-baz foo-bar">foo</li><li class="foo-baz foo-bar">bar</li></ul></div>';
$displayInfo = $helper->render(PluginFlashMessenger::NAMESPACE_DEFAULT, array('foo-baz', 'foo-bar'));
$this->assertEquals($displayInfoAssertion, $displayInfo);
}

public function testCanTranslateMessages()
{
$mockTranslator = $this->getMock('Zend\I18n\Translator\Translator');
Expand Down

0 comments on commit d233be3

Please sign in to comment.