File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
src/Symfony/Component/HttpFoundation Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 ();
You can’t perform that action at this time.
0 commit comments