Skip to content

Commit

Permalink
Merge branch '7.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Longosz committed Mar 2, 2018
2 parents 68999da + b1d8d5b commit 6c67eca
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions Repository/Tests/ContentServiceTest.php
Expand Up @@ -5418,6 +5418,11 @@ public function providerForDeleteTranslationFromDraftRemovesUrlAliasOnPublishing
* @dataProvider providerForDeleteTranslationFromDraftRemovesUrlAliasOnPublishing
*
* @param string[] $fieldValues translated field values
*
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
*/
public function testDeleteTranslationFromDraftRemovesUrlAliasOnPublishing(array $fieldValues)
{
Expand Down Expand Up @@ -5480,6 +5485,65 @@ public function testDeleteTranslationFromDraftRemovesUrlAliasOnPublishing(array
}
}

/**
* Test that URL aliases for deleted Translations are properly archived.
*/
public function testDeleteTranslationFromDraftArchivesUrlAliasOnPublishing()
{
$repository = $this->getRepository();
$contentService = $repository->getContentService();
$urlAliasService = $repository->getURLAliasService();

$content = $contentService->publishVersion(
$this->createMultilingualContentDraft(
'folder',
2,
'eng-US',
[
'name' => [
'eng-GB' => 'BritishEnglishContent',
'eng-US' => 'AmericanEnglishContent',
],
]
)->versionInfo
);

$unrelatedContent = $contentService->publishVersion(
$this->createMultilingualContentDraft(
'folder',
2,
'eng-US',
[
'name' => [
'eng-GB' => 'AnotherBritishContent',
'eng-US' => 'AnotherAmericanContent',
],
]
)->versionInfo
);

$urlAlias = $urlAliasService->lookup('/BritishEnglishContent');
self::assertFalse($urlAlias->isHistory);
self::assertEquals($urlAlias->path, '/BritishEnglishContent');
self::assertEquals($urlAlias->destination, $content->contentInfo->mainLocationId);

$draft = $contentService->deleteTranslationFromDraft(
$contentService->createContentDraft($content->contentInfo)->versionInfo,
'eng-GB'
);
$content = $contentService->publishVersion($draft->versionInfo);

$urlAlias = $urlAliasService->lookup('/BritishEnglishContent');
self::assertTrue($urlAlias->isHistory);
self::assertEquals($urlAlias->path, '/BritishEnglishContent');
self::assertEquals($urlAlias->destination, $content->contentInfo->mainLocationId);

$unrelatedUrlAlias = $urlAliasService->lookup('/AnotherBritishContent');
self::assertFalse($unrelatedUrlAlias->isHistory);
self::assertEquals($unrelatedUrlAlias->path, '/AnotherBritishContent');
self::assertEquals($unrelatedUrlAlias->destination, $unrelatedContent->contentInfo->mainLocationId);
}

/**
* Test deleting a Translation from Draft which has single Translation throws BadStateException.
*
Expand Down

0 comments on commit 6c67eca

Please sign in to comment.