|
@@ 2543-2593 (lines=51) @@
|
| 2540 |
|
* @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
| 2541 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2542 |
|
*/ |
| 2543 |
|
public function testMoveSubtreeIncrementsChildCountOfNewParent() |
| 2544 |
|
{ |
| 2545 |
|
$repository = $this->getRepository(); |
| 2546 |
|
$locationService = $repository->getLocationService(); |
| 2547 |
|
|
| 2548 |
|
$newParentLocation = $locationService->loadLocation($this->generateId('location', 56)); |
| 2549 |
|
|
| 2550 |
|
// Load expected properties before move |
| 2551 |
|
$expected = $this->loadLocationProperties($newParentLocation); |
| 2552 |
|
$childCountBefore = $locationService->getLocationChildCount($newParentLocation); |
| 2553 |
|
|
| 2554 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2555 |
|
$demoDesignLocationId = $this->generateId('location', 56); |
| 2556 |
|
/* BEGIN: Use Case */ |
| 2557 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2558 |
|
// an eZ Publish demo installation |
| 2559 |
|
|
| 2560 |
|
// $demoDesignLocationId is the ID of the "Demo Design" page location in an eZ |
| 2561 |
|
// Publish demo installation |
| 2562 |
|
|
| 2563 |
|
// Load the location service |
| 2564 |
|
$locationService = $repository->getLocationService(); |
| 2565 |
|
|
| 2566 |
|
// Load location to move |
| 2567 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2568 |
|
|
| 2569 |
|
// Load new parent location |
| 2570 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2571 |
|
|
| 2572 |
|
// Move location from "Home" to "Demo Design" |
| 2573 |
|
$locationService->moveSubtree( |
| 2574 |
|
$locationToMove, |
| 2575 |
|
$newParentLocation |
| 2576 |
|
); |
| 2577 |
|
|
| 2578 |
|
// Load moved location |
| 2579 |
|
$movedLocation = $locationService->loadLocation($mediaLocationId); |
| 2580 |
|
|
| 2581 |
|
// Reload new parent location |
| 2582 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2583 |
|
/* END: Use Case */ |
| 2584 |
|
|
| 2585 |
|
$this->refreshSearch($repository); |
| 2586 |
|
|
| 2587 |
|
// Load Subtree properties after move |
| 2588 |
|
$actual = $this->loadLocationProperties($newParentLocation); |
| 2589 |
|
$childCountAfter = $locationService->getLocationChildCount($newParentLocation); |
| 2590 |
|
|
| 2591 |
|
$this->assertEquals($expected, $actual); |
| 2592 |
|
$this->assertEquals($childCountBefore + 1, $childCountAfter); |
| 2593 |
|
} |
| 2594 |
|
|
| 2595 |
|
/** |
| 2596 |
|
* Test for the moveSubtree() method. |
|
@@ 2601-2651 (lines=51) @@
|
| 2598 |
|
* @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
| 2599 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2600 |
|
*/ |
| 2601 |
|
public function testMoveSubtreeDecrementsChildCountOfOldParent() |
| 2602 |
|
{ |
| 2603 |
|
$repository = $this->getRepository(); |
| 2604 |
|
$locationService = $repository->getLocationService(); |
| 2605 |
|
|
| 2606 |
|
$oldParentLocation = $locationService->loadLocation($this->generateId('location', 1)); |
| 2607 |
|
|
| 2608 |
|
// Load expected properties before move |
| 2609 |
|
$expected = $this->loadLocationProperties($oldParentLocation); |
| 2610 |
|
$childCountBefore = $locationService->getLocationChildCount($oldParentLocation); |
| 2611 |
|
|
| 2612 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2613 |
|
$demoDesignLocationId = $this->generateId('location', 56); |
| 2614 |
|
/* BEGIN: Use Case */ |
| 2615 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2616 |
|
// an eZ Publish demo installation |
| 2617 |
|
|
| 2618 |
|
// $demoDesignLocationId is the ID of the "Demo Design" page location in an eZ |
| 2619 |
|
// Publish demo installation |
| 2620 |
|
|
| 2621 |
|
// Load the location service |
| 2622 |
|
$locationService = $repository->getLocationService(); |
| 2623 |
|
|
| 2624 |
|
// Load location to move |
| 2625 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2626 |
|
|
| 2627 |
|
// Get the location id of the old parent |
| 2628 |
|
$oldParentLocationId = $locationToMove->parentLocationId; |
| 2629 |
|
|
| 2630 |
|
// Load new parent location |
| 2631 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2632 |
|
|
| 2633 |
|
// Move location from "Home" to "Demo Design" |
| 2634 |
|
$locationService->moveSubtree( |
| 2635 |
|
$locationToMove, |
| 2636 |
|
$newParentLocation |
| 2637 |
|
); |
| 2638 |
|
|
| 2639 |
|
// Reload old parent location |
| 2640 |
|
$oldParentLocation = $locationService->loadLocation($oldParentLocationId); |
| 2641 |
|
/* END: Use Case */ |
| 2642 |
|
|
| 2643 |
|
$this->refreshSearch($repository); |
| 2644 |
|
|
| 2645 |
|
// Load Subtree properties after move |
| 2646 |
|
$actual = $this->loadLocationProperties($oldParentLocation); |
| 2647 |
|
$childCountAfter = $locationService->getLocationChildCount($oldParentLocation); |
| 2648 |
|
|
| 2649 |
|
$this->assertEquals($expected, $actual); |
| 2650 |
|
$this->assertEquals($childCountBefore - 1, $childCountAfter); |
| 2651 |
|
} |
| 2652 |
|
|
| 2653 |
|
/** |
| 2654 |
|
* Test moving invisible (hidden by parent) subtree. |