PHP code example of raigu / psr16-simple-cache-testdoubles

1. Go to this page and download the library: Download raigu/psr16-simple-cache-testdoubles library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

raigu / psr16-simple-cache-testdoubles example snippets


$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);)