Skip to content

Commit 0aedb90

Browse files
authored
Added test to verify tags when used with deferred. (#65)
* Added test to verify tags when used with deferred. * allow skip * Require tag-interop
1 parent 26db00b commit 0aedb90

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
],
2424
"require": {
2525
"php": "^5.4|^7",
26-
"psr/cache": "~1.0"
26+
"psr/cache": "~1.0",
27+
"cache/tag-interop": "^1.0"
2728
},
2829
"require-dev": {
2930
"phpunit/phpunit": "^4.0|^5.0",

src/TaggableCachePoolTest.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Cache\IntegrationTests;
1313

14-
use Cache\Adapter\Common\TaggableCacheItemPoolInterface;
14+
use Cache\TagInterop\TaggableCacheItemPoolInterface;
1515

1616
/**
1717
* @author Tobias Nyholm <[email protected]>
@@ -99,6 +99,25 @@ public function testPreviousTag()
9999
$this->assertCount(1, $item->getPreviousTags());
100100
}
101101

102+
public function testPreviousTagDeferred()
103+
{
104+
if (isset($this->skippedTests[__FUNCTION__])) {
105+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
106+
107+
return;
108+
}
109+
110+
$item = $this->cache->getItem('key')->set('value');
111+
$item->setTags(['tag0']);
112+
$this->assertCount(0, $item->getPreviousTags());
113+
114+
$this->cache->saveDeferred($item);
115+
$this->assertCount(0, $item->getPreviousTags());
116+
117+
$item = $this->cache->getItem('key');
118+
$this->assertCount(1, $item->getPreviousTags());
119+
}
120+
102121
/**
103122
* @expectedException \Psr\Cache\InvalidArgumentException
104123
*/
@@ -260,6 +279,12 @@ public function testInvalidateTags()
260279
*/
261280
public function testTagsAreCleanedOnSave()
262281
{
282+
if (isset($this->skippedTests[__FUNCTION__])) {
283+
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);
284+
285+
return;
286+
}
287+
263288
$pool = $this->cache;
264289
$i = $pool->getItem('key')->set('value');
265290
$pool->save($i->setTags(['foo']));

0 commit comments

Comments
 (0)