-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
…or location
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?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, $draft1, $draft2, $draft3, $draftSecondDepth] = $this->prepareContentStructure(); | ||
|
||
$contentService->deleteContent($folder->getContentInfo()); | ||
Check failure on line 28 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 28 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 28 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
|
||
$contentInfos = $contentService->loadContentInfoList([ | ||
$draft1->getId(), | ||
Check failure on line 31 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 31 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 31 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
$draft2->getId(), | ||
Check failure on line 32 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 32 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 32 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
$draft3->getId(), | ||
Check failure on line 33 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 33 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 33 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
$draftSecondDepth->getId(), | ||
Check failure on line 34 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 34 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 34 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
]); | ||
|
||
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(); | ||
Check failure on line 50 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 50 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 50 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
Assert::assertIsNumeric($folderMainLocationId); | ||
|
||
$locationToTrash = self::getLocationService()->loadLocation($folderMainLocationId); | ||
Check failure on line 53 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 53 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 53 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
|
||
$trashService->trash($locationToTrash); | ||
|
||
$contentInfos = $contentService->loadContentInfoList([ | ||
$draft1->getId(), | ||
Check failure on line 58 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 58 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 58 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
$draft2->getId(), | ||
Check failure on line 59 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 59 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 59 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
$draft3->getId(), | ||
Check failure on line 60 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.0)
Check failure on line 60 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (7.4)
Check failure on line 60 in tests/integration/Core/Repository/ContentService/DeleteContentTest.php GitHub Actions / Unit tests & SQLite integration tests (8.1)
|
||
$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, | ||
]; | ||
} | ||
} |