diff --git a/Resources/views/flash.html.twig b/Resources/views/flash.html.twig
index ddc5072..df60741 100644
--- a/Resources/views/flash.html.twig
+++ b/Resources/views/flash.html.twig
@@ -12,7 +12,7 @@
{% endfor %}
-{% for flashMessage in app.session.flashbag.get('error') %}
+{% for flashMessage in app.session.flashbag.get('danger') %}
{% if close %}{% endif %}
{{ flashMessage|trans({}, translation_domain) }}
diff --git a/Session/FlashMessage.php b/Session/FlashMessage.php
index 98e680b..35ecfce 100644
--- a/Session/FlashMessage.php
+++ b/Session/FlashMessage.php
@@ -38,8 +38,6 @@ public function __construct(SessionInterface $session)
* Sets an alert message.
*
* @param string $message The message
- *
- * @return void
*/
public function alert($message)
{
@@ -47,23 +45,29 @@ public function alert($message)
}
/**
- * Sets an error message.
+ * Alias for `danger()`.
*
* @param string $message The message
- *
- * @return void
*/
public function error($message)
{
- $this->session->getFlashBag()->add('error', $message);
+ $this->danger($message);
+ }
+
+ /**
+ * Sets a danger message.
+ *
+ * @param $message
+ */
+ public function danger($message)
+ {
+ $this->session->getFlashBag()->add('danger', $message);
}
/**
* Sets an info message.
*
* @param string $message The message
- *
- * @return void
*/
public function info($message)
{
@@ -74,18 +78,14 @@ public function info($message)
* Sets a success message.
*
* @param string $message The message
- *
- * @return void
*/
public function success($message)
{
$this->session->getFlashBag()->add('success', $message);
}
-
+
/**
* Resets the flash bag.
- *
- * @return void
*/
public function reset()
{
diff --git a/Tests/Session/FlashMessageTest.php b/Tests/Session/FlashMessageTest.php
index 0e9c21a..8a23082 100644
--- a/Tests/Session/FlashMessageTest.php
+++ b/Tests/Session/FlashMessageTest.php
@@ -13,10 +13,10 @@
*/
class FlashMessageTest extends \PHPUnit_Framework_TestCase
{
- /** @var \Symfony\Component\HttpFoundation\Session\SessionInterface */
+ /** @var \Symfony\Component\HttpFoundation\Session\SessionInterface|\Mockery\MockInterface */
private $session;
- /** @var \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface */
+ /** @var \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface|\Mockery\MockInterface */
private $flashBag;
/** @var FlashMessage */
@@ -61,12 +61,28 @@ public function testError()
{
$this->flashBag
->shouldReceive('add')
- ->with('error', 'Foobar Error')
+ ->with('danger', 'Foobar Error')
->once();
$this->flash->error('Foobar Error');
}
+ /**
+ * Tests the danger() method.
+ *
+ * @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::__construct()
+ * @covers Braincrafted\Bundle\BootstrapBundle\Session\FlashMessage::danger()
+ */
+ public function testDanger()
+ {
+ $this->flashBag
+ ->shouldReceive('add')
+ ->with('danger', 'Foobar Error')
+ ->once();
+
+ $this->flash->danger('Foobar Error');
+ }
+
/**
* Tests the info() method.
*