Skip to content

raigu/psr16-simple-cache-testdoubles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latest Stable Version Fallows SemVer build codecov License: MIT

psr16-simple-cache-testdoubles

Test Doubles for PSR-16 simple cache

Dependency

Install

$ composer require --dev raigu/psr16-simple-cache-testdoubles

Usage

In-memory stub

Caches in memory.

$sut = new \Raigu\TestDouble\Psr16\InMemoryCache;

$sut->set('1', 'a value');

assert($sut->has('1'))
assert($sut->get('1') === 'a value')

Disconnected cache stub

Behaves like a cache over network which has connection issues and is disconnected.

$sut = new \Raigu\TestDouble\Psr16\DisconnectedCacheStub;

assert($sut->set(1, 'value') === false);
assert($sut->has(1) === false);
assert($sut->get(1, 'default') === 'default');
assert($sut->getMultiple([1], 'default') === [1 => 'default']);
assert($sut->setMultiple([2 => 'value']) === false);
assert($sut->delete(1, 'value') === false);
assert($sut->deleteMultiple([1, 2]) === false);
assert($sut->clear() === false);)

Testing

$ composer test
$ composer specification 
$ composer coverage