You are here

protected function ContentTranslationUITestBase::doTestTranslationOverview in Drupal 8

Same name in this branch
  1. 8 core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php \Drupal\content_translation\Tests\ContentTranslationUITestBase::doTestTranslationOverview()
  2. 8 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/src/Tests/ContentTranslationUITestBase.php
Tests the basic translation UI.

File

core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php, line 220

Class

ContentTranslationUITestBase
Tests the Content Translation UI.

Namespace

Drupal\content_translation\Tests

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,
      ]);
      $view_url = $entity
        ->toUrl('canonical', [
        'language' => $language,
      ])
        ->toString();
      $elements = $this
        ->xpath('//table//a[@href=:href]', [
        ':href' => $view_url,
      ]);
      $this
        ->assertEqual((string) $elements[0], $entity
        ->getTranslation($langcode)
        ->label(), new FormattableMarkup('Label correctly shown for %language translation.', [
        '%language' => $langcode,
      ]));
      $edit_path = $entity
        ->toUrl('edit-form', [
        'language' => $language,
      ])
        ->toString();
      $elements = $this
        ->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', [
        ':href' => $edit_path,
      ]);
      $this
        ->assertEqual((string) $elements[0], t('Edit'), new FormattableMarkup('Edit link correct for %language translation.', [
        '%language' => $langcode,
      ]));
    }
  }
}