[Session] Fixed Backward Compatibility issue with getFlashes()
This commit is contained in:
parent
b7189fd54a
commit
6756f2819d
@ -256,7 +256,11 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
||||
$return = array();
|
||||
if ($all) {
|
||||
foreach ($all as $name => $array) {
|
||||
$return[$name] = reset($array);
|
||||
if (is_numeric(key($array))) {
|
||||
$return[$name] = reset($array);
|
||||
} else {
|
||||
$return[$name] = $array;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,6 +183,21 @@ class SessionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array('notice' => 'foo'), $this->session->getFlashes());
|
||||
}
|
||||
|
||||
public function testGetFlashesWithArray()
|
||||
{
|
||||
$array = array('notice' => 'hello', 'error' => 'none');
|
||||
$this->assertEquals(array(), $this->session->getFlashes());
|
||||
$this->session->setFlash('foo', $array);
|
||||
$this->assertEquals(array('foo' => $array), $this->session->getFlashes());
|
||||
$this->assertEquals(array(), $this->session->getFlashes());
|
||||
|
||||
$array = array('hello', 'foo');
|
||||
$this->assertEquals(array(), $this->session->getFlashes());
|
||||
$this->session->setFlash('foo', $array);
|
||||
$this->assertEquals(array('foo' => 'hello'), $this->session->getFlashes());
|
||||
$this->assertEquals(array(), $this->session->getFlashes());
|
||||
}
|
||||
|
||||
public function testGetSetFlash()
|
||||
{
|
||||
$this->assertNull($this->session->getFlash('notice'));
|
||||
|
Reference in New Issue
Block a user