Skip to content

Commit 3dfb2c7

Browse files
committed
Added tests for IBX-10854: Not possible to hide content draft
1 parent ed818bb commit 3dfb2c7

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

tests/integration/Core/Repository/ContentServiceTest.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6229,6 +6229,76 @@ function (Location $parentLocation) {
62296229
$this->assertEquals($hiddenLocations, $hiddenLocationsAfterReveal);
62306230
}
62316231

6232+
/**
6233+
* @covers \Ibexa\Contracts\Core\Repository\ContentService::hideContent
6234+
6235+
*
6236+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\APIInvalidArgumentException
6237+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
6238+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentFieldValidationException
6239+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
6240+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
6241+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentValidationException
6242+
*/
6243+
public function testHideContentDraft(): void
6244+
{
6245+
$publishedContent = $this->createContentForHideRevealDraftTests(false);
6246+
$location = $this->locationService->loadLocation($publishedContent->contentInfo->mainLocationId);
6247+
6248+
$content = $this->contentService->loadContent($publishedContent->contentInfo->id);
6249+
self::assertTrue($content->contentInfo->isHidden, 'Content is not hidden');
6250+
self::assertTrue($location->isHidden(), 'Location is visible');
6251+
}
6252+
6253+
/**
6254+
* @covers \Ibexa\Contracts\Core\Repository\ContentService::revealContent
6255+
6256+
*
6257+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
6258+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
6259+
*/
6260+
public function testHideAndRevealContentDraft(): void
6261+
{
6262+
$publishedContent = $this->createContentForHideRevealDraftTests(true);
6263+
$location = $this->locationService->loadLocation($publishedContent->contentInfo->mainLocationId);
6264+
6265+
$content = $this->contentService->loadContent($publishedContent->contentInfo->id);
6266+
self::assertFalse($content->contentInfo->isHidden, 'Content is hidden');
6267+
self::assertFalse($location->isHidden(), 'Location is hidden');
6268+
}
6269+
6270+
/**
6271+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\APIInvalidArgumentException
6272+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
6273+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentFieldValidationException
6274+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
6275+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
6276+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentValidationException
6277+
*/
6278+
private function createContentForHideRevealDraftTests(bool $hideAndRevel): Content
6279+
{
6280+
$contentTypeService = $this->getRepository()->getContentTypeService();
6281+
6282+
$locationCreateStructs = $this->locationService->newLocationCreateStruct(2);
6283+
6284+
$contentType = $contentTypeService->loadContentTypeByIdentifier('folder');
6285+
6286+
$contentCreate = $this->contentService->newContentCreateStruct($contentType, self::ENG_US);
6287+
$contentCreate->setField('name', 'Folder to hide');
6288+
6289+
$draft = $this->contentService->createContent(
6290+
$contentCreate,
6291+
[$locationCreateStructs]
6292+
);
6293+
6294+
$this->contentService->hideContent($draft->contentInfo);
6295+
if ($hideAndRevel) {
6296+
$this->contentService->revealContent($draft->contentInfo);
6297+
}
6298+
6299+
return $this->contentService->publishVersion($draft->versionInfo);
6300+
}
6301+
62326302
/**
62336303
* @depends testRevealContent
62346304
*/

0 commit comments

Comments
 (0)