Skip to content

Commit

Permalink
EZP-29788: As a developer, I want to delete content type translation …
Browse files Browse the repository at this point in the history
…(#2494)

* EZP-29788: As a developer, I want to delete content type translation

* EZP-29788: Move handling into persistence layer

* EZP-29788: Code review fix

* EZP-29788: Unit tests for new removeContentTypeTranslation method

* EZP-29788: BC breaks doc updated

* EZP-29788: Changed typehinting for contentTypeId from mixed to int
  • Loading branch information
ViniTou authored and Łukasz Serwatka committed Dec 14, 2018
1 parent 7011525 commit 6e491ce
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Repository/ContentTypeService.php
Expand Up @@ -380,4 +380,12 @@ public function newFieldDefinitionUpdateStruct();
* @return bool
*/
public function isContentTypeUsed(ContentType $contentType);

/**
* @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft $contentTypeDraft
* @param string $languageCode
*
* @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft
*/
public function removeContentTypeTranslation(ContentTypeDraft $contentTypeDraft, string $languageCode): ContentTypeDraft;
}
42 changes: 42 additions & 0 deletions Repository/Tests/ContentTypeServiceTest.php
Expand Up @@ -4131,4 +4131,46 @@ public function testIsContentTypeUsed()
$this->assertTrue($isFolderUsed);
$this->assertFalse($isEventUsed);
}

/**
* @covers \eZ\Publish\API\Repository\ContentTypeService::removeContentTypeTranslation
*
* @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 testRemoveContentTypeTranslation()
{
$repository = $this->getRepository();
$contentTypeService = $repository->getContentTypeService();

$contentTypeDraft = $this->createContentTypeDraft();
$contentTypeService->publishContentTypeDraft($contentTypeDraft);

$contentType = $contentTypeService->loadContentType($contentTypeDraft->id);

$this->assertEquals(
[
'eng-US' => 'Blog post',
'ger-DE' => 'Blog-Eintrag',
],
$contentType->getNames()
);

$contentTypeService->removeContentTypeTranslation(
$contentTypeService->createContentTypeDraft($contentType),
'ger-DE'
);

$loadedContentTypeDraft = $contentTypeService->loadContentTypeDraft($contentType->id);

$this->assertArrayNotHasKey('ger-DE', $loadedContentTypeDraft->getNames());
$this->assertArrayNotHasKey('ger-DE', $loadedContentTypeDraft->getDescriptions());

foreach ($loadedContentTypeDraft->fieldDefinitions as $fieldDefinition) {
$this->assertArrayNotHasKey('ger-DE', $fieldDefinition->getNames());
$this->assertArrayNotHasKey('ger-DE', $fieldDefinition->getDescriptions());
}
}
}

0 comments on commit 6e491ce

Please sign in to comment.