function ConfigTranslationListUiTest::doVocabularyListTest

Same name and namespace in other branches
  1. 9 core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationListUiTest::doVocabularyListTest()
  2. 8.9.x core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationListUiTest::doVocabularyListTest()
  3. 11.x core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php \Drupal\Tests\config_translation\Functional\ConfigTranslationListUiTest::doVocabularyListTest()

Tests the vocabulary listing for the translate operation.

1 call to ConfigTranslationListUiTest::doVocabularyListTest()
ConfigTranslationListUiTest::testTranslateOperationInListUi in core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php
Tests if translate link is added to operations in all configuration lists.

File

core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php, line 173

Class

ConfigTranslationListUiTest
Visit all lists.

Namespace

Drupal\Tests\config_translation\Functional

Code

protected function doVocabularyListTest() {
  // Create a test vocabulary to decouple looking for translate operations
  // link so this does not test more than necessary.
  $vocabulary = Vocabulary::create([
    'name' => $this->randomMachineName(),
    'description' => $this->randomMachineName(),
    'vid' => $this->randomMachineName(),
  ]);
  $vocabulary->save();
  // Get the Taxonomy listing.
  $this->drupalGet('admin/structure/taxonomy');
  $translate_link = 'admin/structure/taxonomy/manage/' . $vocabulary->id() . '/translate';
  // Test if the link to translate the vocabulary is on the page.
  $this->assertSession()
    ->linkByHrefExists($translate_link);
  // Test if the link to translate actually goes to the translate page.
  $this->drupalGet($translate_link);
  $this->assertSession()
    ->responseContains('<th>Language</th>');
  // Test if the local task for translation is on this page.
  $this->assertSession()
    ->linkExists('Translate taxonomy vocabulary');
  $local_task_url = parse_url($this->getSession()
    ->getPage()
    ->findLink('Translate taxonomy vocabulary')
    ->getAttribute('href'));
  $this->assertSame(base_path() . $translate_link, $local_task_url['path']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.