function MediaEmbedFilterTranslationTest::setUp

Overrides MediaEmbedFilterTestBase::setUp

File

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

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();
}

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