| @@ 1101-1120 (lines=20) @@ | ||
| 1098 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 1099 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1100 | */ |
|
| 1101 | public function testUpdateLocationThrowsInvalidArgumentException() |
|
| 1102 | { |
|
| 1103 | $repository = $this->getRepository(); |
|
| 1104 | ||
| 1105 | $locationId = $this->generateId('location', 5); |
|
| 1106 | /* BEGIN: Use Case */ |
|
| 1107 | // $locationId and remoteId is the IDs of an existing, but not the same, location |
|
| 1108 | $locationService = $repository->getLocationService(); |
|
| 1109 | ||
| 1110 | $originalLocation = $locationService->loadLocation($locationId); |
|
| 1111 | ||
| 1112 | $updateStruct = $locationService->newLocationUpdateStruct(); |
|
| 1113 | ||
| 1114 | // Remote ID of an existing location with a different locationId |
|
| 1115 | $updateStruct->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
|
| 1116 | ||
| 1117 | // Throws exception, since remote ID is already taken |
|
| 1118 | $locationService->updateLocation($originalLocation, $updateStruct); |
|
| 1119 | /* END: Use Case */ |
|
| 1120 | } |
|
| 1121 | ||
| 1122 | /** |
|
| 1123 | * Test for the updateLocation() method. |
|
| @@ 1765-1791 (lines=27) @@ | ||
| 1762 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1763 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
|
| 1764 | */ |
|
| 1765 | public function testCopySubtreeThrowsInvalidArgumentException() |
|
| 1766 | { |
|
| 1767 | $repository = $this->getRepository(); |
|
| 1768 | ||
| 1769 | $communityLocationId = $this->generateId('location', 5); |
|
| 1770 | /* BEGIN: Use Case */ |
|
| 1771 | // $communityLocationId is the ID of the "Community" page location in |
|
| 1772 | // an eZ Publish demo installation |
|
| 1773 | ||
| 1774 | // Load the location service |
|
| 1775 | $locationService = $repository->getLocationService(); |
|
| 1776 | ||
| 1777 | // Load location to copy |
|
| 1778 | $locationToCopy = $locationService->loadLocation($communityLocationId); |
|
| 1779 | ||
| 1780 | // Use a child as new parent |
|
| 1781 | $childLocations = $locationService->loadLocationChildren($locationToCopy)->locations; |
|
| 1782 | $newParentLocation = end($childLocations); |
|
| 1783 | ||
| 1784 | // This call will fail with an "InvalidArgumentException", because the |
|
| 1785 | // new parent is a child location of the subtree to copy. |
|
| 1786 | $locationService->copySubtree( |
|
| 1787 | $locationToCopy, |
|
| 1788 | $newParentLocation |
|
| 1789 | ); |
|
| 1790 | /* END: Use Case */ |
|
| 1791 | } |
|
| 1792 | ||
| 1793 | /** |
|
| 1794 | * Test for the moveSubtree() method. |
|
| @@ 2144-2172 (lines=29) @@ | ||
| 2141 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
|
| 2142 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 2143 | */ |
|
| 2144 | public function testMoveSubtreeThrowsInvalidArgumentException() |
|
| 2145 | { |
|
| 2146 | $repository = $this->getRepository(); |
|
| 2147 | $mediaLocationId = $this->generateId('location', 43); |
|
| 2148 | $multimediaLocationId = $this->generateId('location', 53); |
|
| 2149 | ||
| 2150 | /* BEGIN: Use Case */ |
|
| 2151 | // $mediaLocationId is the ID of the "Media" page location in |
|
| 2152 | // an eZ Publish demo installation |
|
| 2153 | ||
| 2154 | // $multimediaLocationId is the ID of the "Multimedia" page location in an eZ |
|
| 2155 | // Publish demo installation |
|
| 2156 | ||
| 2157 | // Load the location service |
|
| 2158 | $locationService = $repository->getLocationService(); |
|
| 2159 | ||
| 2160 | // Load location to move |
|
| 2161 | $locationToMove = $locationService->loadLocation($mediaLocationId); |
|
| 2162 | ||
| 2163 | // Load new parent location |
|
| 2164 | $newParentLocation = $locationService->loadLocation($multimediaLocationId); |
|
| 2165 | ||
| 2166 | // Throws an exception because new parent location is placed below location to move |
|
| 2167 | $locationService->moveSubtree( |
|
| 2168 | $locationToMove, |
|
| 2169 | $newParentLocation |
|
| 2170 | ); |
|
| 2171 | /* END: Use Case */ |
|
| 2172 | } |
|
| 2173 | ||
| 2174 | /** |
|
| 2175 | * 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. |
|