You are here

protected function BlockContentTranslationUITest::doTestTranslationEdit in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php \Drupal\Tests\block_content\Functional\BlockContentTranslationUITest::doTestTranslationEdit()
  2. 9 core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php \Drupal\Tests\block_content\Functional\BlockContentTranslationUITest::doTestTranslationEdit()

File

core/modules/block_content/tests/src/Functional/BlockContentTranslationUITest.php, line 135

Class

BlockContentTranslationUITest
Tests the block content translation UI.

Namespace

Drupal\Tests\block_content\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();
  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);
      $this
        ->assertSession()
        ->pageTextContains("Edit {$entity->bundle()} {$entity->getTranslation($langcode)->label()} [{$languages[$langcode]->getName()} translation]");
    }
  }
}