Completed
Push — master ( 4e0ac6...0fdc9b )
by Łukasz
25:36
created

LocationServiceTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAPIServiceClassName() 0 4 1
A getSiteAccessAwareServiceClassName() 0 4 1
A providerForPassTroughMethods() 0 32 1
A providerForLanguagesLookupMethods() 0 24 1
1
<?php
2
3
namespace eZ\Publish\Core\Repository\SiteAccessAware\Tests;
4
5
use eZ\Publish\API\Repository\LocationService as APIService;
6
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
7
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
8
use eZ\Publish\API\Repository\Values\Content\LocationUpdateStruct;
9
use eZ\Publish\Core\Repository\SiteAccessAware\LocationService;
10
use eZ\Publish\Core\Repository\Values\Content\Location;
11
use eZ\Publish\Core\Repository\Values\Content\VersionInfo;
12
13
class LocationServiceTest extends AbstractServiceTest
14
{
15
    public function getAPIServiceClassName()
16
    {
17
        return APIService::class;
18
    }
19
20
    public function getSiteAccessAwareServiceClassName()
21
    {
22
        return LocationService::class;
23
    }
24
25
    public function providerForPassTroughMethods()
26
    {
27
        $location = new Location();
28
        $contentInfo = new ContentInfo();
29
        $locationCreateStruct = new LocationCreateStruct();
30
        $locationUpdateStruct = new LocationUpdateStruct();
31
32
        // string $method, array $arguments, bool $return = true
33
        return [
34
            ['copySubtree', [$location, $location]],
35
36
            ['getLocationChildCount', [$location]],
37
38
            ['createLocation', [$contentInfo, $locationCreateStruct]],
39
40
            ['updateLocation', [$location, $locationUpdateStruct]],
41
42
            ['swapLocation', [$location, $location]],
43
44
            ['hideLocation', [$location]],
45
46
            ['unhideLocation', [$location]],
47
48
            ['moveSubtree', [$location, $location]],
49
50
            ['deleteLocation', [$location], false],
51
52
            ['newLocationCreateStruct', [55]],
53
54
            ['newLocationUpdateStruct', []],
55
        ];
56
    }
57
58
    public function providerForLanguagesLookupMethods()
59
    {
60
        $location = new Location();
61
        $contentInfo = new ContentInfo();
62
        $versionInfo = new VersionInfo();
63
64
        // string $method, array $arguments, bool $return, int $languageArgumentIndex
65
        return [
66
            ['loadLocation', [55], true, 1],
67
            ['loadLocation', [55, self::LANG_ARG], true, 1],
68
69
            ['loadLocationByRemoteId', ['ergemiotregf'], true, 1],
70
            ['loadLocationByRemoteId', ['ergemiotregf', self::LANG_ARG], true, 1],
71
72
            ['loadLocations', [$contentInfo, null], true, 2],
73
            ['loadLocations', [$contentInfo, $location, self::LANG_ARG], true, 2],
74
75
            ['loadLocationChildren', [$location, 0, 15], true, 3],
76
            ['loadLocationChildren', [$location, 50, 50, self::LANG_ARG], true, 3],
77
78
            ['loadParentLocationsForDraftContent', [$versionInfo], true, 1],
79
            ['loadParentLocationsForDraftContent', [$versionInfo, self::LANG_ARG], true, 1],
80
        ];
81
    }
82
}
83