1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the LocalPurgeClientTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace Symfony\Component\HttpFoundation; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Avoid test failure caused by time passing between generating expected & actual object. |
13
|
|
|
* |
14
|
|
|
* @return int |
15
|
|
|
*/ |
16
|
|
|
function time() |
17
|
|
|
{ |
18
|
|
|
return 1417624982; |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
namespace eZ\Publish\Core\MVC\Symfony\Cache\Tests\Http; |
22
|
|
|
|
23
|
|
|
use eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient; |
24
|
|
|
use eZ\Publish\Core\MVC\Symfony\Cache\Http\ContentPurger; |
25
|
|
|
use PHPUnit\Framework\TestCase; |
26
|
|
|
use Symfony\Component\HttpFoundation\Request; |
27
|
|
|
|
28
|
|
|
class LocalPurgeClientTest extends TestCase |
29
|
|
|
{ |
30
|
|
|
public function testPurge() |
31
|
|
|
{ |
32
|
|
|
$locationIds = [123, 456, 789]; |
33
|
|
|
$expectedBanRequest = Request::create('http://localhost', 'BAN'); |
34
|
|
|
$expectedBanRequest->headers->set('X-Location-Id', '(' . implode('|', $locationIds) . ')'); |
35
|
|
|
|
36
|
|
|
$cacheStore = $this->createMock(ContentPurger::class); |
37
|
|
|
$cacheStore |
38
|
|
|
->expects($this->once()) |
39
|
|
|
->method('purgeByRequest') |
40
|
|
|
->with($this->equalTo($expectedBanRequest)); |
41
|
|
|
|
42
|
|
|
$purgeClient = new LocalPurgeClient($cacheStore); |
|
|
|
|
43
|
|
|
$purgeClient->purge($locationIds); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function testPurgeAll() |
47
|
|
|
{ |
48
|
|
|
$cacheStore = $this->createMock(ContentPurger::class); |
49
|
|
|
$cacheStore |
50
|
|
|
->expects($this->once()) |
51
|
|
|
->method('purgeAllContent'); |
52
|
|
|
|
53
|
|
|
$purgeClient = new LocalPurgeClient($cacheStore); |
|
|
|
|
54
|
|
|
$purgeClient->purgeAll(); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.