|
@@ 1335-1354 (lines=20) @@
|
| 1332 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
| 1333 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1334 |
|
*/ |
| 1335 |
|
public function testUpdateLocationThrowsInvalidArgumentException() |
| 1336 |
|
{ |
| 1337 |
|
$repository = $this->getRepository(); |
| 1338 |
|
|
| 1339 |
|
$locationId = $this->generateId('location', 5); |
| 1340 |
|
/* BEGIN: Use Case */ |
| 1341 |
|
// $locationId and remoteId is the IDs of an existing, but not the same, location |
| 1342 |
|
$locationService = $repository->getLocationService(); |
| 1343 |
|
|
| 1344 |
|
$originalLocation = $locationService->loadLocation($locationId); |
| 1345 |
|
|
| 1346 |
|
$updateStruct = $locationService->newLocationUpdateStruct(); |
| 1347 |
|
|
| 1348 |
|
// Remote ID of an existing location with a different locationId |
| 1349 |
|
$updateStruct->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
| 1350 |
|
|
| 1351 |
|
// Throws exception, since remote ID is already taken |
| 1352 |
|
$locationService->updateLocation($originalLocation, $updateStruct); |
| 1353 |
|
/* END: Use Case */ |
| 1354 |
|
} |
| 1355 |
|
|
| 1356 |
|
/** |
| 1357 |
|
* Test for the updateLocation() method. |
|
@@ 1364-1383 (lines=20) @@
|
| 1361 |
|
* @dataProvider dataProviderForOutOfRangeLocationPriority |
| 1362 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1363 |
|
*/ |
| 1364 |
|
public function testUpdateLocationThrowsInvalidArgumentExceptionPriorityIsOutOfRange($priority) |
| 1365 |
|
{ |
| 1366 |
|
$repository = $this->getRepository(); |
| 1367 |
|
|
| 1368 |
|
$locationId = $this->generateId('location', 5); |
| 1369 |
|
/* BEGIN: Use Case */ |
| 1370 |
|
// $locationId and remoteId is the IDs of an existing, but not the same, location |
| 1371 |
|
$locationService = $repository->getLocationService(); |
| 1372 |
|
|
| 1373 |
|
$originalLocation = $locationService->loadLocation($locationId); |
| 1374 |
|
|
| 1375 |
|
$updateStruct = $locationService->newLocationUpdateStruct(); |
| 1376 |
|
|
| 1377 |
|
// Priority value is out of range |
| 1378 |
|
$updateStruct->priority = $priority; |
| 1379 |
|
|
| 1380 |
|
// Throws exception, since remote ID is already taken |
| 1381 |
|
$locationService->updateLocation($originalLocation, $updateStruct); |
| 1382 |
|
/* END: Use Case */ |
| 1383 |
|
} |
| 1384 |
|
|
| 1385 |
|
/** |
| 1386 |
|
* Test for the updateLocation() method. |
|
@@ 2345-2371 (lines=27) @@
|
| 2342 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 2343 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
| 2344 |
|
*/ |
| 2345 |
|
public function testCopySubtreeThrowsInvalidArgumentException() |
| 2346 |
|
{ |
| 2347 |
|
$repository = $this->getRepository(); |
| 2348 |
|
|
| 2349 |
|
$communityLocationId = $this->generateId('location', 5); |
| 2350 |
|
/* BEGIN: Use Case */ |
| 2351 |
|
// $communityLocationId is the ID of the "Community" page location in |
| 2352 |
|
// an eZ Publish demo installation |
| 2353 |
|
|
| 2354 |
|
// Load the location service |
| 2355 |
|
$locationService = $repository->getLocationService(); |
| 2356 |
|
|
| 2357 |
|
// Load location to copy |
| 2358 |
|
$locationToCopy = $locationService->loadLocation($communityLocationId); |
| 2359 |
|
|
| 2360 |
|
// Use a child as new parent |
| 2361 |
|
$childLocations = $locationService->loadLocationChildren($locationToCopy)->locations; |
| 2362 |
|
$newParentLocation = end($childLocations); |
| 2363 |
|
|
| 2364 |
|
// This call will fail with an "InvalidArgumentException", because the |
| 2365 |
|
// new parent is a child location of the subtree to copy. |
| 2366 |
|
$locationService->copySubtree( |
| 2367 |
|
$locationToCopy, |
| 2368 |
|
$newParentLocation |
| 2369 |
|
); |
| 2370 |
|
/* END: Use Case */ |
| 2371 |
|
} |
| 2372 |
|
|
| 2373 |
|
/** |
| 2374 |
|
* Test for the moveSubtree() method. |
|
@@ 2765-2793 (lines=29) @@
|
| 2762 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2763 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 2764 |
|
*/ |
| 2765 |
|
public function testMoveSubtreeThrowsInvalidArgumentException() |
| 2766 |
|
{ |
| 2767 |
|
$repository = $this->getRepository(); |
| 2768 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2769 |
|
$multimediaLocationId = $this->generateId('location', 53); |
| 2770 |
|
|
| 2771 |
|
/* BEGIN: Use Case */ |
| 2772 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2773 |
|
// an eZ Publish demo installation |
| 2774 |
|
|
| 2775 |
|
// $multimediaLocationId is the ID of the "Multimedia" page location in an eZ |
| 2776 |
|
// Publish demo installation |
| 2777 |
|
|
| 2778 |
|
// Load the location service |
| 2779 |
|
$locationService = $repository->getLocationService(); |
| 2780 |
|
|
| 2781 |
|
// Load location to move |
| 2782 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2783 |
|
|
| 2784 |
|
// Load new parent location |
| 2785 |
|
$newParentLocation = $locationService->loadLocation($multimediaLocationId); |
| 2786 |
|
|
| 2787 |
|
// Throws an exception because new parent location is placed below location to move |
| 2788 |
|
$locationService->moveSubtree( |
| 2789 |
|
$locationToMove, |
| 2790 |
|
$newParentLocation |
| 2791 |
|
); |
| 2792 |
|
/* END: Use Case */ |
| 2793 |
|
} |
| 2794 |
|
|
| 2795 |
|
/** |
| 2796 |
|
* Test that Legacy ezcontentobject_tree.path_identification_string field is correctly updated |