1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL v3 or later
*/
namespace Tests\Matomo\Cache\Backend;
use Matomo\Cache\Backend\DefaultTimeoutDecorated;
use Matomo\Cache\Backend\NullCache;
use PHPUnit\Framework\TestCase;
/**
* @covers \Matomo\Cache\Backend\DefaultTimeoutDecorated
*/
class DefaultTimeoutTest extends TestCase
{
/**
* @var DefaultTimeoutDecorated
*/
private $cache;
/**
* @var NullCache
*/
private $backendMock;
private $defaultTTl = 555;
public function setUp()
{
$this->backendMock = $this->getMockBuilder(NullCache::class)->getMock();
$opts = ['defaultTimeout'=>$this->defaultTTl];
$this->cache = new DefaultTimeoutDecorated($this->backendMock, $opts);
}
public function test_doSave_shouldCallDecoratedWithDefaultTTL()
{
$this->backendMock
->expects($this->once())
->method('doSave')
->with( $this->anything(),
$this->anything(),
$this->defaultTTl);
$this->cache->doSave('randomid', 'anyvalue');
}
}
|