| @@ 153-172 (lines=20) @@ | ||
| 150 | * @see \eZ\Publish\API\Repository\TrashService::trash() |
|
| 151 | * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testTrash |
|
| 152 | */ |
|
| 153 | public function testTrashDecrementsChildCountOnParentLocation() |
|
| 154 | { |
|
| 155 | $repository = $this->getRepository(); |
|
| 156 | $locationService = $repository->getLocationService(); |
|
| 157 | ||
| 158 | $baseLocationId = $this->generateId('location', 1); |
|
| 159 | ||
| 160 | $location = $locationService->loadLocation($baseLocationId); |
|
| 161 | ||
| 162 | $childCount = $locationService->getLocationChildCount($location); |
|
| 163 | ||
| 164 | $this->createTrashItem(); |
|
| 165 | ||
| 166 | $this->refreshSearch($repository); |
|
| 167 | ||
| 168 | $this->assertEquals( |
|
| 169 | $childCount - 1, |
|
| 170 | $locationService->getLocationChildCount($location) |
|
| 171 | ); |
|
| 172 | } |
|
| 173 | ||
| 174 | /** |
|
| 175 | * Test sending a location to trash updates Content mainLocation. |
|
| @@ 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. |
|
| @@ 1272-1291 (lines=20) @@ | ||
| 1269 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
|
| 1270 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 1271 | */ |
|
| 1272 | public function testUpdateLocationThrowsInvalidArgumentException() |
|
| 1273 | { |
|
| 1274 | $repository = $this->getRepository(); |
|
| 1275 | ||
| 1276 | $locationId = $this->generateId('location', 5); |
|
| 1277 | /* BEGIN: Use Case */ |
|
| 1278 | // $locationId and remoteId is the IDs of an existing, but not the same, location |
|
| 1279 | $locationService = $repository->getLocationService(); |
|
| 1280 | ||
| 1281 | $originalLocation = $locationService->loadLocation($locationId); |
|
| 1282 | ||
| 1283 | $updateStruct = $locationService->newLocationUpdateStruct(); |
|
| 1284 | ||
| 1285 | // Remote ID of an existing location with a different locationId |
|
| 1286 | $updateStruct->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
|
| 1287 | ||
| 1288 | // Throws exception, since remote ID is already taken |
|
| 1289 | $locationService->updateLocation($originalLocation, $updateStruct); |
|
| 1290 | /* END: Use Case */ |
|
| 1291 | } |
|
| 1292 | ||
| 1293 | /** |
|
| 1294 | * Test for the updateLocation() method. |
|
| @@ 2070-2096 (lines=27) @@ | ||
| 2067 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 2068 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
|
| 2069 | */ |
|
| 2070 | public function testCopySubtreeThrowsInvalidArgumentException() |
|
| 2071 | { |
|
| 2072 | $repository = $this->getRepository(); |
|
| 2073 | ||
| 2074 | $communityLocationId = $this->generateId('location', 5); |
|
| 2075 | /* BEGIN: Use Case */ |
|
| 2076 | // $communityLocationId is the ID of the "Community" page location in |
|
| 2077 | // an eZ Publish demo installation |
|
| 2078 | ||
| 2079 | // Load the location service |
|
| 2080 | $locationService = $repository->getLocationService(); |
|
| 2081 | ||
| 2082 | // Load location to copy |
|
| 2083 | $locationToCopy = $locationService->loadLocation($communityLocationId); |
|
| 2084 | ||
| 2085 | // Use a child as new parent |
|
| 2086 | $childLocations = $locationService->loadLocationChildren($locationToCopy)->locations; |
|
| 2087 | $newParentLocation = end($childLocations); |
|
| 2088 | ||
| 2089 | // This call will fail with an "InvalidArgumentException", because the |
|
| 2090 | // new parent is a child location of the subtree to copy. |
|
| 2091 | $locationService->copySubtree( |
|
| 2092 | $locationToCopy, |
|
| 2093 | $newParentLocation |
|
| 2094 | ); |
|
| 2095 | /* END: Use Case */ |
|
| 2096 | } |
|
| 2097 | ||
| 2098 | /** |
|
| 2099 | * Test for the moveSubtree() method. |
|
| @@ 2449-2477 (lines=29) @@ | ||
| 2446 | * @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
|
| 2447 | * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
|
| 2448 | */ |
|
| 2449 | public function testMoveSubtreeThrowsInvalidArgumentException() |
|
| 2450 | { |
|
| 2451 | $repository = $this->getRepository(); |
|
| 2452 | $mediaLocationId = $this->generateId('location', 43); |
|
| 2453 | $multimediaLocationId = $this->generateId('location', 53); |
|
| 2454 | ||
| 2455 | /* BEGIN: Use Case */ |
|
| 2456 | // $mediaLocationId is the ID of the "Media" page location in |
|
| 2457 | // an eZ Publish demo installation |
|
| 2458 | ||
| 2459 | // $multimediaLocationId is the ID of the "Multimedia" page location in an eZ |
|
| 2460 | // Publish demo installation |
|
| 2461 | ||
| 2462 | // Load the location service |
|
| 2463 | $locationService = $repository->getLocationService(); |
|
| 2464 | ||
| 2465 | // Load location to move |
|
| 2466 | $locationToMove = $locationService->loadLocation($mediaLocationId); |
|
| 2467 | ||
| 2468 | // Load new parent location |
|
| 2469 | $newParentLocation = $locationService->loadLocation($multimediaLocationId); |
|
| 2470 | ||
| 2471 | // Throws an exception because new parent location is placed below location to move |
|
| 2472 | $locationService->moveSubtree( |
|
| 2473 | $locationToMove, |
|
| 2474 | $newParentLocation |
|
| 2475 | ); |
|
| 2476 | /* END: Use Case */ |
|
| 2477 | } |
|
| 2478 | ||
| 2479 | /** |
|
| 2480 | * Loads properties from all locations in the $location's subtree. |
|