| @@ 316-338 (lines=23) @@ | ||
| 313 | * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException |
|
| 314 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testUnhideLocation |
|
| 315 | */ |
|
| 316 | public function testUnhideLocationThrowsUnauthorizedException() |
|
| 317 | { |
|
| 318 | $repository = $this->getRepository(); |
|
| 319 | ||
| 320 | $editorsGroupId = $this->generateId('group', 13); |
|
| 321 | ||
| 322 | /* BEGIN: Use Case */ |
|
| 323 | $user = $this->createUserVersion1(); |
|
| 324 | ||
| 325 | $locationService = $repository->getLocationService(); |
|
| 326 | ||
| 327 | $visibleLocation = $locationService->loadLocation($editorsGroupId); |
|
| 328 | ||
| 329 | // Hide location |
|
| 330 | $hiddenLocation = $locationService->hideLocation($visibleLocation); |
|
| 331 | ||
| 332 | // Set current user to newly created user |
|
| 333 | $repository->setCurrentUser($user); |
|
| 334 | ||
| 335 | // This call will fail with an "UnauthorizedException" |
|
| 336 | $locationService->unhideLocation($hiddenLocation); |
|
| 337 | /* END: Use Case */ |
|
| 338 | } |
|
| 339 | ||
| 340 | /** |
|
| 341 | * Test for the deleteLocation() method. |
|
| @@ 1103-1122 (lines=20) @@ | ||
| 1100 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 1101 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1102 | */ |
|
| 1103 | public function testUpdateLocationThrowsInvalidArgumentException() |
|
| 1104 | { |
|
| 1105 | $repository = $this->getRepository(); |
|
| 1106 | ||
| 1107 | $locationId = $this->generateId('location', 5); |
|
| 1108 | /* BEGIN: Use Case */ |
|
| 1109 | // $locationId and remoteId is the IDs of an existing, but not the same, location |
|
| 1110 | $locationService = $repository->getLocationService(); |
|
| 1111 | ||
| 1112 | $originalLocation = $locationService->loadLocation($locationId); |
|
| 1113 | ||
| 1114 | $updateStruct = $locationService->newLocationUpdateStruct(); |
|
| 1115 | ||
| 1116 | // Remote ID of an existing location with a different locationId |
|
| 1117 | $updateStruct->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
|
| 1118 | ||
| 1119 | // Throws exception, since remote ID is already taken |
|
| 1120 | $locationService->updateLocation($originalLocation, $updateStruct); |
|
| 1121 | /* END: Use Case */ |
|
| 1122 | } |
|
| 1123 | ||
| 1124 | /** |
|
| 1125 | * Test for the updateLocation() method. |
|
| @@ 1966-1992 (lines=27) @@ | ||
| 1963 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1964 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
|
| 1965 | */ |
|
| 1966 | public function testCopySubtreeThrowsInvalidArgumentException() |
|
| 1967 | { |
|
| 1968 | $repository = $this->getRepository(); |
|
| 1969 | ||
| 1970 | $communityLocationId = $this->generateId('location', 5); |
|
| 1971 | /* BEGIN: Use Case */ |
|
| 1972 | // $communityLocationId is the ID of the "Community" page location in |
|
| 1973 | // an eZ Publish demo installation |
|
| 1974 | ||
| 1975 | // Load the location service |
|
| 1976 | $locationService = $repository->getLocationService(); |
|
| 1977 | ||
| 1978 | // Load location to copy |
|
| 1979 | $locationToCopy = $locationService->loadLocation($communityLocationId); |
|
| 1980 | ||
| 1981 | // Use a child as new parent |
|
| 1982 | $childLocations = $locationService->loadLocationChildren($locationToCopy)->locations; |
|
| 1983 | $newParentLocation = end($childLocations); |
|
| 1984 | ||
| 1985 | // This call will fail with an "InvalidArgumentException", because the |
|
| 1986 | // new parent is a child location of the subtree to copy. |
|
| 1987 | $locationService->copySubtree( |
|
| 1988 | $locationToCopy, |
|
| 1989 | $newParentLocation |
|
| 1990 | ); |
|
| 1991 | /* END: Use Case */ |
|
| 1992 | } |
|
| 1993 | ||
| 1994 | /** |
|
| 1995 | * Test for the moveSubtree() method. |
|
| @@ 2345-2373 (lines=29) @@ | ||
| 2342 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
|
| 2343 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 2344 | */ |
|
| 2345 | public function testMoveSubtreeThrowsInvalidArgumentException() |
|
| 2346 | { |
|
| 2347 | $repository = $this->getRepository(); |
|
| 2348 | $mediaLocationId = $this->generateId('location', 43); |
|
| 2349 | $multimediaLocationId = $this->generateId('location', 53); |
|
| 2350 | ||
| 2351 | /* BEGIN: Use Case */ |
|
| 2352 | // $mediaLocationId is the ID of the "Media" page location in |
|
| 2353 | // an eZ Publish demo installation |
|
| 2354 | ||
| 2355 | // $multimediaLocationId is the ID of the "Multimedia" page location in an eZ |
|
| 2356 | // Publish demo installation |
|
| 2357 | ||
| 2358 | // Load the location service |
|
| 2359 | $locationService = $repository->getLocationService(); |
|
| 2360 | ||
| 2361 | // Load location to move |
|
| 2362 | $locationToMove = $locationService->loadLocation($mediaLocationId); |
|
| 2363 | ||
| 2364 | // Load new parent location |
|
| 2365 | $newParentLocation = $locationService->loadLocation($multimediaLocationId); |
|
| 2366 | ||
| 2367 | // Throws an exception because new parent location is placed below location to move |
|
| 2368 | $locationService->moveSubtree( |
|
| 2369 | $locationToMove, |
|
| 2370 | $newParentLocation |
|
| 2371 | ); |
|
| 2372 | /* END: Use Case */ |
|
| 2373 | } |
|
| 2374 | ||
| 2375 | /** |
|
| 2376 | * Loads properties from all locations in the $location's subtree. |
|