@@ -121,7 +121,7 @@ public function testResponseIsStillPublicIfSessionStartedAndHeaderPresent()
121
121
$ this ->assertFalse ($ response ->headers ->has (AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER ));
122
122
}
123
123
124
- public function testUninitializedSession ()
124
+ public function testUninitializedSessionUsingInitializedSessionService ()
125
125
{
126
126
$ kernel = $ this ->createMock (HttpKernelInterface::class);
127
127
$ response = new Response ();
@@ -142,6 +142,26 @@ public function testUninitializedSession()
142
142
$ this ->assertFalse ($ response ->headers ->has (AbstractSessionListener::NO_AUTO_CACHE_CONTROL_HEADER ));
143
143
}
144
144
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
+
145
165
public function testUninitializedSessionWithoutInitializedSession ()
146
166
{
147
167
$ kernel = $ this ->createMock (HttpKernelInterface::class);
0 commit comments