function MediaEmbedFilterTranslationTest::setUp

Same name and namespace in other branches
  1. 8.9.x core/modules/media/tests/src/Kernel/MediaEmbedFilterTranslationTest.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTranslationTest::setUp()
  2. 10 core/modules/media/tests/src/Kernel/MediaEmbedFilterTranslationTest.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTranslationTest::setUp()
  3. 11.x core/modules/media/tests/src/Kernel/MediaEmbedFilterTranslationTest.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTranslationTest::setUp()

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

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