Completed
Push — 6.13 ( 9c335d...8c8805 )
by
unknown
16:33
created

LocalPurgeClientTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPurge() 0 15 1
A testPurgeAll() 0 10 1
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);
0 ignored issues
show
Deprecated Code introduced by
The class eZ\Publish\Core\MVC\Symf...e\Http\LocalPurgeClient has been deprecated with message: since 6.8. Use LocalPurgeClient from the platform-http-cache package.

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.

Loading history...
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);
0 ignored issues
show
Deprecated Code introduced by
The class eZ\Publish\Core\MVC\Symf...e\Http\LocalPurgeClient has been deprecated with message: since 6.8. Use LocalPurgeClient from the platform-http-cache package.

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.

Loading history...
54
        $purgeClient->purgeAll();
55
    }
56
}
57