|
@@ 2028-2078 (lines=51) @@
|
| 2025 |
|
* @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
| 2026 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2027 |
|
*/ |
| 2028 |
|
public function testMoveSubtreeIncrementsChildCountOfNewParent() |
| 2029 |
|
{ |
| 2030 |
|
$repository = $this->getRepository(); |
| 2031 |
|
$locationService = $repository->getLocationService(); |
| 2032 |
|
|
| 2033 |
|
$newParentLocation = $locationService->loadLocation($this->generateId('location', 56)); |
| 2034 |
|
|
| 2035 |
|
// Load expected properties before move |
| 2036 |
|
$expected = $this->loadLocationProperties($newParentLocation); |
| 2037 |
|
$childCountBefore = $locationService->getLocationChildCount($newParentLocation); |
| 2038 |
|
|
| 2039 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2040 |
|
$demoDesignLocationId = $this->generateId('location', 56); |
| 2041 |
|
/* BEGIN: Use Case */ |
| 2042 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2043 |
|
// an eZ Publish demo installation |
| 2044 |
|
|
| 2045 |
|
// $demoDesignLocationId is the ID of the "Demo Design" page location in an eZ |
| 2046 |
|
// Publish demo installation |
| 2047 |
|
|
| 2048 |
|
// Load the location service |
| 2049 |
|
$locationService = $repository->getLocationService(); |
| 2050 |
|
|
| 2051 |
|
// Load location to move |
| 2052 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2053 |
|
|
| 2054 |
|
// Load new parent location |
| 2055 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2056 |
|
|
| 2057 |
|
// Move location from "Home" to "Demo Design" |
| 2058 |
|
$locationService->moveSubtree( |
| 2059 |
|
$locationToMove, |
| 2060 |
|
$newParentLocation |
| 2061 |
|
); |
| 2062 |
|
|
| 2063 |
|
// Load moved location |
| 2064 |
|
$movedLocation = $locationService->loadLocation($mediaLocationId); |
| 2065 |
|
|
| 2066 |
|
// Reload new parent location |
| 2067 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2068 |
|
/* END: Use Case */ |
| 2069 |
|
|
| 2070 |
|
$this->refreshSearch($repository); |
| 2071 |
|
|
| 2072 |
|
// Load Subtree properties after move |
| 2073 |
|
$actual = $this->loadLocationProperties($newParentLocation); |
| 2074 |
|
$childCountAfter = $locationService->getLocationChildCount($newParentLocation); |
| 2075 |
|
|
| 2076 |
|
$this->assertEquals($expected, $actual); |
| 2077 |
|
$this->assertEquals($childCountBefore + 1, $childCountAfter); |
| 2078 |
|
} |
| 2079 |
|
|
| 2080 |
|
/** |
| 2081 |
|
* Test for the moveSubtree() method. |
|
@@ 2086-2136 (lines=51) @@
|
| 2083 |
|
* @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
| 2084 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2085 |
|
*/ |
| 2086 |
|
public function testMoveSubtreeDecrementsChildCountOfOldParent() |
| 2087 |
|
{ |
| 2088 |
|
$repository = $this->getRepository(); |
| 2089 |
|
$locationService = $repository->getLocationService(); |
| 2090 |
|
|
| 2091 |
|
$oldParentLocation = $locationService->loadLocation($this->generateId('location', 1)); |
| 2092 |
|
|
| 2093 |
|
// Load expected properties before move |
| 2094 |
|
$expected = $this->loadLocationProperties($oldParentLocation); |
| 2095 |
|
$childCountBefore = $locationService->getLocationChildCount($oldParentLocation); |
| 2096 |
|
|
| 2097 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2098 |
|
$demoDesignLocationId = $this->generateId('location', 56); |
| 2099 |
|
/* BEGIN: Use Case */ |
| 2100 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2101 |
|
// an eZ Publish demo installation |
| 2102 |
|
|
| 2103 |
|
// $demoDesignLocationId is the ID of the "Demo Design" page location in an eZ |
| 2104 |
|
// Publish demo installation |
| 2105 |
|
|
| 2106 |
|
// Load the location service |
| 2107 |
|
$locationService = $repository->getLocationService(); |
| 2108 |
|
|
| 2109 |
|
// Load location to move |
| 2110 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2111 |
|
|
| 2112 |
|
// Get the location id of the old parent |
| 2113 |
|
$oldParentLocationId = $locationToMove->parentLocationId; |
| 2114 |
|
|
| 2115 |
|
// Load new parent location |
| 2116 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2117 |
|
|
| 2118 |
|
// Move location from "Home" to "Demo Design" |
| 2119 |
|
$locationService->moveSubtree( |
| 2120 |
|
$locationToMove, |
| 2121 |
|
$newParentLocation |
| 2122 |
|
); |
| 2123 |
|
|
| 2124 |
|
// Reload old parent location |
| 2125 |
|
$oldParentLocation = $locationService->loadLocation($oldParentLocationId); |
| 2126 |
|
/* END: Use Case */ |
| 2127 |
|
|
| 2128 |
|
$this->refreshSearch($repository); |
| 2129 |
|
|
| 2130 |
|
// Load Subtree properties after move |
| 2131 |
|
$actual = $this->loadLocationProperties($oldParentLocation); |
| 2132 |
|
$childCountAfter = $locationService->getLocationChildCount($oldParentLocation); |
| 2133 |
|
|
| 2134 |
|
$this->assertEquals($expected, $actual); |
| 2135 |
|
$this->assertEquals($childCountBefore - 1, $childCountAfter); |
| 2136 |
|
} |
| 2137 |
|
|
| 2138 |
|
/** |
| 2139 |
|
* Test for the moveSubtree() method. |