|
@@ 1290-1309 (lines=20) @@
|
| 1287 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testLoadLocation |
| 1288 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1289 |
|
*/ |
| 1290 |
|
public function testUpdateLocationThrowsInvalidArgumentException() |
| 1291 |
|
{ |
| 1292 |
|
$repository = $this->getRepository(); |
| 1293 |
|
|
| 1294 |
|
$locationId = $this->generateId('location', 5); |
| 1295 |
|
/* BEGIN: Use Case */ |
| 1296 |
|
// $locationId and remoteId is the IDs of an existing, but not the same, location |
| 1297 |
|
$locationService = $repository->getLocationService(); |
| 1298 |
|
|
| 1299 |
|
$originalLocation = $locationService->loadLocation($locationId); |
| 1300 |
|
|
| 1301 |
|
$updateStruct = $locationService->newLocationUpdateStruct(); |
| 1302 |
|
|
| 1303 |
|
// Remote ID of an existing location with a different locationId |
| 1304 |
|
$updateStruct->remoteId = 'f3e90596361e31d496d4026eb624c983'; |
| 1305 |
|
|
| 1306 |
|
// Throws exception, since remote ID is already taken |
| 1307 |
|
$locationService->updateLocation($originalLocation, $updateStruct); |
| 1308 |
|
/* END: Use Case */ |
| 1309 |
|
} |
| 1310 |
|
|
| 1311 |
|
/** |
| 1312 |
|
* Test for the updateLocation() method. |
|
@@ 1319-1338 (lines=20) @@
|
| 1316 |
|
* @dataProvider dataProviderForOutOfRangeLocationPriority |
| 1317 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 1318 |
|
*/ |
| 1319 |
|
public function testUpdateLocationThrowsInvalidArgumentExceptionPriorityIsOutOfRange($priority) |
| 1320 |
|
{ |
| 1321 |
|
$repository = $this->getRepository(); |
| 1322 |
|
|
| 1323 |
|
$locationId = $this->generateId('location', 5); |
| 1324 |
|
/* BEGIN: Use Case */ |
| 1325 |
|
// $locationId and remoteId is the IDs of an existing, but not the same, location |
| 1326 |
|
$locationService = $repository->getLocationService(); |
| 1327 |
|
|
| 1328 |
|
$originalLocation = $locationService->loadLocation($locationId); |
| 1329 |
|
|
| 1330 |
|
$updateStruct = $locationService->newLocationUpdateStruct(); |
| 1331 |
|
|
| 1332 |
|
// Priority value is out of range |
| 1333 |
|
$updateStruct->priority = $priority; |
| 1334 |
|
|
| 1335 |
|
// Throws exception, since remote ID is already taken |
| 1336 |
|
$locationService->updateLocation($originalLocation, $updateStruct); |
| 1337 |
|
/* END: Use Case */ |
| 1338 |
|
} |
| 1339 |
|
|
| 1340 |
|
/** |
| 1341 |
|
* Test for the updateLocation() method. |
|
@@ 2300-2326 (lines=27) @@
|
| 2297 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 2298 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testCopySubtree |
| 2299 |
|
*/ |
| 2300 |
|
public function testCopySubtreeThrowsInvalidArgumentException() |
| 2301 |
|
{ |
| 2302 |
|
$repository = $this->getRepository(); |
| 2303 |
|
|
| 2304 |
|
$communityLocationId = $this->generateId('location', 5); |
| 2305 |
|
/* BEGIN: Use Case */ |
| 2306 |
|
// $communityLocationId is the ID of the "Community" page location in |
| 2307 |
|
// an eZ Publish demo installation |
| 2308 |
|
|
| 2309 |
|
// Load the location service |
| 2310 |
|
$locationService = $repository->getLocationService(); |
| 2311 |
|
|
| 2312 |
|
// Load location to copy |
| 2313 |
|
$locationToCopy = $locationService->loadLocation($communityLocationId); |
| 2314 |
|
|
| 2315 |
|
// Use a child as new parent |
| 2316 |
|
$childLocations = $locationService->loadLocationChildren($locationToCopy)->locations; |
| 2317 |
|
$newParentLocation = end($childLocations); |
| 2318 |
|
|
| 2319 |
|
// This call will fail with an "InvalidArgumentException", because the |
| 2320 |
|
// new parent is a child location of the subtree to copy. |
| 2321 |
|
$locationService->copySubtree( |
| 2322 |
|
$locationToCopy, |
| 2323 |
|
$newParentLocation |
| 2324 |
|
); |
| 2325 |
|
/* END: Use Case */ |
| 2326 |
|
} |
| 2327 |
|
|
| 2328 |
|
/** |
| 2329 |
|
* Test for the moveSubtree() method. |
|
@@ 2720-2748 (lines=29) @@
|
| 2717 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2718 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 2719 |
|
*/ |
| 2720 |
|
public function testMoveSubtreeThrowsInvalidArgumentException() |
| 2721 |
|
{ |
| 2722 |
|
$repository = $this->getRepository(); |
| 2723 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2724 |
|
$multimediaLocationId = $this->generateId('location', 53); |
| 2725 |
|
|
| 2726 |
|
/* BEGIN: Use Case */ |
| 2727 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2728 |
|
// an eZ Publish demo installation |
| 2729 |
|
|
| 2730 |
|
// $multimediaLocationId is the ID of the "Multimedia" page location in an eZ |
| 2731 |
|
// Publish demo installation |
| 2732 |
|
|
| 2733 |
|
// Load the location service |
| 2734 |
|
$locationService = $repository->getLocationService(); |
| 2735 |
|
|
| 2736 |
|
// Load location to move |
| 2737 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2738 |
|
|
| 2739 |
|
// Load new parent location |
| 2740 |
|
$newParentLocation = $locationService->loadLocation($multimediaLocationId); |
| 2741 |
|
|
| 2742 |
|
// Throws an exception because new parent location is placed below location to move |
| 2743 |
|
$locationService->moveSubtree( |
| 2744 |
|
$locationToMove, |
| 2745 |
|
$newParentLocation |
| 2746 |
|
); |
| 2747 |
|
/* END: Use Case */ |
| 2748 |
|
} |
| 2749 |
|
|
| 2750 |
|
/** |
| 2751 |
|
* Test that Legacy ezcontentobject_tree.path_identification_string field is correctly updated |