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

URLWildcardServiceTest::serviceProvider()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 59

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 59
rs 8.8945
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 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