Completed
Push — sf_cache ( 18214b...3b3329 )
by André
19:05
created

LocationHandlerTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 46
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getHandlerMethodName() 0 4 1
A getHandlerClassName() 0 4 1
A providerForUnCachedMethods() 0 18 1
A providerForCachedLoadMethods() 0 14 1
1
<?php
2
3
/**
4
 * File contains Test 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 eZ\Publish\Core\Persistence\Cache\Tests;
10
11
use eZ\Publish\SPI\Persistence\Content\Location;
12
use eZ\Publish\SPI\Persistence\Content\Location\Handler;
13
use eZ\Publish\SPI\Persistence\Content\Location\CreateStruct;
14
use eZ\Publish\SPI\Persistence\Content\Location\UpdateStruct;
15
16
/**
17
 * Test case for Persistence\Cache\LocationHandler.
18
 */
19
class LocationHandlerTest extends AbstractCacheHandlerTest
20
{
21
    public function getHandlerMethodName(): string
22
    {
23
        return 'locationHandler';
24
    }
25
26
    public function getHandlerClassName(): string
27
    {
28
        return Handler::class;
29
    }
30
31
    public function providerForUnCachedMethods(): array
32
    {
33
        // string $method, array $arguments, array? $tags, string? $key
34
        return [
35
            ['copySubtree', [12, 45]],
36
            ['move', [12, 45], ['location-path-12']],
37
            ['markSubtreeModified', [12]],
38
            ['hide', [12], ['location-path-data-12']],
39
            ['unHide', [12], ['location-path-data-12']],
40
            ['swap', [12, 45], ['location-data-12', 'location-data-45']],
41
            ['update', [new UpdateStruct(), 12], ['location-data-12']],
42
            ['create', [new CreateStruct(['contentId' => 4, 'mainLocationId' => true])], ['content-4', 'role-assignment-group-list-4']],
43
            ['create', [new CreateStruct(['contentId' => 4, 'mainLocationId' => false])], ['content-4', 'role-assignment-group-list-4']],
44
            ['removeSubtree', [12], ['location-path-12']],
45
            ['setSectionForSubtree', [12, 2], ['location-path-12']],
46
            ['changeMainLocation', [4, 12], ['content-4']],
47
        ];
48
    }
49
50
    public function providerForCachedLoadMethods(): array
51
    {
52
        $location = new Location(['id' => 12]);
53
54
        // string $method, array $arguments, string $key, mixed? $data
55
        return [
56
            ['load', [12], 'ez-location-12', $location],
57
            ['loadSubtreeIds', [12], 'ez-location-subtree-12', [33, 44]],
58
            ['loadLocationsByContent', [4, 12], 'ez-content-locations-4-root-12', [$location]],
59
            ['loadLocationsByContent', [4], 'ez-content-locations-4', [$location]],
60
            ['loadParentLocationsForDraftContent', [4], 'ez-content-locations-4-parentForDraft', [$location]],
61
            ['loadByRemoteId', ['34fe5y4'], 'ez-location-34fe5y4-by-remoteid', $location],
62
        ];
63
    }
64
}
65