diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php index 48ec5e5923e88..a41d8665083c2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/HttpCacheTest.php @@ -1242,6 +1242,7 @@ public function testEsiCacheForceValidation() $this->assertEquals('Hello World! My name is Bobby.', $this->response->getContent()); $this->assertNull($this->response->getTtl()); $this->assertTrue($this->response->mustRevalidate()); + $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); $this->assertTrue($this->response->headers->hasCacheControlDirective('no-cache')); } @@ -1272,6 +1273,7 @@ public function testEsiCacheForceValidationForHeadRequests() $this->assertEmpty($this->response->getContent()); $this->assertNull($this->response->getTtl()); $this->assertTrue($this->response->mustRevalidate()); + $this->assertTrue($this->response->headers->hasCacheControlDirective('private')); $this->assertTrue($this->response->headers->hasCacheControlDirective('no-cache')); } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php index 3d9be7180e0ec..6d67a177398c2 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/ResponseCacheStrategyTest.php @@ -88,8 +88,8 @@ public function testMasterResponseNotCacheableWhenEmbeddedResponseRequiresValida $masterResponse->setSharedMaxAge(3600); $cacheStrategy->update($masterResponse); - $this->assertFalse($masterResponse->headers->hasCacheControlDirective('public')); - $this->assertFalse($masterResponse->headers->hasCacheControlDirective('s-maxage')); + $this->assertTrue($masterResponse->headers->hasCacheControlDirective('no-cache')); + $this->assertTrue($masterResponse->headers->hasCacheControlDirective('must-revalidate')); $this->assertFalse($masterResponse->isFresh()); } @@ -112,6 +112,8 @@ public function testValidationOnMasterResponseIsNotPossibleWhenItContainsEmbedde $this->assertFalse($masterResponse->isValidateable()); $this->assertFalse($masterResponse->headers->has('Last-Modified')); $this->assertFalse($masterResponse->headers->has('ETag')); + $this->assertTrue($masterResponse->headers->hasCacheControlDirective('no-cache')); + $this->assertTrue($masterResponse->headers->hasCacheControlDirective('must-revalidate')); } public function testMasterResponseWithValidationIsUnchangedWhenThereIsNoEmbeddedResponse() @@ -153,6 +155,7 @@ public function testMasterResponseIsNotCacheableWhenEmbeddedResponseIsNotCacheab $cacheStrategy->update($masterResponse); $this->assertTrue($masterResponse->headers->hasCacheControlDirective('no-cache')); + $this->assertTrue($masterResponse->headers->hasCacheControlDirective('must-revalidate')); $this->assertFalse($masterResponse->isFresh()); } @@ -234,85 +237,4 @@ public function testResponseIsExpirableButNotValidateableWhenMasterResponseCombi $this->assertSame('60', $masterResponse->headers->getCacheControlDirective('s-maxage')); $this->assertFalse($masterResponse->isValidateable()); } - - public function testResponseIsPrivateWhenCombiningPrivateResponses() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $masterResponse = new Response(); - $masterResponse->setSharedMaxAge(60); - $masterResponse->setPrivate(); - - $embeddedResponse = new Response(); - $embeddedResponse->setSharedMaxAge(60); - $embeddedResponse->setPrivate(); - - $cacheStrategy->add($embeddedResponse); - $cacheStrategy->update($masterResponse); - - $this->assertFalse($masterResponse->headers->hasCacheControlDirective('no-cache')); - $this->assertFalse($masterResponse->headers->hasCacheControlDirective('must-revalidate')); - $this->assertTrue($masterResponse->headers->hasCacheControlDirective('private')); - } - - public function testMasterResponseHasLowestPrivateMaxAge() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $response1 = new Response(); - $response1->setMaxAge(3600); - $response1->setPrivate(); - $cacheStrategy->add($response1); - - $response2 = new Response(); - $response2->setSharedMaxAge(60); - $response2->setMaxAge(60); - $response2->setPublic(); - $cacheStrategy->add($response2); - - $response3 = new Response(); - $response3->setMaxAge(60); - $response3->setPrivate(); - $cacheStrategy->add($response3); - - $response = new Response(); - $response->setMaxAge(100); - $response->setPrivate(); - $cacheStrategy->update($response); - - $this->assertFalse($response->headers->hasCacheControlDirective('public')); - $this->assertTrue($response->headers->hasCacheControlDirective('private')); - $this->assertFalse($response->headers->hasCacheControlDirective('s-maxage')); - $this->assertSame('60', $response->headers->getCacheControlDirective('max-age')); - } - - public function testMasterResponseHasBothMaxAges() - { - $cacheStrategy = new ResponseCacheStrategy(); - - $response1 = new Response(); - $response1->setSharedMaxAge(1000); - $response1->setMaxAge(30); - $cacheStrategy->add($response1); - - $response2 = new Response(); - $response2->setSharedMaxAge(500); - $response2->setMaxAge(500); - $cacheStrategy->add($response2); - - $response3 = new Response(); - $response3->setSharedMaxAge(30); - $response3->setMaxAge(1000); - $cacheStrategy->add($response3); - - $response = new Response(); - $response->setSharedMaxAge(100); - $response->setMaxAge(2000); - $cacheStrategy->update($response); - - $this->assertTrue($response->headers->hasCacheControlDirective('public')); - $this->assertFalse($response->headers->hasCacheControlDirective('private')); - $this->assertSame('30', $response->headers->getCacheControlDirective('s-maxage')); - $this->assertSame('30', $response->headers->getCacheControlDirective('max-age')); - } }