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

ObjectStateServiceTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 178
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Importance

Changes 0
Metric Value
dl 0
loc 178
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getServiceMock() 0 4 1
A getSignalSlotService() 0 4 1
B serviceProvider() 0 165 1
1
<?php
2
3
/**
4
 * File containing the ObjectStateTest 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\ObjectStateService as APIObjectStateService;
12
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateCreateStruct;
13
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupCreateStruct;
14
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroupUpdateStruct;
15
use eZ\Publish\API\Repository\Values\ObjectState\ObjectStateUpdateStruct;
16
use eZ\Publish\Core\Repository\Values\ObjectState\ObjectState;
17
use eZ\Publish\Core\Repository\Values\ObjectState\ObjectStateGroup;
18
use eZ\Publish\Core\SignalSlot\SignalDispatcher;
19
use eZ\Publish\Core\SignalSlot\ObjectStateService;
20
use eZ\Publish\Core\SignalSlot\Signal\ObjectStateService as ObjectStateServiceSignals;
21
22
class ObjectStateServiceTest extends ServiceTest
23
{
24
    protected function getServiceMock()
25
    {
26
        return $this->createMock(APIObjectStateService::class);
27
    }
28
29
    protected function getSignalSlotService($coreService, SignalDispatcher $dispatcher)
30
    {
31
        return new ObjectStateService($coreService, $dispatcher);
32
    }
33
34
    public function serviceProvider()
35
    {
36
        $objectStateGroupId = 4;
37
        $objectStateId = 42;
38
        $priority = 50;
39
        $contentId = 59;
40
        $contentRemoteId = md5("What's up doc ?");
41
42
        $objectStateGroupCreateStruct = new ObjectStateGroupCreateStruct();
43
        $objectStateGroupUpdateStruct = new ObjectStateGroupUpdateStruct();
44
        $objectStateCreateStruct = new ObjectStateCreateStruct();
45
        $objectStateUpdateStruct = new ObjectStateUpdateStruct();
46
        $objectStateGroup = new ObjectStateGroup(
47
            array(
48
                'id' => $objectStateGroupId,
49
            )
50
        );
51
        $objectState = new ObjectState(
52
            array(
53
                'id' => $objectStateId,
54
            )
55
        );
56
        $contentInfo = $this->getContentInfo($contentId, $contentRemoteId);
57
58
        return [
59
            [
60
                'createObjectStateGroup',
61
                [$objectStateGroupCreateStruct],
62
                $objectStateGroup,
63
                1,
64
                ObjectStateServiceSignals\CreateObjectStateGroupSignal::class,
65
                ['objectStateGroupId' => $objectStateGroupId],
66
            ],
67
            [
68
                'loadObjectStateGroup',
69
                [4, []],
70
                $objectStateGroup,
71
                0,
72
            ],
73
            [
74
                'loadObjectStateGroups',
75
                [1, 1, []],
76
                [$objectStateGroup],
77
                0,
78
            ],
79
            [
80
                'loadObjectStates',
81
                [$objectStateGroup, []],
82
                [$objectState],
83
                0,
84
            ],
85
            [
86
                'updateObjectStateGroup',
87
                [$objectStateGroup, $objectStateGroupUpdateStruct],
88
                $objectStateGroup,
89
                1,
90
                ObjectStateServiceSignals\UpdateObjectStateGroupSignal::class,
91
                ['objectStateGroupId' => $objectStateGroupId],
92
            ],
93
            [
94
                'deleteObjectStateGroup',
95
                [$objectStateGroup],
96
                null,
97
                1,
98
                ObjectStateServiceSignals\DeleteObjectStateGroupSignal::class,
99
                ['objectStateGroupId' => $objectStateGroupId],
100
            ],
101
            [
102
                'createObjectState',
103
                [$objectStateGroup, $objectStateCreateStruct],
104
                $objectState,
105
                1,
106
                ObjectStateServiceSignals\CreateObjectStateSignal::class,
107
                [
108
                    'objectStateGroupId' => $objectStateGroupId,
109
                    'objectStateId' => $objectStateId,
110
                ],
111
            ],
112
            [
113
                'loadObjectState',
114
                [$objectStateId, []],
115
                $objectState,
116
                0,
117
            ],
118
            [
119
                'updateObjectState',
120
                [$objectState, $objectStateUpdateStruct],
121
                $objectState,
122
                1,
123
                ObjectStateServiceSignals\UpdateObjectStateSignal::class,
124
                [
125
                    'objectStateId' => $objectStateId,
126
                ],
127
            ],
128
            [
129
                'setPriorityOfObjectState',
130
                [$objectState, $priority],
131
                null,
132
                1,
133
                ObjectStateServiceSignals\SetPriorityOfObjectStateSignal::class,
134
                [
135
                    'objectStateId' => $objectStateId,
136
                    'priority' => $priority,
137
                ],
138
            ],
139
            [
140
                'deleteObjectState',
141
                [$objectState],
142
                null,
143
                1,
144
                ObjectStateServiceSignals\DeleteObjectStateSignal::class,
145
                [
146
                    'objectStateId' => $objectStateId,
147
                ],
148
            ],
149
            [
150
                'setContentState',
151
                [$contentInfo, $objectStateGroup, $objectState],
152
                null,
153
                1,
154
                ObjectStateServiceSignals\SetContentStateSignal::class,
155
                [
156
                    'objectStateId' => $objectStateId,
157
                    'contentId' => $contentId,
158
                    'objectStateGroupId' => $objectStateGroupId,
159
                ],
160
            ],
161
            [
162
                'getContentState',
163
                [$contentInfo, $objectStateGroup],
164
                $objectState,
165
                0,
166
            ],
167
            [
168
                'getContentCount',
169
                [$objectState],
170
                35,
171
                0,
172
            ],
173
            [
174
                'newObjectStateGroupCreateStruct',
175
                ['identifier'],
176
                $objectStateGroupCreateStruct,
177
                0,
178
            ],
179
            [
180
                'newObjectStateGroupUpdateStruct',
181
                [],
182
                $objectStateGroupUpdateStruct,
183
                0,
184
            ],
185
            [
186
                'newObjectStateUpdateStruct',
187
                [],
188
                $objectStateUpdateStruct,
189
                0,
190
            ],
191
            [
192
                'newObjectStateCreateStruct',
193
                ['identifier'],
194
                $objectStateCreateStruct,
195
                0,
196
            ],
197
        ];
198
    }
199
}
200