@@ 240-271 (lines=32) @@ | ||
237 | * @see \eZ\Publish\API\Repository\LocationService::updateLocation() |
|
238 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testUpdateLocation |
|
239 | */ |
|
240 | public function testUpdateLocationThrowsUnauthorizedException() |
|
241 | { |
|
242 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\UnauthorizedException::class); |
|
243 | ||
244 | $repository = $this->getRepository(); |
|
245 | $permissionResolver = $repository->getPermissionResolver(); |
|
246 | ||
247 | $editorsGroupId = $this->generateId('group', 13); |
|
248 | ||
249 | /* BEGIN: Use Case */ |
|
250 | $user = $this->createUserVersion1(); |
|
251 | ||
252 | $locationService = $repository->getLocationService(); |
|
253 | ||
254 | $originalLocation = $locationService->loadLocation($editorsGroupId); |
|
255 | ||
256 | $locationUpdateStruct = $locationService->newLocationUpdateStruct(); |
|
257 | $locationUpdateStruct->priority = 3; |
|
258 | $locationUpdateStruct->remoteId = 'c7adcbf1e96bc29bca28c2d809d0c7ef69272651'; |
|
259 | $locationUpdateStruct->sortField = Location::SORT_FIELD_PRIORITY; |
|
260 | $locationUpdateStruct->sortOrder = Location::SORT_ORDER_DESC; |
|
261 | ||
262 | // Set current user to newly created user |
|
263 | $permissionResolver->setCurrentUserReference($user); |
|
264 | ||
265 | // This call will fail with an "UnauthorizedException" |
|
266 | $locationService->updateLocation( |
|
267 | $originalLocation, |
|
268 | $locationUpdateStruct |
|
269 | ); |
|
270 | /* END: Use Case */ |
|
271 | } |
|
272 | ||
273 | /** |
|
274 | * Test for the swapLocation() method. |
@@ 312-342 (lines=31) @@ | ||
309 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testNewLocationCreateStruct |
|
310 | * @dataProvider dataProviderForOutOfRangeLocationPriority |
|
311 | */ |
|
312 | public function testCreateLocationThrowsInvalidArgumentExceptionPriorityIsOutOfRange($priority) |
|
313 | { |
|
314 | $this->expectException(\eZ\Publish\API\Repository\Exceptions\InvalidArgumentException::class); |
|
315 | ||
316 | $repository = $this->getRepository(); |
|
317 | ||
318 | $contentId = $this->generateId('object', 41); |
|
319 | $parentLocationId = $this->generateId('location', 5); |
|
320 | /* BEGIN: Use Case */ |
|
321 | // $contentId is the ID of an existing content object |
|
322 | // $parentLocationId is the ID of an existing location |
|
323 | $contentService = $repository->getContentService(); |
|
324 | $locationService = $repository->getLocationService(); |
|
325 | ||
326 | // ContentInfo for "How to use eZ Publish" |
|
327 | $contentInfo = $contentService->loadContentInfo($contentId); |
|
328 | ||
329 | $locationCreate = $locationService->newLocationCreateStruct($parentLocationId); |
|
330 | $locationCreate->priority = $priority; |
|
331 | $locationCreate->hidden = true; |
|
332 | $locationCreate->remoteId = 'sindelfingen'; |
|
333 | $locationCreate->sortField = Location::SORT_FIELD_NODE_ID; |
|
334 | $locationCreate->sortOrder = Location::SORT_ORDER_DESC; |
|
335 | ||
336 | // Throws exception, since priority is out of range |
|
337 | $locationService->createLocation( |
|
338 | $contentInfo, |
|
339 | $locationCreate |
|
340 | ); |
|
341 | /* END: Use Case */ |
|
342 | } |
|
343 | ||
344 | public function dataProviderForOutOfRangeLocationPriority() |
|
345 | { |