Completed
Push — 6.1 ( a2a867...11a8bc )
by
unknown
25:26
created

LocalPurgeClientTest.php ➔ time()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
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