Skip to content
Permalink
Browse files

Merge branch '7.3'

  • Loading branch information...
andrerom committed Dec 11, 2018
2 parents b6087af + a0c71cd commit e4e2cfc17afbc13ea52c941633db96bfb5645799
@@ -44,11 +44,12 @@ public function copySubtree(Location $subtree, Location $targetParentLocation);
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified location is not found
*
* @param mixed $locationId
* @param string[]|null $prioritizedLanguages Used as prioritized language code on translated properties of returned object.
* @param string[]|null $prioritizedLanguages Filter on and use as prioritized language code on translated properties of returned object.
* @param bool|null $useAlwaysAvailable Respect always available flag on content when filtering on $prioritizedLanguages.
*
* @return \eZ\Publish\API\Repository\Values\Content\Location
*/
public function loadLocation($locationId, array $prioritizedLanguages = null);
public function loadLocation($locationId, array $prioritizedLanguages = null, bool $useAlwaysAvailable = null);
/**
* Loads a location object from its $remoteId.
@@ -57,11 +58,12 @@ public function loadLocation($locationId, array $prioritizedLanguages = null);
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the specified location is not found
*
* @param string $remoteId
* @param string[]|null $prioritizedLanguages Used as prioritized language code on translated properties of returned object.
* @param string[]|null $prioritizedLanguages Filter on and use as prioritized language code on translated properties of returned object.
* @param bool|null $useAlwaysAvailable Respect always available flag on content when filtering on $prioritizedLanguages.
*
* @return \eZ\Publish\API\Repository\Values\Content\Location
*/
public function loadLocationByRemoteId($remoteId, array $prioritizedLanguages = null);
public function loadLocationByRemoteId($remoteId, array $prioritizedLanguages = null, bool $useAlwaysAvailable = null);
/**
* Loads the locations for the given content object.
@@ -11,7 +11,7 @@
use Doctrine\DBAL\Connection;
use eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException;
use eZ\Publish\API\Repository\Tests\PHPUnitConstraint\ValidationErrorOccurs as PHPUnitConstraintValidationErrorOccurs;
use eZ\Publish\API\Repository\Values\Content\Location;
use eZ\Publish\API\Repository\Values\Content\Language;
use EzSystems\EzPlatformSolrSearchEngine\Tests\SetupFactory\LegacySetupFactory as LegacySolrSetupFactory;
use PHPUnit\Framework\TestCase;
use eZ\Publish\API\Repository\Repository;
@@ -717,4 +717,26 @@ protected function createFolder(array $names, $parentLocationId)
return $contentService->publishVersion($contentDraft->versionInfo);
}
/**
* Add new Language to the Repository.
*
* @param string $languageCode
* @param string $name
* @param bool $enabled
*
* @return \eZ\Publish\API\Repository\Values\Content\Language
*/
protected function createLanguage(string $languageCode, string $name, bool $enabled = true): Language
{
$repository = $this->getRepository(false);
$languageService = $repository->getContentLanguageService();
$languageStruct = $languageService->newLanguageCreateStruct();
$languageStruct->name = $name;
$languageStruct->languageCode = $languageCode;
$languageStruct->enabled = $enabled;
return $languageService->createLanguage($languageStruct);
}
}
@@ -548,26 +548,6 @@ public function testGetDefaultLanguageCode()
);
}
/**
* Helper method that creates a new language test fixture in the
* API implementation under test.
*
* @return \eZ\Publish\API\Repository\Values\Content\Language
*/
private function createLanguage()
{
$repository = $this->getRepository();
$languageService = $repository->getContentLanguageService();
$languageCreate = $languageService->newLanguageCreateStruct();
$languageCreate->enabled = false;
$languageCreate->name = 'English';
$languageCreate->languageCode = 'eng-US';
return $languageService->createLanguage($languageCreate);
}
/**
* Test for the createLanguage() method.
*
@@ -478,11 +478,7 @@ public function testLoadLocationPrioritizedLanguagesFallback()
$repository = $this->getRepository();
// Add a language
$languageService = $repository->getContentLanguageService();
$languageStruct = $languageService->newLanguageCreateStruct();
$languageStruct->name = 'Norsk';
$languageStruct->languageCode = 'nor-NO';
$languageService->createLanguage($languageStruct);
$this->createLanguage('nor-NO', 'Norsk');
$locationService = $repository->getLocationService();
$contentService = $repository->getContentService();
@@ -495,7 +491,7 @@ public function testLoadLocationPrioritizedLanguagesFallback()
$draft = $contentService->updateContent($draft->getVersionInfo(), $struct);
$contentService->publishVersion($draft->getVersionInfo());
// Load with prioritc language (fallback will be the old one)
// Load with priority language (fallback will be the old one)
$location = $locationService->loadLocation(5, ['nor-NO']);
$this->assertInstanceOf(
@@ -513,6 +509,24 @@ public function testLoadLocationPrioritizedLanguagesFallback()
$this->assertEquals($content->getVersionInfo()->getName('eng-US'), 'Users');
}
/**
* Test that accessing lazy-loaded Content without a translation in the specific
* not available language throws NotFoundException.
*/
public function testLoadLocationThrowsNotFoundExceptionForNotAvailableContent(): void
{
$repository = $this->getRepository();
$locationService = $repository->getLocationService();
$this->createLanguage('pol-PL', 'Polski');
$this->expectException(NotFoundException::class);
// Note: relying on existing database fixtures to make test case more readable
$locationService->loadLocation(60, ['pol-PL']);
}
/**
* Test for the loadLocation() method.
*

0 comments on commit e4e2cfc

Please sign in to comment.
You can’t perform that action at this time.