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

UrlAliasHandlerTest::testUnCachedMethods()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 34
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 26
nc 6
nop 2
dl 0
loc 34
rs 8.439
c 0
b 0
f 0
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\UrlAlias;
12
use eZ\Publish\SPI\Persistence\Content\UrlAlias\Handler as SPIUrlAliasHandler;
13
14
/**
15
 * Test case for Persistence\Cache\UrlAliasHandler.
16
 */
17
class UrlAliasHandlerTest extends AbstractCacheHandlerTest
18
{
19
    public function getHandlerMethodName(): string
20
    {
21
        return 'urlAliasHandler';
22
    }
23
24
    public function getHandlerClassName(): string
25
    {
26
        return SPIUrlAliasHandler::class;
27
    }
28
29
    public function providerForUnCachedMethods(): array
30
    {
31
        // string $method, array $arguments, array? $tags, string? $key
32
        return [
33
            ['publishUrlAliasForLocation', [44, 2, 'name', 'eng-GB', true, false], ['urlAlias-location-44', 'urlAlias-location-path-44', 'urlAlias-notFound']],
34
            ['createCustomUrlAlias', [44, '1/2/44', true, null, false], ['urlAlias-location-44', 'urlAlias-location-path-44', 'urlAlias-notFound']],
35
            ['createGlobalUrlAlias', ['something', '1/2/44', true, null, false], ['urlAlias-notFound']],
36
            ['createGlobalUrlAlias', ['something', '1/2/44', true, 'eng-GB', false], ['urlAlias-notFound']],
37
            ['listGlobalURLAliases', ['eng-GB', 10, 50]],
38
            ['removeURLAliases', [[new UrlAlias(['id' => 5, 'type' => UrlAlias::LOCATION, 'isCustom' => true, 'destination' => 21])]], ['urlAlias-5', 'urlAlias-location-21', 'urlAlias-location-path-21', 'urlAlias-custom-21']],
39
            ['locationMoved', [21, 45, 12], ['urlAlias-location-21', 'urlAlias-location-path-21']],
40
            ['locationCopied', [21, 33, 12], ['urlAlias-location-21', 'urlAlias-location-33']],
41
            ['locationDeleted', [21], ['urlAlias-location-21', 'urlAlias-location-path-21']],
42
            ['locationSwapped', [21, 2, 33, 45], ['urlAlias-location-21', 'urlAlias-location-path-21', 'urlAlias-location-33', 'urlAlias-location-path-33']],
43
            ['translationRemoved', [[21, 33], 'eng-GB'], ['urlAlias-location-21', 'urlAlias-location-path-21', 'urlAlias-location-33', 'urlAlias-location-path-33']],
44
            ['archiveUrlAliasesForDeletedTranslations', [21, 33, ['eng-GB']], ['urlAlias-location-21', 'urlAlias-location-path-21']],
45
        ];
46
    }
47
48
    public function providerForCachedLoadMethods(): array
49
    {
50
        $object = new UrlAlias(['id' => 5]);
51
52
        // string $method, array $arguments, string $key, mixed? $data
53
        return [
54
            ['listURLAliasesForLocation', [5], 'ez-urlAlias-location-list-5', [$object]],
55
            ['listURLAliasesForLocation', [5, true], 'ez-urlAlias-location-list-5-custom', [$object]],
56
            ['lookup', ['/Home'], 'ez-urlAlias-url-_Home', $object],
57
            ['loadUrlAlias', [5], 'ez-urlAlias-5', $object],
58
        ];
59
    }
60
}
61