|
@@ 1969-2019 (lines=51) @@
|
| 1966 |
|
* @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
| 1967 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 1968 |
|
*/ |
| 1969 |
|
public function testMoveSubtreeIncrementsChildCountOfNewParent() |
| 1970 |
|
{ |
| 1971 |
|
$repository = $this->getRepository(); |
| 1972 |
|
$locationService = $repository->getLocationService(); |
| 1973 |
|
|
| 1974 |
|
$newParentLocation = $locationService->loadLocation($this->generateId('location', 56)); |
| 1975 |
|
|
| 1976 |
|
// Load expected properties before move |
| 1977 |
|
$expected = $this->loadLocationProperties($newParentLocation); |
| 1978 |
|
$childCountBefore = $locationService->getLocationChildCount($newParentLocation); |
| 1979 |
|
|
| 1980 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 1981 |
|
$demoDesignLocationId = $this->generateId('location', 56); |
| 1982 |
|
/* BEGIN: Use Case */ |
| 1983 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 1984 |
|
// an eZ Publish demo installation |
| 1985 |
|
|
| 1986 |
|
// $demoDesignLocationId is the ID of the "Demo Design" page location in an eZ |
| 1987 |
|
// Publish demo installation |
| 1988 |
|
|
| 1989 |
|
// Load the location service |
| 1990 |
|
$locationService = $repository->getLocationService(); |
| 1991 |
|
|
| 1992 |
|
// Load location to move |
| 1993 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 1994 |
|
|
| 1995 |
|
// Load new parent location |
| 1996 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 1997 |
|
|
| 1998 |
|
// Move location from "Home" to "Demo Design" |
| 1999 |
|
$locationService->moveSubtree( |
| 2000 |
|
$locationToMove, |
| 2001 |
|
$newParentLocation |
| 2002 |
|
); |
| 2003 |
|
|
| 2004 |
|
// Load moved location |
| 2005 |
|
$movedLocation = $locationService->loadLocation($mediaLocationId); |
| 2006 |
|
|
| 2007 |
|
// Reload new parent location |
| 2008 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2009 |
|
/* END: Use Case */ |
| 2010 |
|
|
| 2011 |
|
$this->refreshSearch($repository); |
| 2012 |
|
|
| 2013 |
|
// Load Subtree properties after move |
| 2014 |
|
$actual = $this->loadLocationProperties($newParentLocation); |
| 2015 |
|
$childCountAfter = $locationService->getLocationChildCount($newParentLocation); |
| 2016 |
|
|
| 2017 |
|
$this->assertEquals($expected, $actual); |
| 2018 |
|
$this->assertEquals($childCountBefore + 1, $childCountAfter); |
| 2019 |
|
} |
| 2020 |
|
|
| 2021 |
|
/** |
| 2022 |
|
* Test for the moveSubtree() method. |
|
@@ 2027-2077 (lines=51) @@
|
| 2024 |
|
* @see \eZ\Publish\API\Repository\LocationService::moveSubtree() |
| 2025 |
|
* @depends eZ\Publish\API\Repository\Tests\LocationServiceTest::testMoveSubtree |
| 2026 |
|
*/ |
| 2027 |
|
public function testMoveSubtreeDecrementsChildCountOfOldParent() |
| 2028 |
|
{ |
| 2029 |
|
$repository = $this->getRepository(); |
| 2030 |
|
$locationService = $repository->getLocationService(); |
| 2031 |
|
|
| 2032 |
|
$oldParentLocation = $locationService->loadLocation($this->generateId('location', 1)); |
| 2033 |
|
|
| 2034 |
|
// Load expected properties before move |
| 2035 |
|
$expected = $this->loadLocationProperties($oldParentLocation); |
| 2036 |
|
$childCountBefore = $locationService->getLocationChildCount($oldParentLocation); |
| 2037 |
|
|
| 2038 |
|
$mediaLocationId = $this->generateId('location', 43); |
| 2039 |
|
$demoDesignLocationId = $this->generateId('location', 56); |
| 2040 |
|
/* BEGIN: Use Case */ |
| 2041 |
|
// $mediaLocationId is the ID of the "Media" page location in |
| 2042 |
|
// an eZ Publish demo installation |
| 2043 |
|
|
| 2044 |
|
// $demoDesignLocationId is the ID of the "Demo Design" page location in an eZ |
| 2045 |
|
// Publish demo installation |
| 2046 |
|
|
| 2047 |
|
// Load the location service |
| 2048 |
|
$locationService = $repository->getLocationService(); |
| 2049 |
|
|
| 2050 |
|
// Load location to move |
| 2051 |
|
$locationToMove = $locationService->loadLocation($mediaLocationId); |
| 2052 |
|
|
| 2053 |
|
// Get the location id of the old parent |
| 2054 |
|
$oldParentLocationId = $locationToMove->parentLocationId; |
| 2055 |
|
|
| 2056 |
|
// Load new parent location |
| 2057 |
|
$newParentLocation = $locationService->loadLocation($demoDesignLocationId); |
| 2058 |
|
|
| 2059 |
|
// Move location from "Home" to "Demo Design" |
| 2060 |
|
$locationService->moveSubtree( |
| 2061 |
|
$locationToMove, |
| 2062 |
|
$newParentLocation |
| 2063 |
|
); |
| 2064 |
|
|
| 2065 |
|
// Reload old parent location |
| 2066 |
|
$oldParentLocation = $locationService->loadLocation($oldParentLocationId); |
| 2067 |
|
/* END: Use Case */ |
| 2068 |
|
|
| 2069 |
|
$this->refreshSearch($repository); |
| 2070 |
|
|
| 2071 |
|
// Load Subtree properties after move |
| 2072 |
|
$actual = $this->loadLocationProperties($oldParentLocation); |
| 2073 |
|
$childCountAfter = $locationService->getLocationChildCount($oldParentLocation); |
| 2074 |
|
|
| 2075 |
|
$this->assertEquals($expected, $actual); |
| 2076 |
|
$this->assertEquals($childCountBefore - 1, $childCountAfter); |
| 2077 |
|
} |
| 2078 |
|
|
| 2079 |
|
/** |
| 2080 |
|
* Test for the moveSubtree() method. |