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

SectionServiceTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 131
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 131
c 0
b 0
f 0
rs 10
wmc 3
lcom 0
cbo 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getServiceMock() 0 4 1
A getSignalSlotService() 0 4 1
B serviceProvider() 0 118 1
1
<?php
2
3
/**
4
 * File containing the SectionServiceTest 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\SectionService as APISectionService;
12
use eZ\Publish\API\Repository\Values\Content\SectionCreateStruct;
13
use eZ\Publish\API\Repository\Values\Content\SectionUpdateStruct;
14
use eZ\Publish\API\Repository\Values\Content\Section;
15
use eZ\Publish\Core\Repository\Values\Content\Location;
16
use eZ\Publish\Core\SignalSlot\SignalDispatcher;
17
use eZ\Publish\Core\SignalSlot\SectionService;
18
use eZ\Publish\Core\SignalSlot\Signal\SectionService as SectionServiceSignal;
19
20
class SectionServiceTest extends ServiceTest
21
{
22
    protected function getServiceMock()
23
    {
24
        return $this->createMock(APISectionService::class);
25
    }
26
27
    protected function getSignalSlotService($coreService, SignalDispatcher $dispatcher)
28
    {
29
        return new SectionService($coreService, $dispatcher);
30
    }
31
32
    public function serviceProvider()
33
    {
34
        $sectionId = 1;
35
        $sectionIdentifier = 'mordor';
36
        $sectionName = 'Mordor';
37
        $locationId = 46;
38
        $contentId = 42;
39
40
        $section = new Section(
41
            array(
42
                'id' => $sectionId,
43
                'identifier' => $sectionIdentifier,
44
                'name' => $sectionName,
45
            )
46
        );
47
48
        $location = new Location([
49
            'id' => $locationId,
50
        ]);
51
52
        $contentInfo = $this->getContentInfo($contentId, md5('Osgiliath'));
53
54
        $sectionCreateStruct = new SectionCreateStruct();
55
        $sectionUpdateStruct = new SectionUpdateStruct();
56
57
        return array(
58
            array(
59
                'createSection',
60
                array($sectionCreateStruct),
61
                $section,
62
                1,
63
                SectionServiceSignal\CreateSectionSignal::class,
64
                array('sectionId' => $sectionId),
65
            ),
66
            array(
67
                'updateSection',
68
                array($section, $sectionUpdateStruct),
69
                $section,
70
                1,
71
                SectionServiceSignal\UpdateSectionSignal::class,
72
                array('sectionId' => $sectionId),
73
            ),
74
            array(
75
                'loadSection',
76
                array($sectionId),
77
                $section,
78
                0,
79
            ),
80
            array(
81
                'loadSections',
82
                array(),
83
                array($section),
84
                0,
85
            ),
86
            array(
87
                'loadSectionByIdentifier',
88
                array($sectionIdentifier),
89
                $section,
90
                0,
91
            ),
92
            array(
93
                'countAssignedContents',
94
                array($section),
95
                42,
96
                0,
97
            ),
98
            array(
99
                'isSectionUsed',
100
                array($section),
101
                true,
102
                0,
103
            ),
104
            array(
105
                'assignSection',
106
                array($contentInfo, $section),
107
                null,
108
                1,
109
                SectionServiceSignal\AssignSectionSignal::class,
110
                array(
111
                    'contentId' => $contentId,
112
                    'sectionId' => $sectionId,
113
                ),
114
            ),
115
            array(
116
                'assignSectionToSubtree',
117
                array($location, $section),
118
                null,
119
                1,
120
                SectionServiceSignal\AssignSectionToSubtreeSignal::class,
121
                array(
122
                    'locationId' => $locationId,
123
                    'sectionId' => $sectionId,
124
                ),
125
            ),
126
            array(
127
                'deleteSection',
128
                array($section),
129
                null,
130
                1,
131
                SectionServiceSignal\DeleteSectionSignal::class,
132
                array(
133
                    'sectionId' => $sectionId,
134
                ),
135
            ),
136
            array(
137
                'newSectionCreateStruct',
138
                array(),
139
                $sectionCreateStruct,
140
                0,
141
            ),
142
            array(
143
                'newSectionUpdateStruct',
144
                array(),
145
                $sectionUpdateStruct,
146
                0,
147
            ),
148
        );
149
    }
150
}
151