public function TranslationTest::testSingleLanguage in Search API sorts 8
Test search_api_sorts with one language enabled.
File
- tests/
src/ Functional/ TranslationTest.php, line 63
Class
- TranslationTest
- Tests Search API sorts translation.
Namespace
Drupal\Tests\search_api_sorts\FunctionalCode
public function testSingleLanguage() {
// Remove the FR language so we can test the search api sorts admin screens
// without multiple languages enabled.
$language = ConfigurableLanguage::load('fr');
$language
->delete();
$this
->drupalGet('admin/config/search/search-api/index/' . $this->indexId . '/sorts/' . $this->escapedDisplayId);
// Check if the translation warning is not shown.
$this
->assertSession()
->pageTextNotContains('You are currently editing the English version of the search api sorts fields.');
// Check if the translate column is not present.
$this
->assertSession()
->elementNotContains('css', 'table#edit-sorts thead th:last-child', 'Translate');
// Check if translate link is not present.
$this
->assertSession()
->linkByHrefNotExists(sprintf('admin/config/search/search-api/sorts/%s/translate', $this->escapedDisplayId . '_' . 'id'));
$edit = [
'sorts[id][status]' => TRUE,
'default_sort' => 'id',
];
$this
->drupalPostForm(NULL, $edit, 'Save settings');
// Check if the config is saved in the default language.
$search_api_sorts_field = $this->searchApiSortsFieldStorage
->load($this->escapedDisplayId . '_' . 'id');
$this
->assertEquals('en', $search_api_sorts_field
->language()
->getId());
// Check if translate link is still not present.
$this
->assertSession()
->linkByHrefNotExists(sprintf('admin/config/search/search-api/sorts/%s/translate', $this->escapedDisplayId . '_' . 'id'));
// Visit the EN version of the search_api overview and check if the labels
// are shown in the default language.
$this
->drupalGet('search-api-sorts-test');
$this
->assertSession()
->linkNotExists('Identifiant');
$this
->assertSession()
->linkExists('ID');
}