1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2014 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2025 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Base\Cache; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class Typo3Test extends \PHPUnit\Framework\TestCase |
14
|
|
|
{ |
15
|
|
|
private $object; |
16
|
|
|
private $mock; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected function setUp() : void |
20
|
|
|
{ |
21
|
|
|
if( interface_exists( 'TYPO3\CMS\Core\Cache\Frontend\FrontendInterface' ) === false ) { |
22
|
|
|
$this->markTestSkipped( 'Class \\TYPO3\\CMS\\Core\\Cache\\Frontend\\FrontendInterface not found' ); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
$this->mock = $this->getMockBuilder( 'TYPO3\CMS\Core\Cache\Frontend\FrontendInterface' )->getMock(); |
26
|
|
|
$this->object = new \Aimeos\Base\Cache\Typo3( $this->mock ); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
protected function tearDown() : void |
31
|
|
|
{ |
32
|
|
|
unset( $this->mock, $this->object ); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
public function testClear() |
37
|
|
|
{ |
38
|
|
|
$this->mock->expects( $this->once() )->method( 'flush' ); |
39
|
|
|
$this->assertTrue( $this->object->clear() ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testClearWithSiteId() |
44
|
|
|
{ |
45
|
|
|
$object = new \Aimeos\Base\Cache\Typo3( $this->mock ); |
46
|
|
|
|
47
|
|
|
$this->mock->expects( $this->once() )->method( 'flush' ); |
48
|
|
|
$this->assertTrue( $object->clear() ); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
public function testDelete() |
53
|
|
|
{ |
54
|
|
|
$this->mock->expects( $this->once() )->method( 'remove' )->with( $this->equalTo( 'key' ) ); |
55
|
|
|
$this->assertTrue( $this->object->delete( 'key' ) ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
public function testDeleteMultiple() |
60
|
|
|
{ |
61
|
|
|
$this->mock->expects( $this->exactly( 2 ) )->method( 'remove' )->with( $this->equalTo( 'key' ) ); |
62
|
|
|
$this->assertTrue( $this->object->deleteMultiple( array( 'key', 'key' ) ) ); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
public function testDeleteByTags() |
67
|
|
|
{ |
68
|
|
|
$this->mock->expects( $this->exactly( 2 ) )->method( 'flushByTag' )->with( $this->equalTo( 'tag' ) ); |
69
|
|
|
$this->assertTrue( $this->object->deleteByTags( array( 'tag', 'tag' ) ) ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
public function testGet() |
74
|
|
|
{ |
75
|
|
|
$this->mock->expects( $this->once() )->method( 'get' ) |
76
|
|
|
->with( $this->equalTo( 'key' ) )->willReturn( 'value' ); |
77
|
|
|
|
78
|
|
|
$this->assertEquals( 'value', $this->object->get( 'key', 'default' ) ); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
public function testGetMultiple() |
83
|
|
|
{ |
84
|
|
|
$this->mock->expects( $this->exactly( 2 ) )->method( 'get' ) |
85
|
|
|
->willReturn( 'value' ); |
86
|
|
|
|
87
|
|
|
$expected = array( 'key1' => 'value', 'key2' => 'value' ); |
88
|
|
|
$this->assertEquals( $expected, $this->object->getMultiple( array( 'key1', 'key2' ) ) ); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
public function testHas() |
93
|
|
|
{ |
94
|
|
|
$this->mock->expects( $this->once() )->method( 'has' )->willReturn( true ); |
95
|
|
|
$this->assertTrue( $this->object->has( 'key' ) ); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
public function testSet() |
100
|
|
|
{ |
101
|
|
|
$this->mock->expects( $this->once() )->method( 'set' ) |
102
|
|
|
->with( |
103
|
|
|
$this->equalTo( 'key' ), $this->equalTo( 'value' ), |
104
|
|
|
$this->equalTo( ['tag'] ), $this->greaterThan( 0 ) |
105
|
|
|
); |
106
|
|
|
|
107
|
|
|
$this->assertTrue( $this->object->set( 'key', 'value', '2100-01-01 00:00:00', ['tag'] ) ); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
|
111
|
|
|
public function testSetMultiple() |
112
|
|
|
{ |
113
|
|
|
$this->mock->expects( $this->once() )->method( 'set' ) |
114
|
|
|
->with( |
115
|
|
|
$this->equalTo( 'key' ), $this->equalTo( 'value' ), |
116
|
|
|
$this->equalTo( ['tag'] ), $this->greaterThan( 0 ) |
117
|
|
|
); |
118
|
|
|
|
119
|
|
|
$expires = '2100-01-01 00:00:00'; |
120
|
|
|
$this->assertTrue( $this->object->setMultiple( ['key' => 'value'], $expires, ['tag'] ) ); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|