|
@@ 1375-1394 (lines=20) @@
|
| 1372 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
| 1373 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1374 |
|
*/ |
| 1375 |
|
public function testUpdateLocationThrowsInvalidArgumentException() |
| 1376 |
|
{ |
| 1377 |
|
$repository = $this->getRepository(); |
| 1378 |
|
|
| 1379 |
|
$locationId = $this->generateId('location', 5); |
| 1380 |
|
/* BEGIN: Use Case */ |
| 1381 |
|
// $locationId and remoteId is the IDs of an existing, but not the same, location |
| 1382 |
|
$locationService = $repository->getLocationService(); |
| 1383 |
|
|
| 1384 |
|
$originalLocation = $locationService->loadLocation($locationId); |
| 1385 |
|
|
| 1386 |
|
$updateStruct = $locationService->newLocationUpdateStruct(); |
| 1387 |
|
|
| 1388 |
|
// Remote ID of an existing location with a different locationId |
| 1389 |
|
$updateStruct->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
| 1390 |
|
|
| 1391 |
|
// Throws exception, since remote ID is already taken |
| 1392 |
|
$locationService->updateLocation($originalLocation, $updateStruct); |
| 1393 |
|
/* END: Use Case */ |
| 1394 |
|
} |
| 1395 |
|
|
| 1396 |
|
/** |
| 1397 |
|
* Test for the updateLocation() method. |
|
@@ 1404-1423 (lines=20) @@
|
| 1401 |
|
* @dataProvider dataProviderForOutOfRangeLocationPriority |
| 1402 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1403 |
|
*/ |
| 1404 |
|
public function testUpdateLocationThrowsInvalidArgumentExceptionPriorityIsOutOfRange($priority) |
| 1405 |
|
{ |
| 1406 |
|
$repository = $this->getRepository(); |
| 1407 |
|
|
| 1408 |
|
$locationId = $this->generateId('location', 5); |
| 1409 |
|
/* BEGIN: Use Case */ |
| 1410 |
|
// $locationId and remoteId is the IDs of an existing, but not the same, location |
| 1411 |
|
$locationService = $repository->getLocationService(); |
| 1412 |
|
|
| 1413 |
|
$originalLocation = $locationService->loadLocation($locationId); |
| 1414 |
|
|
| 1415 |
|
$updateStruct = $locationService->newLocationUpdateStruct(); |
| 1416 |
|
|
| 1417 |
|
// Priority value is out of range |
| 1418 |
|
$updateStruct->priority = $priority; |
| 1419 |
|
|
| 1420 |
|
// Throws exception, since remote ID is already taken |
| 1421 |
|
$locationService->updateLocation($originalLocation, $updateStruct); |
| 1422 |
|
/* END: Use Case */ |
| 1423 |
|
} |
| 1424 |
|
|
| 1425 |
|
/** |
| 1426 |
|
* Test for the updateLocation() method. |
|
@@ 2496-2522 (lines=27) @@
|
| 2493 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 2494 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
| 2495 |
|
*/ |
| 2496 |
|
public function testCopySubtreeThrowsInvalidArgumentException() |
| 2497 |
|
{ |
| 2498 |
|
$repository = $this->getRepository(); |
| 2499 |
|
|
| 2500 |
|
$communityLocationId = $this->generateId('location', 5); |
| 2501 |
|
/* BEGIN: Use Case */ |
| 2502 |
|
// $communityLocationId is the ID of the "Community" page location in |
| 2503 |
|
// an eZ Publish demo installation |
| 2504 |
|
|
| 2505 |
|
// Load the location service |
| 2506 |
|
$locationService = $repository->getLocationService(); |
| 2507 |
|
|
| 2508 |
|
// Load location to copy |
| 2509 |
|
$locationToCopy = $locationService->loadLocation($communityLocationId); |
| 2510 |
|
|
| 2511 |
|
// Use a child as new parent |
| 2512 |
|
$childLocations = $locationService->loadLocationChildren($locationToCopy)->locations; |
| 2513 |
|
$newParentLocation = end($childLocations); |
| 2514 |
|
|
| 2515 |
|
// This call will fail with an "InvalidArgumentException", because the |
| 2516 |
|
// new parent is a child location of the subtree to copy. |
| 2517 |
|
$locationService->copySubtree( |
| 2518 |
|
$locationToCopy, |
| 2519 |
|
$newParentLocation |
| 2520 |
|
); |
| 2521 |
|
/* END: Use Case */ |
| 2522 |
|
} |
| 2523 |
|
|
| 2524 |
|
/** |
| 2525 |
|
* Test for the moveSubtree() method. |
|
@@ 2916-2944 (lines=29) @@
|
| 2913 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2914 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 2915 |
|
*/ |
| 2916 |
|
public function testMoveSubtreeThrowsInvalidArgumentException() |
| 2917 |
|
{ |
| 2918 |
|
$repository = $this->getRepository(); |
| 2919 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2920 |
|
$multimediaLocationId = $this->generateId('location', 53); |
| 2921 |
|
|
| 2922 |
|
/* BEGIN: Use Case */ |
| 2923 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2924 |
|
// an eZ Publish demo installation |
| 2925 |
|
|
| 2926 |
|
// $multimediaLocationId is the ID of the "Multimedia" page location in an eZ |
| 2927 |
|
// Publish demo installation |
| 2928 |
|
|
| 2929 |
|
// Load the location service |
| 2930 |
|
$locationService = $repository->getLocationService(); |
| 2931 |
|
|
| 2932 |
|
// Load location to move |
| 2933 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2934 |
|
|
| 2935 |
|
// Load new parent location |
| 2936 |
|
$newParentLocation = $locationService->loadLocation($multimediaLocationId); |
| 2937 |
|
|
| 2938 |
|
// Throws an exception because new parent location is placed below location to move |
| 2939 |
|
$locationService->moveSubtree( |
| 2940 |
|
$locationToMove, |
| 2941 |
|
$newParentLocation |
| 2942 |
|
); |
| 2943 |
|
/* END: Use Case */ |
| 2944 |
|
} |
| 2945 |
|
|
| 2946 |
|
/** |
| 2947 |
|
* Test that Legacy ezcontentobject_tree.path_identification_string field is correctly updated |