1 | <?php |
||
20 | abstract class ServiceTest extends TestCase |
||
21 | { |
||
22 | /** |
||
23 | * Returns a mock of the aggregated service. |
||
24 | */ |
||
25 | abstract protected function getServiceMock(); |
||
26 | |||
27 | /** |
||
28 | * Returns an instance of the SignalSlot service to test. |
||
29 | * |
||
30 | * @param mixed $innerService mock of the inner service used by the signal |
||
31 | * slot one used to test whether the original method is called is correctly |
||
32 | * called. |
||
33 | * @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $dispatcher mock of |
||
34 | * the dispatcher used to test whether the emit method is correctly called |
||
35 | * |
||
36 | * @return object An instance of the SignalSlot service |
||
37 | */ |
||
38 | abstract protected function getSignalSlotService($innerService, SignalDispatcher $dispatcher); |
||
39 | |||
40 | /** |
||
41 | * @dataProvider serviceProvider |
||
42 | * |
||
43 | * Tests that: |
||
44 | * - the original service method is called with the exact same arguments |
||
45 | * - the signal is emitted with the correct signal object containing the |
||
46 | * expected attributes/values |
||
47 | * - the returned value from the original service method is returned |
||
48 | * by the method from the signal slot service |
||
49 | */ |
||
50 | public function testService( |
||
104 | |||
105 | /** |
||
106 | * Creates a content info from $contentId and $remoteId. |
||
107 | * |
||
108 | * @param mixed $contentId |
||
109 | * @param mixed $remoteId |
||
110 | * |
||
111 | * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo |
||
112 | */ |
||
113 | protected function getContentInfo($contentId, $remoteId) |
||
119 | |||
120 | /** |
||
121 | * Creates a version info object from $contentInfo and $versionNo. |
||
122 | * |
||
123 | * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo |
||
124 | * @param int $versionNo |
||
125 | * @param string|null $languageCode |
||
126 | * |
||
127 | * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo |
||
128 | */ |
||
129 | protected function getVersionInfo(ContentInfo $contentInfo, int $versionNo, ?string $languageCode = null): VersionInfo |
||
139 | |||
140 | /** |
||
141 | * Creates a content object from $versionInfo. |
||
142 | * |
||
143 | * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo |
||
144 | * |
||
145 | * @return \eZ\Publish\API\Repository\Values\Content\Content |
||
146 | */ |
||
147 | protected function getContent(VersionInfo $versionInfo) |
||
156 | |||
157 | /** |
||
158 | * Creates a User object from $userId, $userRemoteId and $userVersionNo. |
||
159 | * |
||
160 | * @param mixed $userId |
||
161 | * @param mixed $userRemoteId |
||
162 | * @param int $userVersionNo |
||
163 | * |
||
164 | * @return \eZ\Publish\Core\Repository\Values\User\User |
||
165 | */ |
||
166 | protected function getUser($userId, $userRemoteId, $userVersionNo) |
||
179 | |||
180 | /** |
||
181 | * Returns a new UserGroup. |
||
182 | * |
||
183 | * @param mixed $groupId |
||
184 | * @param mixed $groupRemoteId |
||
185 | * @param int $groupVersioNo |
||
186 | * |
||
187 | * @return \eZ\Publish\Core\Repository\Values\User\UserGroup |
||
188 | */ |
||
189 | protected function getUserGroup($groupId, $groupRemoteId, $groupVersioNo) |
||
202 | |||
203 | protected function getLanguage(string $languageCode): Language |
||
211 | } |
||
212 |