Skip to content

Commit

Permalink
Add test with a complex one-line Cache-Control
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevinrob committed Jul 30, 2015
1 parent 374da39 commit bdf29d3
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/HeaderCacheControlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function setUp()
(new Response())
->withAddedHeader("Cache-Control", "max-age=2")
);
case '/2s-complex':
return new FulfilledPromise(
(new Response())
->withAddedHeader("Cache-Control", "invalid-token =\"yes\", max-age=2, stale-while-revalidate= 60")
);
case '/no-store':
return new FulfilledPromise(
(new Response())
Expand Down Expand Up @@ -72,6 +77,19 @@ public function testMaxAgeHeader()
$this->assertEquals(CacheMiddleware::HEADER_CACHE_MISS, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));
}

public function testMaxAgeComplexHeader()
{
$this->client->get("http://test.com/2s-complex");

$response = $this->client->get("http://test.com/2s-complex");
$this->assertEquals(CacheMiddleware::HEADER_CACHE_HIT, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));

sleep(3);

$response = $this->client->get("http://test.com/2s-complex");
$this->assertEquals(CacheMiddleware::HEADER_CACHE_MISS, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));
}

public function testNoStoreHeader()
{
$this->client->get("http://test.com/no-store");
Expand All @@ -88,4 +106,4 @@ public function testNoCacheHeader()
$this->assertEquals(CacheMiddleware::HEADER_CACHE_HIT, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));
}

}
}

0 comments on commit bdf29d3

Please sign in to comment.