Skip to content

Commit

Permalink
Merge branch '1.2' into 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
barw4 committed May 31, 2021
2 parents 97ffd31 + 1a8e058 commit 2b48567
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
43 changes: 43 additions & 0 deletions eZ/Publish/API/Repository/Tests/LocationServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2530,6 +2530,49 @@ public function testCopySubtreeIncrementsChildCountOfNewParent()
$this->assertEquals($childCountBefore + 1, $childCountAfter);
}

/**
* @covers \eZ\Publish\API\Repository\LocationService::copySubtree()
*/
public function testCopySubtreeWithInvisibleChild(): void
{
$repository = $this->getRepository();
$locationService = $repository->getLocationService();

// Hide child Location
$locationService->hideLocation($locationService->loadLocation($this->generateId('location', 53)));

$this->refreshSearch($repository);

$locationToCopy = $locationService->loadLocation($this->generateId('location', 43));

$expected = $this->loadSubtreeProperties($locationToCopy);

$mediaLocationId = $this->generateId('location', 43);
$demoDesignLocationId = $this->generateId('location', 56);
$locationService = $repository->getLocationService();

$locationToCopy = $locationService->loadLocation($mediaLocationId);

$newParentLocation = $locationService->loadLocation($demoDesignLocationId);

$copiedLocation = $locationService->copySubtree(
$locationToCopy,
$newParentLocation
);

$this->refreshSearch($repository);

// Load Subtree properties after copy
$actual = $this->loadSubtreeProperties($copiedLocation);

self::assertEquals(count($expected), count($actual));

foreach ($actual as $key => $properties) {
self::assertEquals($expected[$key]['hidden'], $properties['hidden']);
self::assertEquals($expected[$key]['invisible'], $properties['invisible']);
}
}

/**
* Test for the copySubtree() method.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,10 @@ public function copySubtree($sourceId, $destinationParentId, $newOwnerId = null)
$createStruct->contentId = $contentMap[$child['contentobject_id']];
$parentData = $locationMap[$child['parent_node_id']];
$createStruct->parentId = $parentData['id'];
$createStruct->invisible = $createStruct->hidden || $parentData['hidden'] || $parentData['invisible'];
$createStruct->invisible = $createStruct->invisible
|| $createStruct->hidden
|| $parentData['hidden']
|| $parentData['invisible'];
$pathString = explode('/', $child['path_identification_string']);
$pathString = end($pathString);
$createStruct->pathIdentificationString = strlen($pathString) > 0
Expand Down

0 comments on commit 2b48567

Please sign in to comment.