Allow reuse of Session between requests
This commit is contained in:
parent
86a5d92ce7
commit
fd30f4a21d
@ -178,7 +178,9 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable
|
|||||||
*/
|
*/
|
||||||
public function setId($id)
|
public function setId($id)
|
||||||
{
|
{
|
||||||
$this->storage->setId($id);
|
if ($this->storage->getId() !== $id) {
|
||||||
|
$this->storage->setId($id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,6 +70,27 @@ class SessionTest extends TestCase
|
|||||||
$this->assertEquals('0123456789abcdef', $this->session->getId());
|
$this->assertEquals('0123456789abcdef', $this->session->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSetIdAfterStart()
|
||||||
|
{
|
||||||
|
$this->session->start();
|
||||||
|
$id = $this->session->getId();
|
||||||
|
|
||||||
|
$e = null;
|
||||||
|
try {
|
||||||
|
$this->session->setId($id);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertNull($e);
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->session->setId('different');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertInstanceOf('\LogicException', $e);
|
||||||
|
}
|
||||||
|
|
||||||
public function testSetName()
|
public function testSetName()
|
||||||
{
|
{
|
||||||
$this->assertEquals('MOCKSESSID', $this->session->getName());
|
$this->assertEquals('MOCKSESSID', $this->session->getName());
|
||||||
|
@ -48,7 +48,7 @@ class MockArraySessionStorageTest extends TestCase
|
|||||||
$this->data = array(
|
$this->data = array(
|
||||||
$this->attributes->getStorageKey() => array('foo' => 'bar'),
|
$this->attributes->getStorageKey() => array('foo' => 'bar'),
|
||||||
$this->flashes->getStorageKey() => array('notice' => 'hello'),
|
$this->flashes->getStorageKey() => array('notice' => 'hello'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->storage = new MockArraySessionStorage();
|
$this->storage = new MockArraySessionStorage();
|
||||||
$this->storage->registerBag($this->flashes);
|
$this->storage->registerBag($this->flashes);
|
||||||
|
Reference in New Issue
Block a user