@@ -213,6 +213,40 @@ public function testSessionCookieNotWrittenCookieGiven()
213
213
$ this ->assertCount (0 , $ cookies );
214
214
}
215
215
216
+ /**
217
+ * @runInSeparateProcess
218
+ */
219
+ public function testNewSessionIdIsNotOverwritten ()
220
+ {
221
+ $ newSessionId = $ this ->createValidSessionId ();
222
+
223
+ $ this ->assertNotEmpty ($ newSessionId );
224
+
225
+ $ request = new Request ();
226
+ $ request ->cookies ->set ('PHPSESSID ' , 'OLD-SESSION-ID ' );
227
+
228
+ $ listener = $ this ->createListener ($ request , new NativeSessionStorageFactory ());
229
+
230
+ $ kernel = $ this ->createMock (HttpKernelInterface::class);
231
+ $ listener ->onKernelRequest (new RequestEvent ($ kernel , $ request , HttpKernelInterface::MAIN_REQUEST ));
232
+
233
+ $ session = $ request ->getSession ();
234
+ $ this ->assertSame ($ newSessionId , $ session ->getId ());
235
+ $ session ->set ('hello ' , 'world ' );
236
+
237
+ $ response = new Response ();
238
+ $ listener ->onKernelResponse (new ResponseEvent ($ kernel , $ request , HttpKernelInterface::MAIN_REQUEST , $ response ));
239
+ $ this ->assertSame ($ newSessionId , $ session ->getId ());
240
+
241
+ $ cookies = $ response ->headers ->getCookies ();
242
+
243
+ $ this ->assertCount (1 , $ cookies );
244
+ $ sessionCookie = $ cookies [0 ];
245
+
246
+ $ this ->assertSame ('PHPSESSID ' , $ sessionCookie ->getName ());
247
+ $ this ->assertSame ($ newSessionId , $ sessionCookie ->getValue ());
248
+ }
249
+
216
250
/**
217
251
* @runInSeparateProcess
218
252
*/
@@ -525,7 +559,7 @@ public function testUninitializedSessionWithoutInitializedSession()
525
559
public function testSurrogateMainRequestIsPublic ()
526
560
{
527
561
$ session = $ this ->createMock (Session::class);
528
- $ session ->expects ($ this ->exactly (2 ))->method ('getName ' )->willReturn ('PHPSESSID ' );
562
+ $ session ->expects ($ this ->exactly (1 ))->method ('getName ' )->willReturn ('PHPSESSID ' );
529
563
$ session ->expects ($ this ->exactly (2 ))->method ('getUsageIndex ' )->will ($ this ->onConsecutiveCalls (0 , 1 ));
530
564
$ sessionFactory = $ this ->createMock (SessionFactory::class);
531
565
$ sessionFactory ->expects ($ this ->once ())->method ('createSession ' )->willReturn ($ session );
@@ -565,9 +599,14 @@ public function testSurrogateMainRequestIsPublic()
565
599
public function testGetSessionIsCalledOnce ()
566
600
{
567
601
$ session = $ this ->createMock (Session::class);
602
+ <<<<<<< HEAD
568
603
$ session->expects ($ this ->exactly (2 ))->method ('getName ' )->willReturn ('PHPSESSID ' );
569
604
$ sessionFactory = $ this ->createMock (SessionFactory::class);
570
605
$ sessionFactory ->expects ($ this ->once ())->method ('createSession ' )->willReturn ($ session );
606
+ =======
607
+ $ session ->expects ($ this ->exactly (1 ))->method ('getName ' )->willReturn ('PHPSESSID ' );
608
+ $ sessionStorage = $ this ->createMock (NativeSessionStorage::class);
609
+ >>>>>>> 5.4
571
610
$ kernel = $ this ->createMock (KernelInterface::class);
572
611
573
612
$ requestStack = new RequestStack ();
0 commit comments