function NodeTranslationUITest::doTestTranslationEdit

Same name and namespace in other branches
  1. 11.x core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::doTestTranslationEdit()
  2. 10 core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::doTestTranslationEdit()
  3. 9 core/modules/node/tests/src/Functional/NodeTranslationUITest.php \Drupal\Tests\node\Functional\NodeTranslationUITest::doTestTranslationEdit()

File

core/modules/node/tests/src/Functional/NodeTranslationUITest.php, line 460

Class

NodeTranslationUITest
Tests the Node Translation UI.

Namespace

Drupal\Tests\node\Functional

Code

protected function doTestTranslationEdit() {
  $storage = $this->container
    ->get('entity_type.manager')
    ->getStorage($this->entityTypeId);
  $storage->resetCache([
    $this->entityId,
  ]);
  $entity = $storage->load($this->entityId);
  $languages = $this->container
    ->get('language_manager')
    ->getLanguages();
  $type_name = node_get_type_label($entity);
  foreach ($this->langcodes as $langcode) {
    // We only want to test the title for non-english translations.
    if ($langcode != 'en') {
      $options = [
        'language' => $languages[$langcode],
      ];
      $url = $entity->toUrl('edit-form', $options);
      $this->drupalGet($url);
      $title = t('<em>Edit @type</em> @title [%language translation]', [
        '@type' => $type_name,
        '@title' => $entity->getTranslation($langcode)
          ->label(),
        '%language' => $languages[$langcode]->getName(),
      ]);
      $this->assertRaw($title);
    }
  }
}

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