|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2018 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Cache; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class FlowTest extends \PHPUnit\Framework\TestCase |
|
|
|
|
|
|
13
|
|
|
{ |
|
14
|
|
|
private $object; |
|
15
|
|
|
private $mock; |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
protected function setUp() |
|
19
|
|
|
{ |
|
20
|
|
|
if( interface_exists( 'Neos\Cache\Frontend\FrontendInterface' ) === false ) { |
|
21
|
|
|
$this->markTestSkipped( 'Class \\Neos\\Cache\\Frontend\\FrontendInterface not found' ); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
$this->mock = $this->getMockBuilder( 'Neos\Cache\Frontend\FrontendInterface' )->getMock(); |
|
25
|
|
|
$this->object = new \Aimeos\MW\Cache\Flow( [], $this->mock ); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
protected function tearDown() |
|
30
|
|
|
{ |
|
31
|
|
|
unset( $this->mock, $this->object ); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
public function testCleanup() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->mock->expects( $this->once() )->method( 'collectGarbage' ); |
|
38
|
|
|
$this->assertTrue( $this->object->cleanup() ); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
public function testClear() |
|
43
|
|
|
{ |
|
44
|
|
|
$this->mock->expects( $this->once() )->method( 'flush' ); |
|
45
|
|
|
$this->assertTrue( $this->object->clear() ); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
public function testClearWithSiteId() |
|
50
|
|
|
{ |
|
51
|
|
|
$object = new \Aimeos\MW\Cache\Flow( array( 'siteid' => 1 ), $this->mock ); |
|
52
|
|
|
|
|
53
|
|
|
$this->mock->expects( $this->once() )->method( 'flushByTag' )->with( $this->equalTo( '1-siteid' ) ); |
|
54
|
|
|
$this->assertTrue( $object->clear() ); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
public function testDelete() |
|
59
|
|
|
{ |
|
60
|
|
|
$this->mock->expects( $this->once() )->method( 'remove' )->with( $this->equalTo( 'key' ) ); |
|
61
|
|
|
$this->assertTrue( $this->object->delete( 'key' ) ); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
public function testDeleteWithSiteId() |
|
66
|
|
|
{ |
|
67
|
|
|
$object = new \Aimeos\MW\Cache\Flow( array( 'siteid' => 1 ), $this->mock ); |
|
68
|
|
|
|
|
69
|
|
|
$this->mock->expects( $this->once() )->method( 'remove' )->with( $this->equalTo( '1-key' ) ); |
|
70
|
|
|
$this->assertTrue( $object->delete( 'key' ) ); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
public function testDeleteMultiple() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->mock->expects( $this->exactly( 2 ) )->method( 'remove' )->with( $this->equalTo( 'key' ) ); |
|
77
|
|
|
$this->assertTrue( $this->object->deleteMultiple( array( 'key', 'key' ) ) ); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
|
|
81
|
|
|
public function testDeleteMultipleWithSiteId() |
|
82
|
|
|
{ |
|
83
|
|
|
$object = new \Aimeos\MW\Cache\Flow( array( 'siteid' => 1 ), $this->mock ); |
|
84
|
|
|
|
|
85
|
|
|
$this->mock->expects( $this->once() )->method( 'remove' )->with( $this->equalTo( '1-key' ) ); |
|
86
|
|
|
$this->assertTrue( $object->deleteMultiple( array( 'key' ) ) ); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
|
|
90
|
|
|
public function testDeleteByTags() |
|
91
|
|
|
{ |
|
92
|
|
|
$this->mock->expects( $this->exactly( 2 ) )->method( 'flushByTag' )->with( $this->equalTo( 'tag' ) ); |
|
93
|
|
|
$this->assertTrue( $this->object->deleteByTags( array( 'tag', 'tag' ) ) ); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
public function testDeleteByTagsWithSiteId() |
|
98
|
|
|
{ |
|
99
|
|
|
$object = new \Aimeos\MW\Cache\Flow( array( 'siteid' => 1 ), $this->mock ); |
|
100
|
|
|
|
|
101
|
|
|
$this->mock->expects( $this->once() )->method( 'flushByTag' )->with( $this->equalTo( '1-tag' ) ); |
|
102
|
|
|
$this->assertTrue( $object->deleteByTags( array( 'tag' ) ) ); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
|
|
106
|
|
|
public function testGet() |
|
107
|
|
|
{ |
|
108
|
|
|
$this->mock->expects( $this->once() )->method( 'get' ) |
|
109
|
|
|
->with( $this->equalTo( 'key' ) )->will( $this->returnValue( 'value' ) ); |
|
110
|
|
|
|
|
111
|
|
|
$this->assertEquals( 'value', $this->object->get( 'key', 'default' ) ); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
|
|
115
|
|
|
public function testGetDefault() |
|
116
|
|
|
{ |
|
117
|
|
|
$this->mock->expects( $this->once() )->method( 'get' ) |
|
118
|
|
|
->with( $this->equalTo( 'key' ) )->will( $this->returnValue( false ) ); |
|
119
|
|
|
|
|
120
|
|
|
$this->assertEquals( 'default', $this->object->get( 'key', 'default' ) ); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
|
|
124
|
|
|
public function testGetWithSiteId() |
|
125
|
|
|
{ |
|
126
|
|
|
$object = new \Aimeos\MW\Cache\Flow( array( 'siteid' => 1 ), $this->mock ); |
|
127
|
|
|
|
|
128
|
|
|
$this->mock->expects( $this->once() )->method( 'get' )->with( $this->equalTo( '1-key' ) ); |
|
129
|
|
|
$object->get( 'key', 'default' ); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
|
|
133
|
|
|
public function testGetMultiple() |
|
134
|
|
|
{ |
|
135
|
|
|
$this->mock->expects( $this->exactly( 2 ) )->method( 'get' ) |
|
136
|
|
|
->will( $this->returnValue( 'value' ) ); |
|
137
|
|
|
|
|
138
|
|
|
$expected = array( 'key1' => 'value', 'key2' => 'value' ); |
|
139
|
|
|
$this->assertEquals( $expected, $this->object->getMultiple( array( 'key1', 'key2' ) ) ); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
|
|
143
|
|
|
public function testGetMultipleWithSiteId() |
|
144
|
|
|
{ |
|
145
|
|
|
$object = new \Aimeos\MW\Cache\Flow( array( 'siteid' => 1 ), $this->mock ); |
|
146
|
|
|
|
|
147
|
|
|
$this->mock->expects( $this->once() )->method( 'get' )->with( $this->equalTo( '1-key' ) ); |
|
148
|
|
|
$object->getMultiple( array( 'key' ) ); |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
|
|
152
|
|
|
public function testHas() |
|
153
|
|
|
{ |
|
154
|
|
|
$this->mock->expects( $this->once() )->method( 'has' )->will( $this->returnValue( true ) ); |
|
155
|
|
|
$this->assertTrue( $this->object->has( 'key' ) ); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
|
|
159
|
|
|
public function testSet() |
|
160
|
|
|
{ |
|
161
|
|
|
$this->mock->expects( $this->once() )->method( 'set' ) |
|
162
|
|
|
->with( |
|
163
|
|
|
$this->equalTo( 'key' ), $this->equalTo( 'value' ), |
|
164
|
|
|
$this->equalTo( array( 'tag' ) ), $this->greaterThan( 0 ) |
|
165
|
|
|
); |
|
166
|
|
|
|
|
167
|
|
|
$this->assertTrue( $this->object->set( 'key', 'value', '2100-01-01 00:00:00', array( 'tag' ) ) ); |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
|
|
171
|
|
|
public function testSetWithSiteId() |
|
172
|
|
|
{ |
|
173
|
|
|
$object = new \Aimeos\MW\Cache\Flow( array( 'siteid' => 1 ), $this->mock ); |
|
174
|
|
|
|
|
175
|
|
|
$this->mock->expects( $this->once() )->method( 'set' ) |
|
176
|
|
|
->with( |
|
177
|
|
|
$this->equalTo( '1-key' ), $this->equalTo( 'value' ), |
|
178
|
|
|
$this->equalTo( array( '1-siteid', '1-tag' ) ), $this->equalTo( null ) |
|
179
|
|
|
); |
|
180
|
|
|
|
|
181
|
|
|
$this->assertTrue( $object->set( 'key', 'value', null, array( 'tag' ) ) ); |
|
182
|
|
|
} |
|
183
|
|
|
|
|
184
|
|
|
|
|
185
|
|
|
public function testSetMultiple() |
|
186
|
|
|
{ |
|
187
|
|
|
$this->mock->expects( $this->once() )->method( 'set' ) |
|
188
|
|
|
->with( |
|
189
|
|
|
$this->equalTo( 'key' ), $this->equalTo( 'value' ), |
|
190
|
|
|
$this->equalTo( array( 'tag' ) ), $this->greaterThan( 0 ) |
|
191
|
|
|
); |
|
192
|
|
|
|
|
193
|
|
|
$this->assertTrue( $this->object->setMultiple( ['key' => 'value'], '2100-01-01 00:00:00', ['tag'] ) ); |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
|
|
197
|
|
|
public function testSetMultipleWithSiteId() |
|
198
|
|
|
{ |
|
199
|
|
|
$object = new \Aimeos\MW\Cache\Flow( array( 'siteid' => 1 ), $this->mock ); |
|
200
|
|
|
|
|
201
|
|
|
$this->mock->expects( $this->once() )->method( 'set' ) |
|
202
|
|
|
->with( |
|
203
|
|
|
$this->equalTo( '1-key' ), $this->equalTo( 'value' ), |
|
204
|
|
|
$this->equalTo( array( '1-siteid', '1-tag' ) ), $this->equalTo( null ) |
|
205
|
|
|
); |
|
206
|
|
|
|
|
207
|
|
|
$this->assertTrue( $object->setMultiple( ['key' => 'value'], null, ['tag'] ) ); |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
} |
|
211
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths