diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php index 377253a086978..663e8484be1ea 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -138,22 +138,48 @@ public function testLastModifiedIsMergedWithEmbeddedResponse() { $cacheStrategy = new ResponseCacheStrategy(); + $mainResponse = new Response(); + $mainResponse->setLastModified(new \DateTimeImmutable('-2 hour')); + $embeddedDate = new \DateTimeImmutable('-1 hour'); + $embeddedResponse = new Response(); + $embeddedResponse->setLastModified($embeddedDate); - // This master response uses the "validation" model - $masterResponse = new Response(); - $masterResponse->setLastModified(new \DateTimeImmutable('-2 hour')); - $masterResponse->setEtag('foo'); + $cacheStrategy->add($embeddedResponse); + $cacheStrategy->update($mainResponse); + + $this->assertTrue($mainResponse->headers->has('Last-Modified')); + $this->assertSame($embeddedDate->getTimestamp(), $mainResponse->getLastModified()->getTimestamp()); + } + + public function testLastModifiedIsRemovedWhenEmbeddedResponseHasNoLastModified() + { + $cacheStrategy = new ResponseCacheStrategy(); + + $mainResponse = new Response(); + $mainResponse->setLastModified(new \DateTimeImmutable('-2 hour')); - // Embedded response uses "expiry" model $embeddedResponse = new Response(); - $embeddedResponse->setLastModified($embeddedDate); + $cacheStrategy->add($embeddedResponse); + $cacheStrategy->update($mainResponse); + + $this->assertFalse($mainResponse->headers->has('Last-Modified')); + } - $cacheStrategy->update($masterResponse); + public function testLastModifiedIsNotAddedWhenMainResponseHasNoLastModified() + { + $cacheStrategy = new ResponseCacheStrategy(); - $this->assertTrue($masterResponse->isValidateable()); - $this->assertSame($embeddedDate->getTimestamp(), $masterResponse->getLastModified()->getTimestamp()); + $mainResponse = new Response(); + + $embeddedResponse = new Response(); + $embeddedResponse->setLastModified(new \DateTimeImmutable('-2 hour')); + + $cacheStrategy->add($embeddedResponse); + $cacheStrategy->update($mainResponse); + + $this->assertFalse($mainResponse->headers->has('Last-Modified')); } public function testMainResponseIsNotCacheableWhenEmbeddedResponseIsNotCacheable() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy