function ContentTranslationUITestBase::doTestTranslationOverview

Same name in other branches
  1. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestTranslationOverview()
  2. 8.9.x core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php \Drupal\content_translation\Tests\ContentTranslationUITestBase::doTestTranslationOverview()
  3. 8.9.x core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestTranslationOverview()
  4. 10 core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestTranslationOverview()

Tests that the translation overview shows the correct values.

1 call to ContentTranslationUITestBase::doTestTranslationOverview()
ContentTranslationUITestBase::testTranslationUI in core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php
Tests the basic translation UI.

File

core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php, line 217

Class

ContentTranslationUITestBase
Tests the Content Translation UI.

Namespace

Drupal\Tests\content_translation\Functional

Code

protected function doTestTranslationOverview() {
    $storage = $this->container
        ->get('entity_type.manager')
        ->getStorage($this->entityTypeId);
    $storage->resetCache([
        $this->entityId,
    ]);
    $entity = $storage->load($this->entityId);
    $translate_url = $entity->toUrl('drupal:content-translation-overview');
    $this->drupalGet($translate_url);
    $translate_url->setAbsolute(FALSE);
    foreach ($this->langcodes as $langcode) {
        if ($entity->hasTranslation($langcode)) {
            $language = new Language([
                'id' => $langcode,
            ]);
            // Test that label is correctly shown for translation.
            $view_url = $entity->toUrl('canonical', [
                'language' => $language,
            ])
                ->toString();
            $this->assertSession()
                ->elementTextEquals('xpath', "//table//a[@href='{$view_url}']", $entity->getTranslation($langcode)
                ->label() ?? $entity->getTranslation($langcode)
                ->id());
            // Test that edit link is correct for translation.
            $edit_path = $entity->toUrl('edit-form', [
                'language' => $language,
            ])
                ->toString();
            $this->assertSession()
                ->elementTextEquals('xpath', "//table//ul[@class='dropbutton']/li/a[@href='{$edit_path}']", 'Edit');
        }
    }
}

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