-
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: Fixed removing orphaned drafts when trashing or deleting it…
…s ancestors (#439) For more details see https://issues.ibexa.co/browse/IBX-8418 and #439 Key changes: * Fixed removing orphaned draft when trashing or deleting its parent or ancestor location
- Loading branch information
Showing
16 changed files
with
284 additions
and
15 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
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
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
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
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
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
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
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
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
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
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
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
111 changes: 111 additions & 0 deletions
111
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,111 @@ | ||
<?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\Contracts\Core\Repository\Values\Content\Content; | ||
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, $draft1, $draft2, $draft3, $draftSecondDepth] = $this->prepareContentStructure(); | ||
|
||
$contentService->deleteContent($folder->getContentInfo()); | ||
|
||
$contentInfos = $contentService->loadContentInfoList([ | ||
$draft1->getId(), | ||
$draft2->getId(), | ||
$draft3->getId(), | ||
$draftSecondDepth->getId(), | ||
]); | ||
|
||
self::assertEmpty($contentInfos); | ||
} | ||
|
||
/** | ||
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\Exception | ||
*/ | ||
public function testTrashLocationDeletesChildrenDrafts(): void | ||
{ | ||
$trashService = self::getTrashService(); | ||
$contentService = self::getContentService(); | ||
|
||
[$folder, $draft1, $draft2, $draft3, $draftSecondDepth] = $this->prepareContentStructure(); | ||
|
||
$folderMainLocationId = $folder->getVersionInfo()->getContentInfo()->getMainLocationId(); | ||
Assert::assertIsNumeric($folderMainLocationId); | ||
|
||
$locationToTrash = self::getLocationService()->loadLocation($folderMainLocationId); | ||
|
||
$trashService->trash($locationToTrash); | ||
|
||
$contentInfos = $contentService->loadContentInfoList([ | ||
$draft1->getId(), | ||
$draft2->getId(), | ||
$draft3->getId(), | ||
$draftSecondDepth->getId(), | ||
]); | ||
|
||
self::assertEmpty($contentInfos); | ||
} | ||
|
||
/** | ||
* @return array<Content> | ||
*/ | ||
private function prepareContentStructure(): array | ||
{ | ||
$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, | ||
); | ||
|
||
return [ | ||
$folder, | ||
$draft1, | ||
$draft2, | ||
$draft3, | ||
$draftSecondDepth, | ||
]; | ||
} | ||
} |
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
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
Oops, something went wrong.