| @@ 337-359 (lines=23) @@ | ||
| 334 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 335 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testUnhideLocation |
|
| 336 | */ |
|
| 337 | public function testUnhideLocationThrowsUnauthorizedException() |
|
| 338 | { |
|
| 339 | $repository = $this->getRepository(); |
|
| 340 | ||
| 341 | $editorsGroupId = $this->generateId('group', 13); |
|
| 342 | ||
| 343 | /* BEGIN: Use Case */ |
|
| 344 | $user = $this->createUserVersion1(); |
|
| 345 | ||
| 346 | $locationService = $repository->getLocationService(); |
|
| 347 | ||
| 348 | $visibleLocation = $locationService->loadLocation($editorsGroupId); |
|
| 349 | ||
| 350 | // Hide location |
|
| 351 | $hiddenLocation = $locationService->hideLocation($visibleLocation); |
|
| 352 | ||
| 353 | // Set current user to newly created user |
|
| 354 | $repository->setCurrentUser($user); |
|
| 355 | ||
| 356 | // This call will fail with an "UnauthorizedException" |
|
| 357 | $locationService->unhideLocation($hiddenLocation); |
|
| 358 | /* END: Use Case */ |
|
| 359 | } |
|
| 360 | ||
| 361 | /** |
|
| 362 | * Test for the deleteLocation() method. |
|
| @@ 1270-1289 (lines=20) @@ | ||
| 1267 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 1268 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1269 | */ |
|
| 1270 | public function testUpdateLocationThrowsInvalidArgumentException() |
|
| 1271 | { |
|
| 1272 | $repository = $this->getRepository(); |
|
| 1273 | ||
| 1274 | $locationId = $this->generateId('location', 5); |
|
| 1275 | /* BEGIN: Use Case */ |
|
| 1276 | // $locationId and remoteId is the IDs of an existing, but not the same, location |
|
| 1277 | $locationService = $repository->getLocationService(); |
|
| 1278 | ||
| 1279 | $originalLocation = $locationService->loadLocation($locationId); |
|
| 1280 | ||
| 1281 | $updateStruct = $locationService->newLocationUpdateStruct(); |
|
| 1282 | ||
| 1283 | // Remote ID of an existing location with a different locationId |
|
| 1284 | $updateStruct->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
|
| 1285 | ||
| 1286 | // Throws exception, since remote ID is already taken |
|
| 1287 | $locationService->updateLocation($originalLocation, $updateStruct); |
|
| 1288 | /* END: Use Case */ |
|
| 1289 | } |
|
| 1290 | ||
| 1291 | /** |
|
| 1292 | * Test for the updateLocation() method. |
|
| @@ 2280-2306 (lines=27) @@ | ||
| 2277 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 2278 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
|
| 2279 | */ |
|
| 2280 | public function testCopySubtreeThrowsInvalidArgumentException() |
|
| 2281 | { |
|
| 2282 | $repository = $this->getRepository(); |
|
| 2283 | ||
| 2284 | $communityLocationId = $this->generateId('location', 5); |
|
| 2285 | /* BEGIN: Use Case */ |
|
| 2286 | // $communityLocationId is the ID of the "Community" page location in |
|
| 2287 | // an eZ Publish demo installation |
|
| 2288 | ||
| 2289 | // Load the location service |
|
| 2290 | $locationService = $repository->getLocationService(); |
|
| 2291 | ||
| 2292 | // Load location to copy |
|
| 2293 | $locationToCopy = $locationService->loadLocation($communityLocationId); |
|
| 2294 | ||
| 2295 | // Use a child as new parent |
|
| 2296 | $childLocations = $locationService->loadLocationChildren($locationToCopy)->locations; |
|
| 2297 | $newParentLocation = end($childLocations); |
|
| 2298 | ||
| 2299 | // This call will fail with an "InvalidArgumentException", because the |
|
| 2300 | // new parent is a child location of the subtree to copy. |
|
| 2301 | $locationService->copySubtree( |
|
| 2302 | $locationToCopy, |
|
| 2303 | $newParentLocation |
|
| 2304 | ); |
|
| 2305 | /* END: Use Case */ |
|
| 2306 | } |
|
| 2307 | ||
| 2308 | /** |
|
| 2309 | * Test for the moveSubtree() method. |
|
| @@ 2700-2728 (lines=29) @@ | ||
| 2697 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
|
| 2698 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 2699 | */ |
|
| 2700 | public function testMoveSubtreeThrowsInvalidArgumentException() |
|
| 2701 | { |
|
| 2702 | $repository = $this->getRepository(); |
|
| 2703 | $mediaLocationId = $this->generateId('location', 43); |
|
| 2704 | $multimediaLocationId = $this->generateId('location', 53); |
|
| 2705 | ||
| 2706 | /* BEGIN: Use Case */ |
|
| 2707 | // $mediaLocationId is the ID of the "Media" page location in |
|
| 2708 | // an eZ Publish demo installation |
|
| 2709 | ||
| 2710 | // $multimediaLocationId is the ID of the "Multimedia" page location in an eZ |
|
| 2711 | // Publish demo installation |
|
| 2712 | ||
| 2713 | // Load the location service |
|
| 2714 | $locationService = $repository->getLocationService(); |
|
| 2715 | ||
| 2716 | // Load location to move |
|
| 2717 | $locationToMove = $locationService->loadLocation($mediaLocationId); |
|
| 2718 | ||
| 2719 | // Load new parent location |
|
| 2720 | $newParentLocation = $locationService->loadLocation($multimediaLocationId); |
|
| 2721 | ||
| 2722 | // Throws an exception because new parent location is placed below location to move |
|
| 2723 | $locationService->moveSubtree( |
|
| 2724 | $locationToMove, |
|
| 2725 | $newParentLocation |
|
| 2726 | ); |
|
| 2727 | /* END: Use Case */ |
|
| 2728 | } |
|
| 2729 | ||
| 2730 | /** |
|
| 2731 | * Loads properties from all locations in the $location's subtree. |
|