diff --git a/eZ/Publish/API/Repository/Tests/ContentServiceAuthorizationTest.php b/eZ/Publish/API/Repository/Tests/ContentServiceAuthorizationTest.php index 1262e42a252..bf05af42524 100644 --- a/eZ/Publish/API/Repository/Tests/ContentServiceAuthorizationTest.php +++ b/eZ/Publish/API/Repository/Tests/ContentServiceAuthorizationTest.php @@ -384,7 +384,7 @@ public function testLoadContentThrowsUnauthorizedException() * Test for the loadContent() method. * * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages) - * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithSecondParameter + * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithPrioritizedLanguages */ public function testLoadContentThrowsUnauthorizedExceptionWithSecondParameter() { diff --git a/eZ/Publish/API/Repository/Tests/ContentServiceTest.php b/eZ/Publish/API/Repository/Tests/ContentServiceTest.php index 82791fc9d96..c3135ff8931 100644 --- a/eZ/Publish/API/Repository/Tests/ContentServiceTest.php +++ b/eZ/Publish/API/Repository/Tests/ContentServiceTest.php @@ -2687,7 +2687,7 @@ public function testLoadContentByContentInfoThrowsNotFoundExceptionWithVersionNu * @see \eZ\Publish\API\Repository\ContentService::loadContent($contentId, $languages) * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testPublishVersionFromContentDraft */ - public function testLoadContentWithSecondParameter() + public function testLoadContentWithPrioritizedLanguages() { $draft = $this->createMultipleLanguageDraftVersion1(); @@ -2696,23 +2696,41 @@ public function testLoadContentWithSecondParameter() $this->assertLocaleFieldsEquals($draftLocalized->getFields(), self::ENG_GB); - return $draft; + return $draftLocalized; } /** * Test for the loadContent() method using undefined translation. * - * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithSecondParameter + * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithPrioritizedLanguages * * @param \eZ\Publish\API\Repository\Values\Content\Content $contentDraft */ - public function testLoadContentWithSecondParameterThrowsNotFoundException(Content $contentDraft) + public function testLoadContentWithPrioritizedLanguagesThrowsNotFoundException(Content $contentDraft) { $this->expectException(NotFoundException::class); $this->contentService->loadContent($contentDraft->id, [self::GER_DE], null, false); } + /** + * Test for the loadContent() method. + * + * @see \eZ\Publish\API\Repository\ContentService::loadContent + * @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testLoadContentWithPrioritizedLanguages + */ + public function testLoadContentPassTroughPrioritizedLanguagesToContentType(Content $content): void + { + $contentTypeService = $this->getRepository()->getContentTypeService(); + + $contentType = $contentTypeService->loadContentType( + $content->contentInfo->contentTypeId, + [self::ENG_GB] + ); + + $this->assertEquals($contentType, $content->getContentType()); + } + /** * Test for the loadContent() method. * diff --git a/eZ/Publish/Core/Repository/ContentService.php b/eZ/Publish/Core/Repository/ContentService.php index 1afa0a71f34..e6534f33f04 100644 --- a/eZ/Publish/Core/Repository/ContentService.php +++ b/eZ/Publish/Core/Repository/ContentService.php @@ -382,12 +382,17 @@ public function internalLoadContent($id, array $languages = null, $versionNo = n ); } + if ($languages === null) { + $languages = []; + } + return $this->domainMapper->buildContentDomainObject( $spiContent, $this->repository->getContentTypeService()->loadContentType( - $spiContent->versionInfo->contentInfo->contentTypeId + $spiContent->versionInfo->contentInfo->contentTypeId, + $languages ), - $languages ?? [], + $languages, $alwaysAvailableLanguageCode ); }