@@ -138,22 +138,48 @@ public function testLastModifiedIsMergedWithEmbeddedResponse()
138
138
{
139
139
$ cacheStrategy = new ResponseCacheStrategy ();
140
140
141
+ $ mainResponse = new Response ();
142
+ $ mainResponse ->setLastModified (new \DateTimeImmutable ('-2 hour ' ));
143
+
141
144
$ embeddedDate = new \DateTimeImmutable ('-1 hour ' );
145
+ $ embeddedResponse = new Response ();
146
+ $ embeddedResponse ->setLastModified ($ embeddedDate );
142
147
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 ' ));
147
161
148
- // Embedded response uses "expiry" model
149
162
$ embeddedResponse = new Response ();
150
- $ embeddedResponse -> setLastModified ( $ embeddedDate );
163
+
151
164
$ cacheStrategy ->add ($ embeddedResponse );
165
+ $ cacheStrategy ->update ($ mainResponse );
166
+
167
+ $ this ->assertFalse ($ mainResponse ->headers ->has ('Last-Modified ' ));
168
+ }
152
169
153
- $ cacheStrategy ->update ($ masterResponse );
170
+ public function testLastModifiedIsNotAddedWhenMainResponseHasNoLastModified ()
171
+ {
172
+ $ cacheStrategy = new ResponseCacheStrategy ();
154
173
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 ' ));
157
183
}
158
184
159
185
public function testMainResponseIsNotCacheableWhenEmbeddedResponseIsNotCacheable ()
0 commit comments