Skip to content

Commit

Permalink
Added test to verify tags when used with deferred. (#65)
Browse files Browse the repository at this point in the history
* Added test to verify tags when used with deferred.

* allow skip

* Require tag-interop
  • Loading branch information
Nyholm authored Dec 30, 2016
1 parent 26db00b commit 0aedb90
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
],
"require": {
"php": "^5.4|^7",
"psr/cache": "~1.0"
"psr/cache": "~1.0",
"cache/tag-interop": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0",
Expand Down
27 changes: 26 additions & 1 deletion src/TaggableCachePoolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Cache\IntegrationTests;

use Cache\Adapter\Common\TaggableCacheItemPoolInterface;
use Cache\TagInterop\TaggableCacheItemPoolInterface;

/**
* @author Tobias Nyholm <[email protected]>
Expand Down Expand Up @@ -99,6 +99,25 @@ public function testPreviousTag()
$this->assertCount(1, $item->getPreviousTags());
}

public function testPreviousTagDeferred()
{
if (isset($this->skippedTests[__FUNCTION__])) {
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);

return;
}

$item = $this->cache->getItem('key')->set('value');
$item->setTags(['tag0']);
$this->assertCount(0, $item->getPreviousTags());

$this->cache->saveDeferred($item);
$this->assertCount(0, $item->getPreviousTags());

$item = $this->cache->getItem('key');
$this->assertCount(1, $item->getPreviousTags());
}

/**
* @expectedException \Psr\Cache\InvalidArgumentException
*/
Expand Down Expand Up @@ -260,6 +279,12 @@ public function testInvalidateTags()
*/
public function testTagsAreCleanedOnSave()
{
if (isset($this->skippedTests[__FUNCTION__])) {
$this->markTestSkipped($this->skippedTests[__FUNCTION__]);

return;
}

$pool = $this->cache;
$i = $pool->getItem('key')->set('value');
$pool->save($i->setTags(['foo']));
Expand Down

0 comments on commit 0aedb90

Please sign in to comment.