@@ -138,22 +138,48 @@ public function testLastModifiedIsMergedWithEmbeddedResponse()
138138 {
139139 $ cacheStrategy = new ResponseCacheStrategy ();
140140
141+ $ mainResponse = new Response ();
142+ $ mainResponse ->setLastModified (new \DateTimeImmutable ('-2 hour ' ));
143+
141144 $ embeddedDate = new \DateTimeImmutable ('-1 hour ' );
145+ $ embeddedResponse = new Response ();
146+ $ embeddedResponse ->setLastModified ($ embeddedDate );
142147
143- // This master response uses the "validation" model
144- $ masterResponse = new Response ();
145- $ masterResponse ->setLastModified (new \DateTimeImmutable ('-2 hour ' ));
146- $ masterResponse ->setEtag ('foo ' );
148+ $ cacheStrategy ->add ($ embeddedResponse );
149+ $ cacheStrategy ->update ($ mainResponse );
150+
151+ $ this ->assertTrue ($ mainResponse ->headers ->has ('Last-Modified ' ));
152+ $ this ->assertSame ($ embeddedDate ->getTimestamp (), $ mainResponse ->getLastModified ()->getTimestamp ());
153+ }
154+
155+ public function testLastModifiedIsRemovedWhenEmbeddedResponseHasNoLastModified ()
156+ {
157+ $ cacheStrategy = new ResponseCacheStrategy ();
158+
159+ $ mainResponse = new Response ();
160+ $ mainResponse ->setLastModified (new \DateTimeImmutable ('-2 hour ' ));
147161
148- // Embedded response uses "expiry" model
149162 $ embeddedResponse = new Response ();
150- $ embeddedResponse -> setLastModified ( $ embeddedDate );
163+
151164 $ cacheStrategy ->add ($ embeddedResponse );
165+ $ cacheStrategy ->update ($ mainResponse );
166+
167+ $ this ->assertFalse ($ mainResponse ->headers ->has ('Last-Modified ' ));
168+ }
152169
153- $ cacheStrategy ->update ($ masterResponse );
170+ public function testLastModifiedIsNotAddedWhenMainResponseHasNoLastModified ()
171+ {
172+ $ cacheStrategy = new ResponseCacheStrategy ();
154173
155- $ this ->assertTrue ($ masterResponse ->isValidateable ());
156- $ this ->assertSame ($ embeddedDate ->getTimestamp (), $ masterResponse ->getLastModified ()->getTimestamp ());
174+ $ mainResponse = new Response ();
175+
176+ $ embeddedResponse = new Response ();
177+ $ embeddedResponse ->setLastModified (new \DateTimeImmutable ('-2 hour ' ));
178+
179+ $ cacheStrategy ->add ($ embeddedResponse );
180+ $ cacheStrategy ->update ($ mainResponse );
181+
182+ $ this ->assertFalse ($ mainResponse ->headers ->has ('Last-Modified ' ));
157183 }
158184
159185 public function testMainResponseIsNotCacheableWhenEmbeddedResponseIsNotCacheable ()
0 commit comments