Completed
Push — ezp-30616 ( 9239a0...7bf8e8 )
by
unknown
57:53 queued 37:56
created

URLWildcardServiceTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getServiceMock() 0 4 1
A getSignalSlotService() 0 4 1
B serviceProvider() 0 59 1
1
<?php
2
3
/**
4
 * File containing the URLWildcardServiceTest 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\SignalSlot\Tests;
10
11
use eZ\Publish\API\Repository\URLWildcardService as APIURLWildcardService;
12
use eZ\Publish\API\Repository\Values\Content\URLWildcard;
13
use eZ\Publish\API\Repository\Values\Content\URLWildcardTranslationResult;
14
use eZ\Publish\Core\SignalSlot\SignalDispatcher;
15
use eZ\Publish\Core\SignalSlot\URLWildcardService;
16
use eZ\Publish\Core\SignalSlot\Signal\URLWildcardService as URLWildcardServiceSignals;
17
18
class URLWildcardServiceTest extends ServiceTest
19
{
20
    protected function getServiceMock()
21
    {
22
        return $this->createMock(APIURLWildcardService::class);
23
    }
24
25
    protected function getSignalSlotService($coreService, SignalDispatcher $dispatcher)
26
    {
27
        return new URLWildcardService($coreService, $dispatcher);
28
    }
29
30
    public function serviceProvider()
31
    {
32
        $wildcardId = 42;
33
        $sourceUrl = '/cms';
34
        $destinationUrl = '/cxm';
35
        $forward = true;
36
        $wildcard = new URLWildcard(
37
            array(
38
                'id' => $wildcardId,
39
                'sourceUrl' => $sourceUrl,
40
                'destinationUrl' => $destinationUrl,
41
                'forward' => $forward,
42
            )
43
        );
44
45
        return array(
46
            array(
47
                'create',
48
                array($sourceUrl, $destinationUrl, $forward),
49
                $wildcard,
50
                1,
51
                URLWildcardServiceSignals\CreateSignal::class,
52
                array('urlWildcardId' => $wildcardId),
53
            ),
54
            array(
55
                'remove',
56
                array($wildcard),
57
                null,
58
                1,
59
                URLWildcardServiceSignals\RemoveSignal::class,
60
                array('urlWildcardId' => $wildcardId),
61
            ),
62
            array(
63
                'load',
64
                array($wildcardId),
65
                $wildcard,
66
                0,
67
            ),
68
            array(
69
                'loadAll',
70
                array(0, 1),
71
                array($wildcard),
72
                0,
73
            ),
74
            array(
75
                'translate',
76
                array($sourceUrl),
77
                new URLWildcardTranslationResult(
78
                    array(
79
                        'uri' => $destinationUrl,
80
                        'forward' => $forward,
81
                    )
82
                ),
83
                1,
84
                URLWildcardServiceSignals\TranslateSignal::class,
85
                array('url' => $sourceUrl),
86
            ),
87
        );
88
    }
89
}
90