protected function ShortcutTranslationUITest::doTestBasicTranslation in Drupal 8
Same name and namespace in other branches
- 9 core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php \Drupal\Tests\shortcut\Functional\ShortcutTranslationUITest::doTestBasicTranslation()
- 10 core/modules/shortcut/tests/src/Functional/ShortcutTranslationUITest.php \Drupal\Tests\shortcut\Functional\ShortcutTranslationUITest::doTestBasicTranslation()
Tests the basic translation workflow.
Overrides ContentTranslationUITestBase::doTestBasicTranslation
File
- core/
modules/ shortcut/ tests/ src/ Functional/ ShortcutTranslationUITest.php, line 71
Class
- ShortcutTranslationUITest
- Tests the shortcut translation UI.
Namespace
Drupal\Tests\shortcut\FunctionalCode
protected function doTestBasicTranslation() {
parent::doTestBasicTranslation();
$storage = $this->container
->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage
->resetCache([
$this->entityId,
]);
$entity = $storage
->load($this->entityId);
foreach ($this->langcodes as $langcode) {
if ($entity
->hasTranslation($langcode)) {
$language = new Language([
'id' => $langcode,
]);
// Request the front page in this language and assert that the right
// translation shows up in the shortcut list with the right path.
$this
->drupalGet('<front>', [
'language' => $language,
]);
$expected_path = \Drupal::urlGenerator()
->generateFromRoute('user.page', [], [
'language' => $language,
]);
$label = $entity
->getTranslation($langcode)
->label();
$elements = $this
->xpath('//nav[contains(@class, "toolbar-lining")]/ul[@class="toolbar-menu"]/li/a[contains(@href, :href) and normalize-space(text())=:label]', [
':href' => $expected_path,
':label' => $label,
]);
$this
->assertTrue(!empty($elements), new FormattableMarkup('Translated @language shortcut link @label found.', [
'@label' => $label,
'@language' => $language
->getName(),
]));
}
}
}