@@ -121,7 +121,7 @@ public function testResponseIsStillPublicIfSessionStartedAndHeaderPresent()
121121 $ this ->assertFalse ($ response ->headers ->has (AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER ));
122122 }
123123
124- public function testUninitializedSession ()
124+ public function testUninitializedSessionUsingInitializedSessionService ()
125125 {
126126 $ kernel = $ this ->createMock (HttpKernelInterface::class);
127127 $ response = new Response ();
@@ -142,6 +142,26 @@ public function testUninitializedSession()
142142 $ this ->assertFalse ($ response ->headers ->has (AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER ));
143143 }
144144
145+ public function testUninitializedSessionUsingSessionFromRequest ()
146+ {
147+ $ kernel = $ this ->createMock (HttpKernelInterface::class);
148+ $ response = new Response ();
149+ $ response ->setSharedMaxAge (60 );
150+ $ response ->headers ->set (AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER , 'true ' );
151+
152+ $ request = new Request ();
153+ $ request ->setSession (new Session ());
154+
155+ $ listener = new SessionListener (new Container ());
156+ $ listener ->onKernelResponse (new ResponseEvent ($ kernel , $ request , HttpKernelInterface::MAIN_REQUEST , $ response ));
157+ $ this ->assertFalse ($ response ->headers ->has ('Expires ' ));
158+ $ this ->assertTrue ($ response ->headers ->hasCacheControlDirective ('public ' ));
159+ $ this ->assertFalse ($ response ->headers ->hasCacheControlDirective ('private ' ));
160+ $ this ->assertFalse ($ response ->headers ->hasCacheControlDirective ('must-revalidate ' ));
161+ $ this ->assertSame ('60 ' , $ response ->headers ->getCacheControlDirective ('s-maxage ' ));
162+ $ this ->assertFalse ($ response ->headers ->has (AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER ));
163+ }
164+
145165 public function testUninitializedSessionWithoutInitializedSession ()
146166 {
147167 $ kernel = $ this ->createMock (HttpKernelInterface::class);
0 commit comments