You are here

protected function MediaEmbedFilterTranslationTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/Kernel/MediaEmbedFilterTranslationTest.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTranslationTest::setUp()
  2. 9 core/modules/media/tests/src/Kernel/MediaEmbedFilterTranslationTest.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTranslationTest::setUp()

File

core/modules/media/tests/src/Kernel/MediaEmbedFilterTranslationTest.php, line 25

Class

MediaEmbedFilterTranslationTest
Tests that media embeds are translated based on text (host entity) language.

Namespace

Drupal\Tests\media\Kernel

Code

protected function setUp() : void {
  parent::setUp();
  ConfigurableLanguage::createFromLangcode('pt-br')
    ->save();

  // Reload the entity to ensure it is aware of the newly created language.
  $this->embeddedEntity = $this->container
    ->get('entity_type.manager')
    ->getStorage('media')
    ->load($this->embeddedEntity
    ->id());
  $this->embeddedEntity
    ->addTranslation('pt-br')
    ->set('field_media_image', [
    'target_id' => $this->image
      ->id(),
    'alt' => 'pt-br alt',
    'title' => 'pt-br title',
  ])
    ->save();
}