You are here

protected function ContentTranslationUITestBase::doTestTranslationOverview in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php \Drupal\content_translation\Tests\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 211
Contains \Drupal\content_translation\Tests\ContentTranslationUITestBase.

Class

ContentTranslationUITestBase
Tests the Content Translation UI.

Namespace

Drupal\content_translation\Tests

Code

protected function doTestTranslationOverview() {
  $entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
  $translate_url = $entity
    ->urlInfo('drupal:content-translation-overview');
  $this
    ->drupalGet($translate_url);
  $translate_url
    ->setAbsolute(FALSE);
  foreach ($this->langcodes as $langcode) {
    if ($entity
      ->hasTranslation($langcode)) {
      $language = new Language(array(
        'id' => $langcode,
      ));
      $view_url = $entity
        ->url('canonical', [
        'language' => $language,
      ]);
      $elements = $this
        ->xpath('//table//a[@href=:href]', [
        ':href' => $view_url,
      ]);
      $this
        ->assertEqual((string) $elements[0], $entity
        ->getTranslation($langcode)
        ->label(), format_string('Label correctly shown for %language translation.', array(
        '%language' => $langcode,
      )));
      $edit_path = $entity
        ->url('edit-form', array(
        'language' => $language,
      ));
      $elements = $this
        ->xpath('//table//ul[@class="dropbutton"]/li/a[@href=:href]', array(
        ':href' => $edit_path,
      ));
      $this
        ->assertEqual((string) $elements[0], t('Edit'), format_string('Edit link correct for %language translation.', array(
        '%language' => $langcode,
      )));
    }
  }
}