Completed
Push — master ( 97e40f...89ec5c )
by André
40:26 queued 12:35
created

LocationHandlerTest::testSwap()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 96
Code Lines 76

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 76
nc 1
nop 0
dl 0
loc 96
rs 8.3859
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\CreateStruct;
13
use eZ\Publish\SPI\Persistence\Content\Location\UpdateStruct;
14
use eZ\Publish\SPI\Persistence\Content\Location\Handler as SPILocationHandler;
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 SPILocationHandler::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