raigu / psr16-simple-cache-testdoubles
Test Doubles for PSR-16 simple cache
v0.1.0
2021-08-29 15:57 UTC
README
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