public function VocabularyTranslationTest::testVocabularyTitleLabelTranslation in Drupal 9
Same name and namespace in other branches
- 10 core/modules/taxonomy/tests/src/Functional/VocabularyTranslationTest.php \Drupal\Tests\taxonomy\Functional\VocabularyTranslationTest::testVocabularyTitleLabelTranslation()
Tests vocabulary name translation for the overview and reset pages.
File
- core/
modules/ taxonomy/ tests/ src/ Functional/ VocabularyTranslationTest.php, line 80
Class
- VocabularyTranslationTest
- Tests content translation for vocabularies.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testVocabularyTitleLabelTranslation() : void {
$this
->drupalGet('admin/structure/taxonomy/add');
// Create the vocabulary.
$vid = mb_strtolower($this
->randomMachineName());
$edit['name'] = $this
->randomMachineName();
$edit['description'] = $this
->randomMachineName();
$edit['langcode'] = 'en';
$edit['vid'] = $vid;
$edit['default_language[content_translation]'] = TRUE;
$this
->submitForm($edit, t('Save'));
$langcode = $this->additionalLangcodes[0];
$vid_name = $edit['name'];
$translated_vid_name = "Translated {$vid_name}";
$this
->assertSession()
->pageTextContains($vid_name);
// Assert that the name label is displayed on the translation form with the
// right value.
$this
->drupalGet("admin/structure/taxonomy/manage/{$vid}/translate/{$langcode}/add");
// Translate the name label.
$this
->submitForm([
"translation[config_names][taxonomy.vocabulary.{$vid}][name]" => $translated_vid_name,
], t('Save translation'));
// Assert that the right name label is displayed on the taxonomy term
// overview page.
$this
->drupalGet("admin/structure/taxonomy/manage/{$vid}/overview");
$this
->assertSession()
->pageTextContains($vid_name);
$this
->drupalGet("{$langcode}/admin/structure/taxonomy/manage/{$vid}/overview");
$this
->assertSession()
->pageTextContains($translated_vid_name);
// Assert that the right name label is displayed on the taxonomy reset page.
$this
->drupalGet("admin/structure/taxonomy/manage/{$vid}/reset");
$this
->assertSession()
->pageTextContains($vid_name);
$this
->drupalGet("{$langcode}/admin/structure/taxonomy/manage/{$vid}/reset");
$this
->assertSession()
->pageTextContains($translated_vid_name);
}