[Bridge] [Twig] get and flush only flash sessions you need in getFlashes method
This commit is contained in:
parent
8807eaf30b
commit
33b044adb1
@ -176,9 +176,7 @@ class AppVariable
|
||||
|
||||
$result = array();
|
||||
foreach ($types as $type) {
|
||||
if ($value = $session->getFlashBag()->get($type)) {
|
||||
$result[$type] = $value;
|
||||
}
|
||||
$result[$type] = $session->getFlashBag()->get($type);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
@ -190,7 +190,10 @@ class AppVariableTest extends TestCase
|
||||
$this->assertEquals(array(), $this->appVariable->getFlashes('this-does-not-exist'));
|
||||
|
||||
$flashMessages = $this->setFlashMessages();
|
||||
$this->assertEquals(array(), $this->appVariable->getFlashes(array('this-does-not-exist')));
|
||||
$this->assertEquals(
|
||||
array('this-does-not-exist' => array()),
|
||||
$this->appVariable->getFlashes(array('this-does-not-exist'))
|
||||
);
|
||||
|
||||
$flashMessages = $this->setFlashMessages();
|
||||
$this->assertEquals($flashMessages['notice'], $this->appVariable->getFlashes('notice'));
|
||||
@ -203,7 +206,7 @@ class AppVariableTest extends TestCase
|
||||
|
||||
$flashMessages = $this->setFlashMessages();
|
||||
$this->assertEquals(
|
||||
array('notice' => $flashMessages['notice']),
|
||||
array('notice' => $flashMessages['notice'], 'this-does-not-exist' => array()),
|
||||
$this->appVariable->getFlashes(array('notice', 'this-does-not-exist'))
|
||||
);
|
||||
|
||||
@ -218,6 +221,11 @@ class AppVariableTest extends TestCase
|
||||
$this->appVariable->getFlashes(array('warning')),
|
||||
'After getting some flash types (e.g. "notice" and "error"), the rest of flash messages must remain (e.g. "warning").'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
array('this-does-not-exist' => array()),
|
||||
$this->appVariable->getFlashes(array('this-does-not-exist'))
|
||||
);
|
||||
}
|
||||
|
||||
protected function setRequestStack($request)
|
||||
|
Reference in New Issue
Block a user