Skip to content

Commit

Permalink
Adds a regression tests for pull request GH#17 (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
frqnck committed Oct 28, 2016
1 parent f64a8b5 commit f883c1d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,26 @@ public function testDeleteWithNoTag()
$this->assertTrue($this->cache->save('data', 'id', array('tag')));
$this->assertTrue($this->cache->delete('id'));
}

/**
* Regression test for pull request GH#17
*
* @link https://github.com/frqnck/apix-cache/pull/17/files
* "File and Directory Adapters @clean returns when fails to find a
* key within a tag"
* @see FilesTest\testPullRequest17()
* @group pr
*/
public function testPullRequest17()
{
$this->cache->save('data1', 'id1', array('tag1', 'tag2'));

$this->assertNotNull($this->cache->loadTag('tag2'));
$this->assertTrue($this->cache->clean(array('non-existant', 'tag2')));
$this->assertNull($this->cache->loadTag('tag2'));

// for good measure.
$this->assertFalse($this->cache->clean(array('tag2')));
}

}
22 changes: 22 additions & 0 deletions tests/FilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,26 @@ public function testCorrupted()
file_put_contents($this->cache->getOption('directory').DIRECTORY_SEPARATOR.$encoded, PHP_EOL);
$this->assertNull($this->cache->loadKey('id'));
}

/**
* Regression test for pull request GH#17
*
* @link https://github.com/frqnck/apix-cache/pull/17/files
* "File and Directory Adapters @clean returns when fails to find a
* key within a tag"
* @see DirectoryTest\testPullRequest17()
* @group pr
*/
public function testPullRequest17()
{
$this->cache->save('data1', 'id1', array('tag1', 'tag2'));

$this->assertNotNull($this->cache->loadTag('tag2'));
$this->assertTrue($this->cache->clean(array('non-existant', 'tag2')));
$this->assertNull($this->cache->loadTag('tag2'));

// for good measure.
$this->assertFalse($this->cache->clean(array('tag2')));
}

}

0 comments on commit f883c1d

Please sign in to comment.