-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
CacheClearSubscriberTest.php
50 lines (42 loc) · 1.37 KB
/
CacheClearSubscriberTest.php
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
<?php
declare(strict_types=1);
/*
* @copyright 2018 Mautic. All rights reserved
* @author Mautic
*
* @link https://mautic.org
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
namespace Mautic\CacheBundle\Tests\EventListener;
use Mautic\CacheBundle\Cache\Adapter\FilesystemTagAwareAdapter;
use Mautic\CacheBundle\EventListener\CacheClearSubscriber;
use Monolog\Logger;
use PHPUnit\Framework\MockObject\MockObject;
class CacheClearSubscriberTest extends \PHPUnit\Framework\TestCase
{
/**
* @var MockObject|FilesystemTagAwareAdapter
*/
private $adapter;
/**
* @var string
*/
private $random;
public function setUp(): void
{
parent::setUp();
$this->random = sha1((string) time());
$this->adapter = $this->getMockBuilder(FilesystemTagAwareAdapter::class)
->disableOriginalConstructor()
->onlyMethods(['clear', 'getCacheAdapter', 'commit'])
->getMock();
$this->adapter->method('clear')->willReturn($this->random);
$this->adapter->method('commit')->willReturn(null);
}
public function testClear(): void
{
$this->adapter->expects($this->once())->method('clear')->willReturn($this->random);
$subscriber = new CacheClearSubscriber($this->adapter, new Logger('test'));
$subscriber->clear('aaa');
}
}