Skip to content

Commit a8709d3

Browse files
committed
fixup! Apply suggestions from code review on tests
1 parent d827ecf commit a8709d3

1 file changed

Lines changed: 61 additions & 15 deletions

File tree

tests/integration/Core/Repository/ContentServiceTest.php

Lines changed: 61 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6284,7 +6284,20 @@ public function testPublishRevealedDraft(): void
62846284
$draftContentInfo = $draft->getContentInfo();
62856285

62866286
$this->contentService->hideContent($draftContentInfo);
6287+
self::assertTrue(
6288+
$this->contentService
6289+
->loadContent($draftContentInfo->getId())
6290+
->getContentInfo()
6291+
->isHidden()
6292+
);
6293+
62876294
$this->contentService->revealContent($draftContentInfo);
6295+
self::assertFalse(
6296+
$this->contentService
6297+
->loadContent($draftContentInfo->getId())
6298+
->getContentInfo()
6299+
->isHidden()
6300+
);
62886301

62896302
$publishedContent = $this->contentService->publishVersion(
62906303
$draft->getVersionInfo()
@@ -6305,37 +6318,70 @@ public function testPublishRevealedDraft(): void
63056318
}
63066319

63076320
/**
6321+
* @dataProvider draftVisibilityTransitionsProvider
6322+
*
63086323
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
63096324
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException
63106325
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentFieldValidationException
63116326
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
63126327
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
63136328
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\ContentValidationException
63146329
*/
6315-
public function testHideAndRevealNeverPublishedDraft(): void
6316-
{
6330+
public function testDraftVisibilityTransitions(
6331+
bool $initiallyHidden,
6332+
bool $secondDraftHidden
6333+
): void {
63176334
$draft = $this->createFolderDraft();
6318-
$draftContentInfo = $draft->getContentInfo();
63196335

6320-
$this->contentService->hideContent($draftContentInfo);
6336+
if ($initiallyHidden) {
6337+
$this->contentService->hideContent($draft->getContentInfo());
6338+
}
63216339

6322-
self::assertTrue(
6323-
$this->contentService
6324-
->loadContent($draftContentInfo->getId())
6325-
->getContentInfo()
6326-
->isHidden()
6340+
$publishedContent = $this->contentService->publishVersion($draft->getVersionInfo());
6341+
$draft2 = $this->contentService->createContentDraft($publishedContent->getContentInfo());
6342+
6343+
if ($secondDraftHidden) {
6344+
$this->contentService->hideContent($draft2->getContentInfo());
6345+
} else {
6346+
$this->contentService->revealContent($draft2->getContentInfo());
6347+
}
6348+
6349+
$publishedContent2 = $this->contentService->publishVersion($draft2->getVersionInfo());
6350+
$contentInfo = $publishedContent2->getContentInfo();
6351+
6352+
self::assertSame(
6353+
$secondDraftHidden,
6354+
$contentInfo->isHidden(),
6355+
'Unexpected final hidden state for content.'
63276356
);
63286357

6329-
$this->contentService->revealContent($draftContentInfo);
6358+
$mainLocationId = $contentInfo->getMainLocationId();
63306359

6331-
self::assertFalse(
6332-
$this->contentService
6333-
->loadContent($draftContentInfo->getId())
6334-
->getContentInfo()
6335-
->isHidden()
6360+
self::assertNotNull(
6361+
$mainLocationId,
6362+
'Expected mainLocationId to be set.'
6363+
);
6364+
6365+
$location = $this->locationService->loadLocation($mainLocationId);
6366+
6367+
self::assertSame(
6368+
$secondDraftHidden,
6369+
$location->isHidden(),
6370+
'Unexpected final hidden state for location.'
63366371
);
63376372
}
63386373

6374+
/**
6375+
* @return iterable<string, array{bool, bool}>
6376+
*/
6377+
public static function draftVisibilityTransitionsProvider(): iterable
6378+
{
6379+
yield 'hidden -> hidden' => [true, true];
6380+
yield 'hidden -> visible' => [true, false];
6381+
yield 'visible -> hidden' => [false, true];
6382+
yield 'visible -> visible' => [false, false];
6383+
}
6384+
63396385
/**
63406386
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
63416387
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\BadStateException

0 commit comments

Comments
 (0)