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