-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
184 additions
and
104 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
45 changes: 45 additions & 0 deletions
45
tests/integration/Core/Repository/ContentService/LoadVersionInfoTest.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,45 @@ | ||
<?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; | ||
|
||
/** | ||
* @covers \eZ\Publish\API\Repository\ContentService | ||
*/ | ||
final class LoadVersionInfoTest extends RepositoryTestCase | ||
{ | ||
/** | ||
* @throws \eZ\Publish\API\Repository\Exceptions\Exception | ||
*/ | ||
public function testLoadVersionInfoListByContentInfo(): void | ||
{ | ||
$contentService = self::getContentService(); | ||
|
||
$folder1 = $this->createFolder(['eng-GB' => 'Folder1'], 2); | ||
$folder2 = $this->createFolder(['eng-GB' => 'Folder2'], 2); | ||
|
||
$versionInfoList = $contentService->loadVersionInfoListByContentInfo( | ||
[ | ||
$folder1->getVersionInfo()->getContentInfo(), | ||
$folder2->getVersionInfo()->getContentInfo(), | ||
] | ||
); | ||
|
||
self::assertCount(2, $versionInfoList); | ||
|
||
foreach ($versionInfoList as $versionInfo) { | ||
$loadedVersionInfo = $contentService->loadVersionInfo( | ||
$versionInfo->getContentInfo(), | ||
$versionInfo->versionNo | ||
); | ||
self::assertEquals($loadedVersionInfo, $versionInfo); | ||
} | ||
} | ||
} |
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,73 @@ | ||
<?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; | ||
|
||
use eZ\Publish\API\Repository\Values\Content\Content; | ||
use Ibexa\Contracts\Core\Test\IbexaKernelTestCase; | ||
use InvalidArgumentException; | ||
|
||
abstract class RepositoryTestCase extends IbexaKernelTestCase | ||
{ | ||
public const CONTENT_TREE_ROOT_ID = 2; | ||
|
||
private const CONTENT_TYPE_FOLDER_IDENTIFIER = 'folder'; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
self::loadSchema(); | ||
self::loadFixtures(); | ||
|
||
self::setAdministratorUser(); | ||
} | ||
|
||
/** | ||
* @param array<string, string> $names | ||
* | ||
* @throws \eZ\Publish\API\Repository\Exceptions\Exception | ||
*/ | ||
public function createFolder(array $names, int $parentLocationId = self::CONTENT_TREE_ROOT_ID): Content | ||
{ | ||
$contentService = self::getContentService(); | ||
$draft = $this->createFolderDraft($names, $parentLocationId); | ||
|
||
return $contentService->publishVersion($draft->getVersionInfo()); | ||
} | ||
|
||
/** | ||
* @param array<string, string> $names | ||
* | ||
* @throws \eZ\Publish\API\Repository\Exceptions\Exception | ||
*/ | ||
public function createFolderDraft(array $names, int $parentLocationId = self::CONTENT_TREE_ROOT_ID): Content | ||
{ | ||
if (empty($names)) { | ||
throw new InvalidArgumentException(__METHOD__ . ' requires $names to be not empty'); | ||
} | ||
|
||
$contentService = self::getContentService(); | ||
$contentTypeService = self::getContentTypeService(); | ||
$locationService = self::getLocationService(); | ||
|
||
$folderType = $contentTypeService->loadContentTypeByIdentifier(self::CONTENT_TYPE_FOLDER_IDENTIFIER); | ||
$mainLanguageCode = array_keys($names)[0]; | ||
$contentCreateStruct = $contentService->newContentCreateStruct($folderType, $mainLanguageCode); | ||
foreach ($names as $languageCode => $name) { | ||
$contentCreateStruct->setField('name', $name, $languageCode); | ||
} | ||
|
||
return $contentService->createContent( | ||
$contentCreateStruct, | ||
[ | ||
$locationService->newLocationCreateStruct($parentLocationId), | ||
] | ||
); | ||
} | ||
} |