-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IBX-8418: Delete children drafts when deleting content
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
tests/integration/Core/Repository/ContentService/DeleteContentTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Tests\Integration\Core\Repository\ContentService; | ||
|
||
use Ibexa\Tests\Integration\Core\RepositoryTestCase; | ||
use PHPUnit\Framework\Assert; | ||
|
||
/** | ||
* @covers \Ibexa\Contracts\Core\Repository\ContentService | ||
*/ | ||
final class DeleteContentTest extends RepositoryTestCase | ||
{ | ||
/** | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception | ||
*/ | ||
public function testDeleteContentDeletesChildrenDrafts(): void | ||
{ | ||
$contentService = self::getContentService(); | ||
|
||
$folder = $this->createFolder(['eng-GB' => 'Folder'], 2); | ||
$folderMainLocationId = $folder->getVersionInfo()->getContentInfo()->getMainLocationId(); | ||
Assert::assertIsNumeric($folderMainLocationId); | ||
|
||
$childFolder = $this->createFolder( | ||
['eng-GB' => 'Child folder'], | ||
$folderMainLocationId, | ||
); | ||
$childFolderMainLocationId = $childFolder->getVersionInfo()->getContentInfo()->getMainLocationId(); | ||
Assert::assertIsNumeric($childFolderMainLocationId); | ||
|
||
$secondDepthChildFolder = $this->createFolder( | ||
['eng-GB' => 'Second depth folder'], | ||
$childFolderMainLocationId, | ||
); | ||
$secondDepthChildFolderLocationId = $secondDepthChildFolder | ||
->getVersionInfo() | ||
->getContentInfo() | ||
->getMainLocationId() | ||
; | ||
Assert::assertIsNumeric($secondDepthChildFolderLocationId); | ||
|
||
$draft1 = $this->createFolderDraft(['eng-GB' => 'Folder draft 1'], $folderMainLocationId); | ||
$draft2 = $this->createFolderDraft(['eng-GB' => 'Folder draft 2'], $childFolderMainLocationId); | ||
$draft3 = $this->createFolderDraft(['eng-GB' => 'Folder draft 3'], $childFolderMainLocationId); | ||
$draftSecondDepth = $this->createFolderDraft( | ||
['eng-GB' => 'Folder draft 4'], | ||
$secondDepthChildFolderLocationId, | ||
); | ||
|
||
$contentService->deleteContent($folder->getContentInfo()); | ||
|
||
$contentInfos = $contentService->loadContentInfoList([ | ||
$draft1->getId(), | ||
$draft2->getId(), | ||
$draft3->getId(), | ||
$draftSecondDepth->getId(), | ||
]); | ||
|
||
self::assertEmpty($contentInfos); | ||
} | ||
} |