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
|
|
|
* @version //autogentag// |
10
|
|
|
*/ |
11
|
|
|
namespace Symfony\Component\HttpFoundation; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Avoid test failure caused by time passing between generating expected & actual object. |
15
|
|
|
* |
16
|
|
|
* @return int |
17
|
|
|
*/ |
18
|
|
|
function time() |
19
|
|
|
{ |
20
|
|
|
return 1417624982; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
namespace eZ\Publish\Core\MVC\Symfony\Cache\Tests; |
24
|
|
|
|
25
|
|
|
use eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient; |
26
|
|
|
use PHPUnit_Framework_TestCase; |
27
|
|
|
use Symfony\Component\HttpFoundation\Request; |
28
|
|
|
|
29
|
|
|
class LocalPurgeClientTest extends PHPUnit_Framework_TestCase |
30
|
|
|
{ |
31
|
|
|
public function testPurge() |
32
|
|
|
{ |
33
|
|
|
$locationIds = array(123, 456, 789); |
34
|
|
|
$expectedBanRequest = Request::create('http://localhost', 'BAN'); |
35
|
|
|
$expectedBanRequest->headers->set('X-Location-Id', '(' . implode('|', $locationIds) . ')'); |
36
|
|
|
|
37
|
|
|
$cacheStore = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\Cache\\Http\\ContentPurger'); |
38
|
|
|
$cacheStore |
39
|
|
|
->expects($this->once()) |
40
|
|
|
->method('purgeByRequest') |
41
|
|
|
->with($this->equalTo($expectedBanRequest)); |
42
|
|
|
|
43
|
|
|
$purgeClient = new LocalPurgeClient($cacheStore); |
44
|
|
|
$purgeClient->purge($locationIds); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testPurgeAll() |
48
|
|
|
{ |
49
|
|
|
$cacheStore = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\Cache\\Http\\ContentPurger'); |
50
|
|
|
$cacheStore |
51
|
|
|
->expects($this->once()) |
52
|
|
|
->method('purgeAllContent'); |
53
|
|
|
|
54
|
|
|
$purgeClient = new LocalPurgeClient($cacheStore); |
55
|
|
|
$purgeClient->purgeAll(); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|