Skip to content

Commit 9c886eb

Browse files
committed
IBX-8418: Delete children drafts when deleting content
1 parent cc08cd6 commit 9c886eb

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

src/lib/Persistence/Legacy/Content/Handler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ public function deleteContent($contentId)
653653
$this->removeRawContent($contentId);
654654
} else {
655655
foreach ($contentLocations as $locationId) {
656+
$this->treeHandler->deleteChildrenDrafts($locationId);
656657
$this->treeHandler->removeSubtree($locationId);
657658
}
658659
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Tests\Integration\Core\Repository\ContentService;
10+
11+
use Ibexa\Tests\Integration\Core\RepositoryTestCase;
12+
use PHPUnit\Framework\Assert;
13+
14+
/**
15+
* @covers \Ibexa\Contracts\Core\Repository\ContentService
16+
*/
17+
final class DeleteContentTest extends RepositoryTestCase
18+
{
19+
/**
20+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception
21+
*/
22+
public function testDeleteContentDeletesChildrenDrafts(): void
23+
{
24+
$contentService = self::getContentService();
25+
26+
$folder = $this->createFolder(['eng-GB' => 'Folder'], 2);
27+
$folderMainLocationId = $folder->getVersionInfo()->getContentInfo()->getMainLocationId();
28+
Assert::assertIsNumeric($folderMainLocationId);
29+
30+
$childFolder = $this->createFolder(
31+
['eng-GB' => 'Child folder'],
32+
$folderMainLocationId,
33+
);
34+
$childFolderMainLocationId = $childFolder->getVersionInfo()->getContentInfo()->getMainLocationId();
35+
Assert::assertIsNumeric($childFolderMainLocationId);
36+
37+
$secondDepthChildFolder = $this->createFolder(
38+
['eng-GB' => 'Second depth folder'],
39+
$childFolderMainLocationId,
40+
);
41+
$secondDepthChildFolderLocationId = $secondDepthChildFolder
42+
->getVersionInfo()
43+
->getContentInfo()
44+
->getMainLocationId()
45+
;
46+
Assert::assertIsNumeric($secondDepthChildFolderLocationId);
47+
48+
$draft1 = $this->createFolderDraft(['eng-GB' => 'Folder draft 1'], $folderMainLocationId);
49+
$draft2 = $this->createFolderDraft(['eng-GB' => 'Folder draft 2'], $childFolderMainLocationId);
50+
$draft3 = $this->createFolderDraft(['eng-GB' => 'Folder draft 3'], $childFolderMainLocationId);
51+
$draftSecondDepth = $this->createFolderDraft(
52+
['eng-GB' => 'Folder draft 4'],
53+
$secondDepthChildFolderLocationId,
54+
);
55+
56+
$contentService->deleteContent($folder->getContentInfo());
57+
58+
$contentInfos = $contentService->loadContentInfoList([
59+
$draft1->getId(),
60+
$draft2->getId(),
61+
$draft3->getId(),
62+
$draftSecondDepth->getId(),
63+
]);
64+
65+
self::assertEmpty($contentInfos);
66+
}
67+
}

0 commit comments

Comments
 (0)