blob: c56964d54ec2de59660a296c970d2c741faf0f66 (
plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<?php
/**
* Piwik - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Tests\Unit;
use Piwik\Cache;
/**
* @group Cache
*/
class CacheTest extends \PHPUnit_Framework_TestCase
{
public function test_getLazyCache_shouldCreateAnInstanceOfLazy()
{
$cache = Cache::getLazyCache();
$this->assertTrue($cache instanceof Cache\Lazy);
}
public function test_getLazyCache_shouldAlwaysReturnTheSameInstance()
{
$cache1 = Cache::getLazyCache();
$cache2 = Cache::getLazyCache();
$this->assertSame($cache1, $cache2);
}
public function test_getEagerCache_shouldCreateAnInstanceOfEager()
{
$cache = Cache::getEagerCache();
$this->assertTrue($cache instanceof Cache\Eager);
}
public function test_getEagerCache_shouldAlwaysReturnTheSameInstance()
{
$cache1 = Cache::getEagerCache();
$cache2 = Cache::getEagerCache();
$this->assertSame($cache1, $cache2);
}
public function test_getTransientCache_shouldCreateAnInstanceOfTransient()
{
$cache = Cache::getTransientCache();
$this->assertTrue($cache instanceof Cache\Transient);
}
public function test_getTransientCache_shouldAlwaysReturnTheSameInstance()
{
$cache1 = Cache::getTransientCache();
$cache2 = Cache::getTransientCache();
$this->assertSame($cache1, $cache2);
}
public function test_flushAll_shouldActuallyFlushAllCaches()
{
$cache1 = Cache::getTransientCache();
$cache2 = Cache::getLazyCache();
$cache3 = Cache::getEagerCache();
$cache1->save('test1', 'content');
$cache2->save('test2', 'content');
$cache3->save('test3', 'content');
$this->assertTrue($cache1->contains('test1'));
$this->assertTrue($cache2->contains('test2'));
$this->assertTrue($cache3->contains('test3'));
Cache::flushAll();
$this->assertFalse($cache1->contains('test1'));
$this->assertFalse($cache2->contains('test2'));
$this->assertFalse($cache3->contains('test3'));
}
}
|