Skip to content

Commit

Permalink
EZP-29751: Wrong first URL generation in exotic languages (#2471)
Browse files Browse the repository at this point in the history
  • Loading branch information
glye committed Dec 5, 2018
1 parent bd4dd44 commit 7169ce0
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
50 changes: 50 additions & 0 deletions eZ/Publish/API/Repository/Tests/URLAliasServiceTest.php
Expand Up @@ -1215,6 +1215,56 @@ public function testRefreshSystemUrlAliasesForContentsWithUpdatedContentTypes()
$this->assertUrlIsCurrent('/DE-Short-Name/DE-Nested-Short-Name', $nestedFolderLocation->id);
}

/**
* Test that created non-latin aliases are non-empty and unique.
*
* @throws \eZ\Publish\API\Repository\Exceptions\ForbiddenException
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
*/
public function testCreateNonLatinNonEmptyUniqueAliases()
{
$repository = $this->getRepository();
$urlAliasService = $repository->getURLAliasService();
$locationService = $repository->getLocationService();

$folderNames = [
'eng-GB' => 'ひらがな',
];

$folderLocation1 = $locationService->loadLocation(
$this->createFolder($folderNames, 2)->contentInfo->mainLocationId
);
$urlAlias1 = $urlAliasService->lookup('/1');
self::assertPropertiesCorrect(
[
'destination' => $folderLocation1->id,
'path' => '/1',
'languageCodes' => ['eng-GB'],
'isHistory' => false,
'isCustom' => false,
'forward' => false,
],
$urlAlias1
);

$folderLocation2 = $locationService->loadLocation(
$this->createFolder($folderNames, 2)->contentInfo->mainLocationId
);
$urlAlias2 = $urlAliasService->lookup('/2');
self::assertPropertiesCorrect(
[
'destination' => $folderLocation2->id,
'path' => '/2',
'languageCodes' => ['eng-GB'],
'isHistory' => false,
'isCustom' => false,
'forward' => false,
],
$urlAlias2
);
}

/**
* Test restoring missing current URL which has existing history.
*
Expand Down
Expand Up @@ -187,7 +187,7 @@ private function internalPublishUrlAliasForLocation(
while (true) {
$newText = '';
if ($locationId != self::CONTENT_REPOSITORY_ROOT_LOCATION_ID) {
$newText = $name . ($uniqueCounter > 1 ? $uniqueCounter : '');
$newText = $name . ($name == '' || $uniqueCounter > 1 ? $uniqueCounter : '');
}
$newTextMD5 = $this->getHash($newText);

Expand Down

0 comments on commit 7169ce0

Please sign in to comment.