raigu / psr16-simple-cache-testdoubles
PSR-16 简单缓存测试双
v0.1.0
2021-08-29 15:57 UTC
README
psr16-simple-cache-testdoubles
PSR-16 简单缓存测试双
依赖关系
安装
$ composer require --dev raigu/psr16-simple-cache-testdoubles
使用
内存存根
在内存中缓存。
$sut = new \Raigu\TestDouble\Psr16\InMemoryCache; $sut->set('1', 'a value'); assert($sut->has('1')) assert($sut->get('1') === 'a value')
断开连接的缓存存根
表现像一个网络缓存,存在连接问题并且断开连接。
$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);)
测试
$ composer test
$ composer specification
$ composer coverage