1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the FOSHttpCache package. |
5
|
|
|
* |
6
|
|
|
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace FOS\HttpCache\Test; |
13
|
|
|
|
14
|
|
|
use FOS\HttpCache\SymfonyCache\CacheEvent; |
15
|
|
|
use FOS\HttpCache\SymfonyCache\CacheInvalidation; |
16
|
|
|
use FOS\HttpCache\SymfonyCache\EventDispatchingHttpCache; |
17
|
|
|
use FOS\HttpCache\SymfonyCache\Events; |
18
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
19
|
|
|
use Symfony\Component\HttpFoundation\Request; |
20
|
|
|
use Symfony\Component\HttpFoundation\Response; |
21
|
|
|
use Symfony\Component\HttpKernel\HttpCache\HttpCache; |
22
|
|
|
use Symfony\Component\HttpKernel\HttpCache\StoreInterface; |
23
|
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* This test ensures that the EventDispatchingHttpCache trait is correctly used. |
27
|
|
|
*/ |
28
|
|
|
abstract class EventDispatchingHttpCacheTestCase extends \PHPUnit_Framework_TestCase |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Specify the CacheInvalidationInterface HttpCache class to test. |
32
|
|
|
* |
33
|
|
|
* @return string Fully qualified class name of the AppCache |
34
|
|
|
*/ |
35
|
|
|
abstract protected function getCacheClass(); |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Create a partial mock of the HttpCache to only test some methods. |
39
|
|
|
* |
40
|
|
|
* @param array $mockedMethods List of methods to mock |
41
|
|
|
* |
42
|
|
|
* @return CacheInvalidation|EventDispatchingHttpCache|\PHPUnit_Framework_MockObject_MockObject |
43
|
|
|
*/ |
44
|
9 |
|
protected function getHttpCachePartialMock(array $mockedMethods = null) |
45
|
|
|
{ |
46
|
|
|
$mock = $this |
47
|
9 |
|
->getMockBuilder($this->getCacheClass()) |
48
|
9 |
|
->setMethods($mockedMethods) |
49
|
9 |
|
->disableOriginalConstructor() |
50
|
9 |
|
->getMock() |
51
|
|
|
; |
52
|
|
|
|
53
|
9 |
|
$this->assertInstanceOf(CacheInvalidation::class, $mock); |
54
|
|
|
|
55
|
|
|
// Force setting options property since we can't use original constructor. |
56
|
|
|
$options = [ |
57
|
9 |
|
'debug' => false, |
58
|
|
|
'default_ttl' => 0, |
59
|
|
|
'private_headers' => ['Authorization', 'Cookie'], |
60
|
|
|
'allow_reload' => false, |
61
|
|
|
'allow_revalidate' => false, |
62
|
|
|
'stale_while_revalidate' => 2, |
63
|
|
|
'stale_if_error' => 60, |
64
|
|
|
]; |
65
|
|
|
|
66
|
9 |
|
$refHttpCache = new \ReflectionClass(HttpCache::class); |
67
|
|
|
// Workaround for Symfony 2 where $options property is not defined. |
68
|
9 |
|
if (!$refHttpCache->hasProperty('options')) { |
69
|
|
|
$mock->options = $options; |
70
|
|
|
} else { |
71
|
9 |
|
$refOptions = $refHttpCache->getProperty('options'); |
72
|
9 |
|
$refOptions->setAccessible(true); |
73
|
9 |
|
$refOptions->setValue($mock, $options); |
74
|
|
|
} |
75
|
|
|
|
76
|
9 |
|
return $mock; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Set the store property on a HttpCache to a StoreInterface expecting one write with request and response. |
81
|
|
|
* |
82
|
|
|
* @param CacheInvalidation $httpCache |
83
|
|
|
* @param Request $request |
84
|
|
|
* @param Response $response |
85
|
|
|
*/ |
86
|
2 |
|
protected function setStoreMock(CacheInvalidation $httpCache, Request $request, Response $response) |
87
|
|
|
{ |
88
|
2 |
|
$store = $this->getMock(StoreInterface::class); |
|
|
|
|
89
|
|
|
$store |
90
|
2 |
|
->expects($this->once()) |
91
|
2 |
|
->method('write') |
92
|
2 |
|
->with($request, $response) |
93
|
|
|
; |
94
|
2 |
|
$refHttpCache = new \ReflectionClass(HttpCache::class); |
95
|
2 |
|
$refStore = $refHttpCache->getProperty('store'); |
96
|
2 |
|
$refStore->setAccessible(true); |
97
|
2 |
|
$refStore->setValue($httpCache, $store); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Assert that preHandle and postHandle are called. |
102
|
|
|
*/ |
103
|
1 |
|
public function testHandleCalled() |
104
|
|
|
{ |
105
|
1 |
|
$catch = true; |
106
|
1 |
|
$request = Request::create('/foo', 'GET'); |
107
|
1 |
|
$response = new Response(); |
108
|
|
|
|
109
|
1 |
|
$httpCache = $this->getHttpCachePartialMock(['lookup']); |
110
|
1 |
|
$testListener = new TestListener($this, $httpCache, $request); |
|
|
|
|
111
|
1 |
|
$httpCache->addSubscriber($testListener); |
|
|
|
|
112
|
|
|
$httpCache |
|
|
|
|
113
|
1 |
|
->expects($this->any()) |
114
|
1 |
|
->method('lookup') |
115
|
1 |
|
->with($request) |
116
|
1 |
|
->will($this->returnValue($response)) |
117
|
|
|
; |
118
|
|
|
|
119
|
1 |
|
$this->assertSame($response, $httpCache->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch)); |
|
|
|
|
120
|
1 |
|
$this->assertEquals(1, $testListener->preHandleCalls); |
121
|
1 |
|
$this->assertEquals(1, $testListener->postHandleCalls); |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* Assert that when preHandle returns a response, that response is used and the normal kernel flow stopped. |
126
|
|
|
* |
127
|
|
|
* @depends testHandleCalled |
128
|
|
|
*/ |
129
|
1 |
|
public function testPreHandleReturnEarly() |
130
|
|
|
{ |
131
|
1 |
|
$catch = true; |
132
|
1 |
|
$request = Request::create('/foo', 'GET'); |
133
|
1 |
|
$response = new Response(); |
134
|
|
|
|
135
|
1 |
|
$httpCache = $this->getHttpCachePartialMock(['lookup']); |
136
|
1 |
|
$testListener = new TestListener($this, $httpCache, $request); |
|
|
|
|
137
|
1 |
|
$testListener->preHandleResponse = $response; |
138
|
1 |
|
$httpCache->addSubscriber($testListener); |
|
|
|
|
139
|
|
|
$httpCache |
|
|
|
|
140
|
1 |
|
->expects($this->never()) |
141
|
1 |
|
->method('lookup') |
142
|
|
|
; |
143
|
|
|
|
144
|
1 |
|
$this->assertSame($response, $httpCache->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch)); |
|
|
|
|
145
|
1 |
|
$this->assertEquals(1, $testListener->preHandleCalls); |
146
|
1 |
|
$this->assertEquals(1, $testListener->postHandleCalls); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Assert that postHandle can update the response. |
151
|
|
|
* |
152
|
|
|
* @depends testHandleCalled |
153
|
|
|
*/ |
154
|
1 |
|
public function testPostHandleReturn() |
155
|
|
|
{ |
156
|
1 |
|
$catch = true; |
157
|
1 |
|
$request = Request::create('/foo', 'GET'); |
158
|
1 |
|
$regularResponse = new Response(); |
159
|
1 |
|
$postResponse = new Response(); |
160
|
|
|
|
161
|
1 |
|
$httpCache = $this->getHttpCachePartialMock(['lookup']); |
162
|
1 |
|
$testListener = new TestListener($this, $httpCache, $request); |
|
|
|
|
163
|
1 |
|
$testListener->postHandleResponse = $postResponse; |
164
|
1 |
|
$httpCache->addSubscriber($testListener); |
|
|
|
|
165
|
|
|
$httpCache |
|
|
|
|
166
|
1 |
|
->expects($this->any()) |
167
|
1 |
|
->method('lookup') |
168
|
1 |
|
->with($request) |
169
|
1 |
|
->will($this->returnValue($regularResponse)) |
170
|
|
|
; |
171
|
|
|
|
172
|
1 |
|
$this->assertSame($postResponse, $httpCache->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch)); |
|
|
|
|
173
|
1 |
|
$this->assertEquals(1, $testListener->preHandleCalls); |
174
|
1 |
|
$this->assertEquals(1, $testListener->postHandleCalls); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
/** |
178
|
|
|
* Assert that postHandle is called and the response can be updated even when preHandle returned a response. |
179
|
|
|
* |
180
|
|
|
* @depends testHandleCalled |
181
|
|
|
*/ |
182
|
1 |
|
public function testPostHandleAfterPreHandle() |
183
|
|
|
{ |
184
|
1 |
|
$catch = true; |
185
|
1 |
|
$request = Request::create('/foo', 'GET'); |
186
|
1 |
|
$preResponse = new Response(); |
187
|
1 |
|
$postResponse = new Response(); |
188
|
|
|
|
189
|
1 |
|
$httpCache = $this->getHttpCachePartialMock(['lookup']); |
190
|
1 |
|
$testListener = new TestListener($this, $httpCache, $request); |
|
|
|
|
191
|
1 |
|
$testListener->preHandleResponse = $preResponse; |
192
|
1 |
|
$testListener->postHandleResponse = $postResponse; |
193
|
1 |
|
$httpCache->addSubscriber($testListener); |
|
|
|
|
194
|
|
|
$httpCache |
|
|
|
|
195
|
1 |
|
->expects($this->never()) |
196
|
1 |
|
->method('lookup') |
197
|
|
|
; |
198
|
|
|
|
199
|
1 |
|
$this->assertSame($postResponse, $httpCache->handle($request, HttpKernelInterface::MASTER_REQUEST, $catch)); |
|
|
|
|
200
|
1 |
|
$this->assertEquals(1, $testListener->preHandleCalls); |
201
|
1 |
|
$this->assertEquals(1, $testListener->postHandleCalls); |
202
|
|
|
} |
203
|
|
|
|
204
|
|
|
/** |
205
|
|
|
* Assert that preStore is called. |
206
|
|
|
*/ |
207
|
1 |
|
public function testPreStoreCalled() |
208
|
|
|
{ |
209
|
1 |
|
$request = Request::create('/foo', 'GET'); |
210
|
1 |
|
$response = new Response(); |
211
|
|
|
|
212
|
1 |
|
$httpCache = $this->getHttpCachePartialMock(); |
213
|
1 |
|
$testListener = new TestListener($this, $httpCache, $request); |
|
|
|
|
214
|
1 |
|
$httpCache->addSubscriber($testListener); |
|
|
|
|
215
|
|
|
|
216
|
1 |
|
$this->setStoreMock($httpCache, $request, $response); |
|
|
|
|
217
|
|
|
|
218
|
1 |
|
$refHttpCache = new \ReflectionObject($httpCache); |
219
|
1 |
|
$method = $refHttpCache->getMethod('store'); |
220
|
1 |
|
$method->setAccessible(true); |
221
|
1 |
|
$method->invokeArgs($httpCache, [$request, $response]); |
222
|
1 |
|
$this->assertEquals(1, $testListener->preStoreCalls); |
223
|
|
|
} |
224
|
|
|
|
225
|
|
|
/** |
226
|
|
|
* Assert that preStore response is used when provided. |
227
|
|
|
*/ |
228
|
1 |
|
public function testPreStoreResponse() |
229
|
|
|
{ |
230
|
1 |
|
$request = Request::create('/foo', 'GET'); |
231
|
1 |
|
$regularResponse = new Response(); |
232
|
1 |
|
$preStoreResponse = new Response(); |
233
|
|
|
|
234
|
1 |
|
$httpCache = $this->getHttpCachePartialMock(); |
235
|
1 |
|
$testListener = new TestListener($this, $httpCache, $request); |
|
|
|
|
236
|
1 |
|
$testListener->preStoreResponse = $preStoreResponse; |
237
|
1 |
|
$httpCache->addSubscriber($testListener); |
|
|
|
|
238
|
|
|
|
239
|
1 |
|
$this->setStoreMock($httpCache, $request, $preStoreResponse); |
|
|
|
|
240
|
|
|
|
241
|
1 |
|
$refHttpCache = new \ReflectionObject($httpCache); |
242
|
1 |
|
$method = $refHttpCache->getMethod('store'); |
243
|
1 |
|
$method->setAccessible(true); |
244
|
1 |
|
$method->invokeArgs($httpCache, [$request, $regularResponse]); |
245
|
1 |
|
$this->assertEquals(1, $testListener->preStoreCalls); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* Assert that preInvalidate is called. |
250
|
|
|
*/ |
251
|
1 |
|
public function testPreInvalidateCalled() |
252
|
|
|
{ |
253
|
1 |
|
$catch = true; |
254
|
1 |
|
$request = Request::create('/foo', 'GET'); |
255
|
1 |
|
$response = new Response('', 500); |
256
|
|
|
|
257
|
1 |
|
$httpCache = $this->getHttpCachePartialMock(['pass']); |
258
|
1 |
|
$testListener = new TestListener($this, $httpCache, $request); |
|
|
|
|
259
|
1 |
|
$httpCache->addSubscriber($testListener); |
|
|
|
|
260
|
|
|
$httpCache |
|
|
|
|
261
|
1 |
|
->expects($this->any()) |
262
|
1 |
|
->method('pass') |
263
|
1 |
|
->with($request) |
264
|
1 |
|
->will($this->returnValue($response)) |
265
|
|
|
; |
266
|
1 |
|
$refHttpCache = new \ReflectionObject($httpCache); |
267
|
1 |
|
$method = $refHttpCache->getMethod('invalidate'); |
268
|
1 |
|
$method->setAccessible(true); |
269
|
|
|
|
270
|
1 |
|
$this->assertSame($response, $method->invokeArgs($httpCache, [$request, $catch])); |
271
|
1 |
|
$this->assertEquals(1, $testListener->preInvalidateCalls); |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* Assert that when preInvalidate returns a response, that response is used and the normal kernel flow stopped. |
276
|
|
|
* |
277
|
|
|
* @depends testPreInvalidateCalled |
278
|
|
|
*/ |
279
|
1 |
|
public function testPreInvalidateReturnEarly() |
280
|
|
|
{ |
281
|
1 |
|
$catch = true; |
282
|
1 |
|
$request = Request::create('/foo', 'GET'); |
283
|
1 |
|
$response = new Response('', 400); |
284
|
|
|
|
285
|
1 |
|
$httpCache = $this->getHttpCachePartialMock(['pass']); |
286
|
1 |
|
$testListener = new TestListener($this, $httpCache, $request); |
|
|
|
|
287
|
1 |
|
$testListener->preInvalidateResponse = $response; |
288
|
1 |
|
$httpCache->addSubscriber($testListener); |
|
|
|
|
289
|
|
|
$httpCache |
|
|
|
|
290
|
1 |
|
->expects($this->never()) |
291
|
1 |
|
->method('pass') |
292
|
|
|
; |
293
|
1 |
|
$refHttpCache = new \ReflectionObject($httpCache); |
294
|
1 |
|
$method = $refHttpCache->getMethod('invalidate'); |
295
|
1 |
|
$method->setAccessible(true); |
296
|
|
|
|
297
|
1 |
|
$this->assertSame($response, $method->invokeArgs($httpCache, [$request, $catch])); |
298
|
1 |
|
$this->assertEquals(1, $testListener->preInvalidateCalls); |
299
|
|
|
} |
300
|
|
|
|
301
|
1 |
|
public function testAddListener() |
302
|
|
|
{ |
303
|
1 |
|
$request = Request::create('/foo', 'GET'); |
304
|
1 |
|
$response = new Response(); |
305
|
|
|
|
306
|
1 |
|
$httpCache = $this->getHttpCachePartialMock(['lookup']); |
307
|
1 |
|
$simpleListener = new SimpleListener($this, $httpCache, $request); |
|
|
|
|
308
|
1 |
|
$httpCache->addListener(Events::PRE_HANDLE, [$simpleListener, 'callback']); |
|
|
|
|
309
|
|
|
|
310
|
|
|
$httpCache |
|
|
|
|
311
|
1 |
|
->expects($this->any()) |
312
|
1 |
|
->method('lookup') |
313
|
1 |
|
->with($request) |
314
|
1 |
|
->will($this->returnValue($response)) |
315
|
|
|
; |
316
|
|
|
|
317
|
1 |
|
$this->assertSame($response, $httpCache->handle($request, HttpKernelInterface::MASTER_REQUEST)); |
|
|
|
|
318
|
1 |
|
$this->assertEquals(1, $simpleListener->calls); |
319
|
|
|
} |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
class TestListener implements EventSubscriberInterface |
|
|
|
|
323
|
|
|
{ |
324
|
|
|
/** |
325
|
|
|
* @var int Count how many times preHandle has been called |
326
|
|
|
*/ |
327
|
|
|
public $preHandleCalls = 0; |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* @var int Count how many times postHandle has been called |
331
|
|
|
*/ |
332
|
|
|
public $postHandleCalls = 0; |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @var int Count how many times preStore has been called |
336
|
|
|
*/ |
337
|
|
|
public $preStoreCalls = 0; |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @var int Count how many times preInvalidate has been called |
341
|
|
|
*/ |
342
|
|
|
public $preInvalidateCalls = 0; |
343
|
|
|
|
344
|
|
|
/** |
345
|
|
|
* @var Response A response to set during the preHandle |
346
|
|
|
*/ |
347
|
|
|
public $preHandleResponse; |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* @var Response A response to set during the postHandle |
351
|
|
|
*/ |
352
|
|
|
public $postHandleResponse; |
353
|
|
|
|
354
|
|
|
/** |
355
|
|
|
* @var Response A response to set during the preStore |
356
|
|
|
*/ |
357
|
|
|
public $preStoreResponse; |
358
|
|
|
|
359
|
|
|
/** |
360
|
|
|
* @var Response A response to set during the preInvalidate |
361
|
|
|
*/ |
362
|
|
|
public $preInvalidateResponse; |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* @var EventDispatchingHttpCacheTestCase To do assertions |
366
|
|
|
*/ |
367
|
|
|
private $test; |
368
|
|
|
|
369
|
|
|
/** |
370
|
|
|
* @var CacheInvalidation The kernel to ensure the event carries the correct kernel |
371
|
|
|
*/ |
372
|
|
|
private $kernel; |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* @var Request The request to ensure the event carries the correct request |
376
|
|
|
*/ |
377
|
|
|
private $request; |
378
|
|
|
|
379
|
8 |
|
public function __construct( |
380
|
|
|
EventDispatchingHttpCacheTestCase $test, |
381
|
|
|
CacheInvalidation $kernel, |
382
|
|
|
Request $request |
|
|
|
|
383
|
|
|
) { |
384
|
8 |
|
$this->test = $test; |
385
|
8 |
|
$this->kernel = $kernel; |
386
|
8 |
|
$this->request = $request; |
387
|
|
|
} |
388
|
|
|
|
389
|
8 |
|
public static function getSubscribedEvents() |
390
|
|
|
{ |
391
|
|
|
return [ |
392
|
8 |
|
Events::PRE_HANDLE => 'preHandle', |
393
|
8 |
|
Events::POST_HANDLE => 'postHandle', |
394
|
8 |
|
Events::PRE_STORE => 'preStore', |
395
|
8 |
|
Events::PRE_INVALIDATE => 'preInvalidate', |
396
|
|
|
]; |
397
|
|
|
} |
398
|
|
|
|
399
|
4 |
View Code Duplication |
public function preHandle(CacheEvent $event) |
|
|
|
|
400
|
|
|
{ |
401
|
4 |
|
$this->test->assertSame($this->kernel, $event->getKernel()); |
402
|
4 |
|
$this->test->assertSame($this->request, $event->getRequest()); |
403
|
4 |
|
if ($this->preHandleResponse) { |
404
|
2 |
|
$event->setResponse($this->preHandleResponse); |
405
|
|
|
} |
406
|
4 |
|
++$this->preHandleCalls; |
407
|
|
|
} |
408
|
|
|
|
409
|
4 |
View Code Duplication |
public function postHandle(CacheEvent $event) |
|
|
|
|
410
|
|
|
{ |
411
|
4 |
|
$this->test->assertSame($this->kernel, $event->getKernel()); |
412
|
4 |
|
$this->test->assertSame($this->request, $event->getRequest()); |
413
|
4 |
|
if ($this->postHandleResponse) { |
414
|
2 |
|
$event->setResponse($this->postHandleResponse); |
415
|
|
|
} |
416
|
4 |
|
++$this->postHandleCalls; |
417
|
|
|
} |
418
|
|
|
|
419
|
2 |
View Code Duplication |
public function preStore(CacheEvent $event) |
|
|
|
|
420
|
|
|
{ |
421
|
2 |
|
$this->test->assertSame($this->kernel, $event->getKernel()); |
422
|
2 |
|
$this->test->assertSame($this->request, $event->getRequest()); |
423
|
2 |
|
if ($this->preStoreResponse) { |
424
|
1 |
|
$event->setResponse($this->preStoreResponse); |
425
|
|
|
} |
426
|
2 |
|
++$this->preStoreCalls; |
427
|
|
|
} |
428
|
|
|
|
429
|
2 |
View Code Duplication |
public function preInvalidate(CacheEvent $event) |
|
|
|
|
430
|
|
|
{ |
431
|
2 |
|
$this->test->assertSame($this->kernel, $event->getKernel()); |
432
|
2 |
|
$this->test->assertSame($this->request, $event->getRequest()); |
433
|
2 |
|
if ($this->preInvalidateResponse) { |
434
|
1 |
|
$event->setResponse($this->preInvalidateResponse); |
435
|
|
|
} |
436
|
2 |
|
++$this->preInvalidateCalls; |
437
|
|
|
} |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
class SimpleListener |
|
|
|
|
441
|
|
|
{ |
442
|
|
|
public $calls = 0; |
443
|
|
|
|
444
|
|
|
/** |
445
|
|
|
* @var EventDispatchingHttpCacheTestCase To do assertions |
446
|
|
|
*/ |
447
|
|
|
private $test; |
448
|
|
|
|
449
|
|
|
/** |
450
|
|
|
* @var CacheInvalidation The kernel to ensure the event carries the correct kernel |
451
|
|
|
*/ |
452
|
|
|
private $kernel; |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* @var Request The request to ensure the event carries the correct request |
456
|
|
|
*/ |
457
|
|
|
private $request; |
458
|
|
|
|
459
|
1 |
|
public function __construct( |
460
|
|
|
EventDispatchingHttpCacheTestCase $test, |
461
|
|
|
CacheInvalidation $kernel, |
462
|
|
|
Request $request |
|
|
|
|
463
|
|
|
) { |
464
|
1 |
|
$this->test = $test; |
465
|
1 |
|
$this->kernel = $kernel; |
466
|
1 |
|
$this->request = $request; |
467
|
|
|
} |
468
|
|
|
|
469
|
1 |
|
public function callback(CacheEvent $event) |
470
|
|
|
{ |
471
|
1 |
|
$this->test->assertSame($this->kernel, $event->getKernel()); |
472
|
1 |
|
$this->test->assertSame($this->request, $event->getRequest()); |
473
|
1 |
|
++$this->calls; |
474
|
|
|
} |
475
|
|
|
} |
476
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.