Commit dbc47502 authored by borisson_'s avatar borisson_ Committed by borisson_

Issue #2893374 by borisson_: Translate url alias

parent dcd708d6
...@@ -7,7 +7,7 @@ facets.facet.*: ...@@ -7,7 +7,7 @@ facets.facet.*:
label: 'ID' label: 'ID'
name: name:
type: label type: label
label: Name' label: Name
uuid: uuid:
type: string type: string
label: 'UUID' label: 'UUID'
...@@ -18,7 +18,7 @@ facets.facet.*: ...@@ -18,7 +18,7 @@ facets.facet.*:
type: integer type: integer
label: 'Minimum count' label: 'Minimum count'
url_alias: url_alias:
type: string type: label
label: 'Name of facet as used in the URL' label: 'Name of facet as used in the URL'
facet_source_id: facet_source_id:
type: string type: string
......
...@@ -21,6 +21,7 @@ class LanguageIntegrationTest extends FacetsTestBase { ...@@ -21,6 +21,7 @@ class LanguageIntegrationTest extends FacetsTestBase {
'block', 'block',
'facets_search_api_dependency', 'facets_search_api_dependency',
'language', 'language',
'config_translation',
]; ];
/** /**
...@@ -29,8 +30,20 @@ class LanguageIntegrationTest extends FacetsTestBase { ...@@ -29,8 +30,20 @@ class LanguageIntegrationTest extends FacetsTestBase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$this->adminUser = $this->drupalCreateUser([
'administer search_api',
'administer facets',
'access administration pages',
'administer nodes',
'access content overview',
'administer content types',
'administer blocks',
'translate configuration',
]);
$this->drupalLogin($this->adminUser); $this->drupalLogin($this->adminUser);
ConfigurableLanguage::create(['id' => 'xx-lolspeak'])->save();
$this->setUpExampleStructure(); $this->setUpExampleStructure();
$this->insertExampleContent(); $this->insertExampleContent();
$this->assertEqual($this->indexItems($this->indexId), 5, '5 items were indexed.'); $this->assertEqual($this->indexItems($this->indexId), 5, '5 items were indexed.');
...@@ -50,8 +63,6 @@ class LanguageIntegrationTest extends FacetsTestBase { ...@@ -50,8 +63,6 @@ class LanguageIntegrationTest extends FacetsTestBase {
$facet_name = 'Owl'; $facet_name = 'Owl';
$this->createFacet($facet_name, $facet_id); $this->createFacet($facet_name, $facet_id);
ConfigurableLanguage::create(['id' => 'xx-lolspeak'])->save();
// Go to the search view with a language prefix and click on one of the // Go to the search view with a language prefix and click on one of the
// facets. // facets.
$this->drupalGet('xx-lolspeak/search-api-test-fulltext'); $this->drupalGet('xx-lolspeak/search-api-test-fulltext');
...@@ -109,4 +120,37 @@ class LanguageIntegrationTest extends FacetsTestBase { ...@@ -109,4 +120,37 @@ class LanguageIntegrationTest extends FacetsTestBase {
$this->assertFacetLabel('Key Word'); $this->assertFacetLabel('Key Word');
} }
/**
* Tests the url alias translation.
*
* @see https://www.drupal.org/node/2893374
*/
public function testUrlAliasTranslation() {
$facet_id = 'barn_owl';
$facet_name = 'Barn owl';
$this->createFacet($facet_name, $facet_id);
// Go to the search view with a language prefix and click on one of the
// facets.
$this->drupalGet('xx-lolspeak/search-api-test-fulltext');
$this->assertFacetBlocksAppear();
$this->clickLink('item');
// Check that the language code is still in the url.
$this->assertTrue(strpos($this->getUrl(), 'xx-lolspeak/'), 'Found the language code in the url');
$this->assertTrue(strpos($this->getUrl(), 'barn_owl'), 'Found the facet in the url');
// Translate the facet.
$this->drupalGet('admin/config/search/facets/' . $facet_id . '/edit/translate/xx-lolspeak/add');
$this->drupalPostForm(NULL, ['translation[config_names][facets.facet.barn_owl][url_alias]' => 'tyto_alba'],'Save translation');
// Go to the search view again and check that we now have the translated
// facet in the url.
$this->drupalGet('xx-lolspeak/search-api-test-fulltext');
$this->assertFacetBlocksAppear();
$this->clickLink('item');
$this->assertTrue(strpos($this->getUrl(), 'xx-lolspeak/'), 'Found the language code in the url');
$this->assertTrue(strpos($this->getUrl(), 'tyto_alba'), 'Found the facet in the url');
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment