| @@ 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. |
|
| @@ 1191-1210 (lines=20) @@ | ||
| 1188 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 1189 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1190 | */ |
|
| 1191 | public function testUpdateLocationThrowsInvalidArgumentException() |
|
| 1192 | { |
|
| 1193 | $repository = $this->getRepository(); |
|
| 1194 | ||
| 1195 | $locationId = $this->generateId('location', 5); |
|
| 1196 | /* BEGIN: Use Case */ |
|
| 1197 | // $locationId and remoteId is the IDs of an existing, but not the same, location |
|
| 1198 | $locationService = $repository->getLocationService(); |
|
| 1199 | ||
| 1200 | $originalLocation = $locationService->loadLocation($locationId); |
|
| 1201 | ||
| 1202 | $updateStruct = $locationService->newLocationUpdateStruct(); |
|
| 1203 | ||
| 1204 | // Remote ID of an existing location with a different locationId |
|
| 1205 | $updateStruct->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
|
| 1206 | ||
| 1207 | // Throws exception, since remote ID is already taken |
|
| 1208 | $locationService->updateLocation($originalLocation, $updateStruct); |
|
| 1209 | /* END: Use Case */ |
|
| 1210 | } |
|
| 1211 | ||
| 1212 | /** |
|
| 1213 | * Test for the updateLocation() method. |
|
| @@ 1921-1947 (lines=27) @@ | ||
| 1918 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1919 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
|
| 1920 | */ |
|
| 1921 | public function testCopySubtreeThrowsInvalidArgumentException() |
|
| 1922 | { |
|
| 1923 | $repository = $this->getRepository(); |
|
| 1924 | ||
| 1925 | $communityLocationId = $this->generateId('location', 5); |
|
| 1926 | /* BEGIN: Use Case */ |
|
| 1927 | // $communityLocationId is the ID of the "Community" page location in |
|
| 1928 | // an eZ Publish demo installation |
|
| 1929 | ||
| 1930 | // Load the location service |
|
| 1931 | $locationService = $repository->getLocationService(); |
|
| 1932 | ||
| 1933 | // Load location to copy |
|
| 1934 | $locationToCopy = $locationService->loadLocation($communityLocationId); |
|
| 1935 | ||
| 1936 | // Use a child as new parent |
|
| 1937 | $childLocations = $locationService->loadLocationChildren($locationToCopy)->locations; |
|
| 1938 | $newParentLocation = end($childLocations); |
|
| 1939 | ||
| 1940 | // This call will fail with an "InvalidArgumentException", because the |
|
| 1941 | // new parent is a child location of the subtree to copy. |
|
| 1942 | $locationService->copySubtree( |
|
| 1943 | $locationToCopy, |
|
| 1944 | $newParentLocation |
|
| 1945 | ); |
|
| 1946 | /* END: Use Case */ |
|
| 1947 | } |
|
| 1948 | ||
| 1949 | /** |
|
| 1950 | * Test for the moveSubtree() method. |
|
| @@ 2300-2328 (lines=29) @@ | ||
| 2297 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
|
| 2298 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 2299 | */ |
|
| 2300 | public function testMoveSubtreeThrowsInvalidArgumentException() |
|
| 2301 | { |
|
| 2302 | $repository = $this->getRepository(); |
|
| 2303 | $mediaLocationId = $this->generateId('location', 43); |
|
| 2304 | $multimediaLocationId = $this->generateId('location', 53); |
|
| 2305 | ||
| 2306 | /* BEGIN: Use Case */ |
|
| 2307 | // $mediaLocationId is the ID of the "Media" page location in |
|
| 2308 | // an eZ Publish demo installation |
|
| 2309 | ||
| 2310 | // $multimediaLocationId is the ID of the "Multimedia" page location in an eZ |
|
| 2311 | // Publish demo installation |
|
| 2312 | ||
| 2313 | // Load the location service |
|
| 2314 | $locationService = $repository->getLocationService(); |
|
| 2315 | ||
| 2316 | // Load location to move |
|
| 2317 | $locationToMove = $locationService->loadLocation($mediaLocationId); |
|
| 2318 | ||
| 2319 | // Load new parent location |
|
| 2320 | $newParentLocation = $locationService->loadLocation($multimediaLocationId); |
|
| 2321 | ||
| 2322 | // Throws an exception because new parent location is placed below location to move |
|
| 2323 | $locationService->moveSubtree( |
|
| 2324 | $locationToMove, |
|
| 2325 | $newParentLocation |
|
| 2326 | ); |
|
| 2327 | /* END: Use Case */ |
|
| 2328 | } |
|
| 2329 | ||
| 2330 | /** |
|
| 2331 | * Loads properties from all locations in the $location's subtree. |
|