Skip to content

Commit 0c9dd5e

Browse files
committed
added tests for must-revalidate
1 parent ac4951a commit 0c9dd5e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/CacheProviderTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ public function testAllowCache()
1616
$this->assertEquals('private, max-age=43200', $cacheControl);
1717
}
1818

19+
public function testAllowCacheWithMustRevalidate()
20+
{
21+
$cacheProvider = new CacheProvider();
22+
$res = $cacheProvider->allowCache(new Response(), 'private', 43200, true);
23+
24+
$cacheControl = $res->getHeaderLine('Cache-Control');
25+
26+
$this->assertEquals('private, max-age=43200, must-revalidate', $cacheControl);
27+
}
28+
1929
public function testDenyCache()
2030
{
2131
$cacheProvider = new CacheProvider();

tests/CacheTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ public function testCacheControlHeader()
3737
$this->assertEquals('public, max-age=86400', $cacheControl);
3838
}
3939

40+
public function testCacheControlHeaderWithMustRevalidate()
41+
{
42+
$cache = new Cache('private', 86400, true);
43+
$req = $this->requestFactory();
44+
$res = new Response();
45+
$next = function (Request $req, Response $res) {
46+
return $res;
47+
};
48+
$res = $cache($req, $res, $next);
49+
50+
$cacheControl = $res->getHeaderLine('Cache-Control');
51+
52+
$this->assertEquals('private, max-age=86400, must-revalidate', $cacheControl);
53+
}
54+
4055
public function testCacheControlHeaderDoesNotOverrideExistingHeader()
4156
{
4257
$cache = new Cache('public', 86400);

0 commit comments

Comments
 (0)