|
@@ 2594-2644 (lines=51) @@
|
| 2591 |
|
* @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
| 2592 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2593 |
|
*/ |
| 2594 |
|
public function testMoveSubtreeIncrementsChildCountOfNewParent() |
| 2595 |
|
{ |
| 2596 |
|
$repository = $this->getRepository(); |
| 2597 |
|
$locationService = $repository->getLocationService(); |
| 2598 |
|
|
| 2599 |
|
$newParentLocation = $locationService->loadLocation($this->generateId('location', 56)); |
| 2600 |
|
|
| 2601 |
|
// Load expected properties before move |
| 2602 |
|
$expected = $this->loadLocationProperties($newParentLocation); |
| 2603 |
|
$childCountBefore = $locationService->getLocationChildCount($newParentLocation); |
| 2604 |
|
|
| 2605 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2606 |
|
$demoDesignLocationId = $this->generateId('location', 56); |
| 2607 |
|
/* BEGIN: Use Case */ |
| 2608 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2609 |
|
// an eZ Publish demo installation |
| 2610 |
|
|
| 2611 |
|
// $demoDesignLocationId is the ID of the "Demo Design" page location in an eZ |
| 2612 |
|
// Publish demo installation |
| 2613 |
|
|
| 2614 |
|
// Load the location service |
| 2615 |
|
$locationService = $repository->getLocationService(); |
| 2616 |
|
|
| 2617 |
|
// Load location to move |
| 2618 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2619 |
|
|
| 2620 |
|
// Load new parent location |
| 2621 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2622 |
|
|
| 2623 |
|
// Move location from "Home" to "Demo Design" |
| 2624 |
|
$locationService->moveSubtree( |
| 2625 |
|
$locationToMove, |
| 2626 |
|
$newParentLocation |
| 2627 |
|
); |
| 2628 |
|
|
| 2629 |
|
// Load moved location |
| 2630 |
|
$movedLocation = $locationService->loadLocation($mediaLocationId); |
| 2631 |
|
|
| 2632 |
|
// Reload new parent location |
| 2633 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2634 |
|
/* END: Use Case */ |
| 2635 |
|
|
| 2636 |
|
$this->refreshSearch($repository); |
| 2637 |
|
|
| 2638 |
|
// Load Subtree properties after move |
| 2639 |
|
$actual = $this->loadLocationProperties($newParentLocation); |
| 2640 |
|
$childCountAfter = $locationService->getLocationChildCount($newParentLocation); |
| 2641 |
|
|
| 2642 |
|
$this->assertEquals($expected, $actual); |
| 2643 |
|
$this->assertEquals($childCountBefore + 1, $childCountAfter); |
| 2644 |
|
} |
| 2645 |
|
|
| 2646 |
|
/** |
| 2647 |
|
* Test for the moveSubtree() method. |
|
@@ 2652-2702 (lines=51) @@
|
| 2649 |
|
* @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
| 2650 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2651 |
|
*/ |
| 2652 |
|
public function testMoveSubtreeDecrementsChildCountOfOldParent() |
| 2653 |
|
{ |
| 2654 |
|
$repository = $this->getRepository(); |
| 2655 |
|
$locationService = $repository->getLocationService(); |
| 2656 |
|
|
| 2657 |
|
$oldParentLocation = $locationService->loadLocation($this->generateId('location', 1)); |
| 2658 |
|
|
| 2659 |
|
// Load expected properties before move |
| 2660 |
|
$expected = $this->loadLocationProperties($oldParentLocation); |
| 2661 |
|
$childCountBefore = $locationService->getLocationChildCount($oldParentLocation); |
| 2662 |
|
|
| 2663 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2664 |
|
$demoDesignLocationId = $this->generateId('location', 56); |
| 2665 |
|
/* BEGIN: Use Case */ |
| 2666 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2667 |
|
// an eZ Publish demo installation |
| 2668 |
|
|
| 2669 |
|
// $demoDesignLocationId is the ID of the "Demo Design" page location in an eZ |
| 2670 |
|
// Publish demo installation |
| 2671 |
|
|
| 2672 |
|
// Load the location service |
| 2673 |
|
$locationService = $repository->getLocationService(); |
| 2674 |
|
|
| 2675 |
|
// Load location to move |
| 2676 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2677 |
|
|
| 2678 |
|
// Get the location id of the old parent |
| 2679 |
|
$oldParentLocationId = $locationToMove->parentLocationId; |
| 2680 |
|
|
| 2681 |
|
// Load new parent location |
| 2682 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2683 |
|
|
| 2684 |
|
// Move location from "Home" to "Demo Design" |
| 2685 |
|
$locationService->moveSubtree( |
| 2686 |
|
$locationToMove, |
| 2687 |
|
$newParentLocation |
| 2688 |
|
); |
| 2689 |
|
|
| 2690 |
|
// Reload old parent location |
| 2691 |
|
$oldParentLocation = $locationService->loadLocation($oldParentLocationId); |
| 2692 |
|
/* END: Use Case */ |
| 2693 |
|
|
| 2694 |
|
$this->refreshSearch($repository); |
| 2695 |
|
|
| 2696 |
|
// Load Subtree properties after move |
| 2697 |
|
$actual = $this->loadLocationProperties($oldParentLocation); |
| 2698 |
|
$childCountAfter = $locationService->getLocationChildCount($oldParentLocation); |
| 2699 |
|
|
| 2700 |
|
$this->assertEquals($expected, $actual); |
| 2701 |
|
$this->assertEquals($childCountBefore - 1, $childCountAfter); |
| 2702 |
|
} |
| 2703 |
|
|
| 2704 |
|
/** |
| 2705 |
|
* Test moving invisible (hidden by parent) subtree. |