Skip to content

Commit

Permalink
Reverted changes to existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp committed Dec 8, 2018
1 parent d21aafa commit ffd95d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 83 deletions.
Expand Up @@ -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'));
}

Expand Down Expand Up @@ -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'));
}

Expand Down
Expand Up @@ -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());
}

Expand All @@ -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()
Expand Down Expand Up @@ -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());
}

Expand Down Expand Up @@ -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'));
}
}

0 comments on commit ffd95d7

Please sign in to comment.