| @@ 1144-1163 (lines=20) @@ | ||
| 1141 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 1142 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1143 | */ |
|
| 1144 | public function testUpdateLocationThrowsInvalidArgumentException() |
|
| 1145 | { |
|
| 1146 | $repository = $this->getRepository(); |
|
| 1147 | ||
| 1148 | $locationId = $this->generateId('location', 5); |
|
| 1149 | /* BEGIN: Use Case */ |
|
| 1150 | // $locationId and remoteId is the IDs of an existing, but not the same, location |
|
| 1151 | $locationService = $repository->getLocationService(); |
|
| 1152 | ||
| 1153 | $originalLocation = $locationService->loadLocation($locationId); |
|
| 1154 | ||
| 1155 | $updateStruct = $locationService->newLocationUpdateStruct(); |
|
| 1156 | ||
| 1157 | // Remote ID of an existing location with a different locationId |
|
| 1158 | $updateStruct->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
|
| 1159 | ||
| 1160 | // Throws exception, since remote ID is already taken |
|
| 1161 | $locationService->updateLocation($originalLocation, $updateStruct); |
|
| 1162 | /* END: Use Case */ |
|
| 1163 | } |
|
| 1164 | ||
| 1165 | /** |
|
| 1166 | * Test for the updateLocation() method. |
|
| @@ 1942-1968 (lines=27) @@ | ||
| 1939 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1940 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
|
| 1941 | */ |
|
| 1942 | public function testCopySubtreeThrowsInvalidArgumentException() |
|
| 1943 | { |
|
| 1944 | $repository = $this->getRepository(); |
|
| 1945 | ||
| 1946 | $communityLocationId = $this->generateId('location', 5); |
|
| 1947 | /* BEGIN: Use Case */ |
|
| 1948 | // $communityLocationId is the ID of the "Community" page location in |
|
| 1949 | // an eZ Publish demo installation |
|
| 1950 | ||
| 1951 | // Load the location service |
|
| 1952 | $locationService = $repository->getLocationService(); |
|
| 1953 | ||
| 1954 | // Load location to copy |
|
| 1955 | $locationToCopy = $locationService->loadLocation($communityLocationId); |
|
| 1956 | ||
| 1957 | // Use a child as new parent |
|
| 1958 | $childLocations = $locationService->loadLocationChildren($locationToCopy)->locations; |
|
| 1959 | $newParentLocation = end($childLocations); |
|
| 1960 | ||
| 1961 | // This call will fail with an "InvalidArgumentException", because the |
|
| 1962 | // new parent is a child location of the subtree to copy. |
|
| 1963 | $locationService->copySubtree( |
|
| 1964 | $locationToCopy, |
|
| 1965 | $newParentLocation |
|
| 1966 | ); |
|
| 1967 | /* END: Use Case */ |
|
| 1968 | } |
|
| 1969 | ||
| 1970 | /** |
|
| 1971 | * Test for the moveSubtree() method. |
|
| @@ 2321-2349 (lines=29) @@ | ||
| 2318 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
|
| 2319 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 2320 | */ |
|
| 2321 | public function testMoveSubtreeThrowsInvalidArgumentException() |
|
| 2322 | { |
|
| 2323 | $repository = $this->getRepository(); |
|
| 2324 | $mediaLocationId = $this->generateId('location', 43); |
|
| 2325 | $multimediaLocationId = $this->generateId('location', 53); |
|
| 2326 | ||
| 2327 | /* BEGIN: Use Case */ |
|
| 2328 | // $mediaLocationId is the ID of the "Media" page location in |
|
| 2329 | // an eZ Publish demo installation |
|
| 2330 | ||
| 2331 | // $multimediaLocationId is the ID of the "Multimedia" page location in an eZ |
|
| 2332 | // Publish demo installation |
|
| 2333 | ||
| 2334 | // Load the location service |
|
| 2335 | $locationService = $repository->getLocationService(); |
|
| 2336 | ||
| 2337 | // Load location to move |
|
| 2338 | $locationToMove = $locationService->loadLocation($mediaLocationId); |
|
| 2339 | ||
| 2340 | // Load new parent location |
|
| 2341 | $newParentLocation = $locationService->loadLocation($multimediaLocationId); |
|
| 2342 | ||
| 2343 | // Throws an exception because new parent location is placed below location to move |
|
| 2344 | $locationService->moveSubtree( |
|
| 2345 | $locationToMove, |
|
| 2346 | $newParentLocation |
|
| 2347 | ); |
|
| 2348 | /* END: Use Case */ |
|
| 2349 | } |
|
| 2350 | ||
| 2351 | /** |
|
| 2352 | * Loads properties from all locations in the $location's subtree. |
|
| @@ 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. |
|