function TermTranslationUITest::testTranslateLinkVocabularyAdminPage
Same name in other branches
- 9 core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php \Drupal\Tests\taxonomy\Functional\TermTranslationUITest::testTranslateLinkVocabularyAdminPage()
- 8.9.x core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php \Drupal\Tests\taxonomy\Functional\TermTranslationUITest::testTranslateLinkVocabularyAdminPage()
- 10 core/modules/taxonomy/tests/src/Functional/TermTranslationUITest.php \Drupal\Tests\taxonomy\Functional\TermTranslationUITest::testTranslateLinkVocabularyAdminPage()
Tests translate link on vocabulary term list.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ TermTranslationUITest.php, line 129
Class
- TermTranslationUITest
- Tests the Term Translation UI.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testTranslateLinkVocabularyAdminPage() : void {
$this->drupalLogin($this->drupalCreateUser(array_merge(parent::getTranslatorPermissions(), [
'access administration pages',
'administer taxonomy',
])));
$values = [
'name' => $this->randomMachineName(),
];
$translatable_tid = $this->createEntity($values, $this->langcodes[0], $this->vocabulary
->id());
// Create an untranslatable vocabulary.
$untranslatable_vocabulary = Vocabulary::create([
'name' => 'untranslatable_voc',
'description' => $this->randomMachineName(),
'vid' => 'untranslatable_voc',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'weight' => mt_rand(0, 10),
]);
$untranslatable_vocabulary->save();
$values = [
'name' => $this->randomMachineName(),
];
$untranslatable_tid = $this->createEntity($values, $this->langcodes[0], $untranslatable_vocabulary->id());
// Verify translation links.
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
->id() . '/overview');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->linkByHrefExists('term/' . $translatable_tid . '/translations', 0, 'The translations link exists for a translatable vocabulary.');
$this->assertSession()
->linkByHrefExists('term/' . $translatable_tid . '/edit', 0, 'The edit link exists for a translatable vocabulary.');
$this->drupalGet('admin/structure/taxonomy/manage/' . $untranslatable_vocabulary->id() . '/overview');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->linkByHrefExists('term/' . $untranslatable_tid . '/edit');
$this->assertSession()
->linkByHrefNotExists('term/' . $untranslatable_tid . '/translations');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.