Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8f60a8a

Browse filesBrowse files
committed
Allow reuse of MockArraySessionStorage between requests
1 parent 86a5d92 commit 8f60a8a
Copy full SHA for 8f60a8a

File tree

Expand file treeCollapse file tree

2 files changed

+26
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+26
-2
lines changed

‎src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Session/Storage/MockArraySessionStorage.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function getId()
123123
*/
124124
public function setId($id)
125125
{
126-
if ($this->started) {
126+
if ($this->started && $this->id !== $id) {
127127
throw new \LogicException('Cannot set session ID after the session has started.');
128128
}
129129

‎src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/Session/Storage/MockArraySessionStorageTest.php
+25-1Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function setUp()
4848
$this->data = array(
4949
$this->attributes->getStorageKey() => array('foo' => 'bar'),
5050
$this->flashes->getStorageKey() => array('notice' => 'hello'),
51-
);
51+
);
5252

5353
$this->storage = new MockArraySessionStorage();
5454
$this->storage->registerBag($this->flashes);
@@ -97,6 +97,30 @@ public function testGetId()
9797
$this->assertNotEquals('', $this->storage->getId());
9898
}
9999

100+
public function testSetId()
101+
{
102+
$this->storage->start();
103+
$id = $this->storage->getId();
104+
105+
$exception = null;
106+
try {
107+
$this->storage->setId($id);
108+
} catch (\Exception $e) {
109+
$exception = $e;
110+
}
111+
112+
$this->assertNull($exception);
113+
114+
$exception = null;
115+
try {
116+
$this->storage->setId('different');
117+
} catch (\Exception $e) {
118+
$exception = $e;
119+
}
120+
121+
$this->assertInstanceOf('\LogicException', $exception);
122+
}
123+
100124
public function testClearClearsBags()
101125
{
102126
$this->storage->clear();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.