Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions tests/Psr6StoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Psr\Cache\CacheItemInterface;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\FilesystemTagAwareAdapter;
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
Expand Down Expand Up @@ -890,6 +891,38 @@ public function contentDigestExpiryProvider()
];
}

public function testHitAfterExpiredWithTags()
{
// first request to this resource
$request1 = Request::create('https://foobar.com/');
$response1 = new Response('hello world', 200, ['Cache-Control' => 's-maxage=5, public']);
$response1->headers->set('Cache-Tags', 'foobar,other tag');

$this->store->write($request1, $response1);
$cacheKey = $this->store->getCacheKey($request1);

// should be cached after it
$cacheItem = $this->getCache()->getItem($cacheKey);
$this->assertTrue($cacheItem->isHit());

// should be expired after 5 seconds
sleep(5);
$cacheItem = $this->getCache()->getItem($cacheKey);
$this->assertFalse($cacheItem->isHit());

// second request to the same resource
$request2 = Request::create('https://foobar.com/');
$response2 = new Response('hello world', 200, ['Cache-Control' => 's-maxage=5, public']);
$response2->headers->set('Cache-Tags', 'foobar,other tag');

$this->store->write($request2, $response2);
$cacheKey = $this->store->getCacheKey($request2);

// should be cache hit again
$cacheItem = $this->getCache()->getItem($cacheKey);
$this->assertTrue($cacheItem->isHit());
}

/**
* @param null $store
*
Expand Down