protected function ContentTranslationUITestBase::doTestTranslationOverview in Drupal 9
Same name and namespace in other branches
- 8 core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationUITestBase::doTestTranslationOverview()
- 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\FunctionalCode
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() ?? '');
      // 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');
    }
  }
}