|
| 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