function MediaUiFunctionalTest::testRenderedEntityReferencedMedia

Same name in other branches
  1. 9 core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php \Drupal\Tests\media\Functional\MediaUiFunctionalTest::testRenderedEntityReferencedMedia()
  2. 8.9.x core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php \Drupal\Tests\media\Functional\MediaUiFunctionalTest::testRenderedEntityReferencedMedia()
  3. 11.x core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php \Drupal\Tests\media\Functional\MediaUiFunctionalTest::testRenderedEntityReferencedMedia()

Tests that media in ER fields use the Rendered Entity formatter by default.

File

core/modules/media/tests/src/Functional/MediaUiFunctionalTest.php, line 191

Class

MediaUiFunctionalTest
Ensures that media UI works correctly.

Namespace

Drupal\Tests\media\Functional

Code

public function testRenderedEntityReferencedMedia() : void {
    $assert_session = $this->assertSession();
    $this->drupalCreateContentType([
        'type' => 'page',
        'name' => 'Page',
    ]);
    $this->createMediaType('image', [
        'id' => 'image',
        'new_revision' => TRUE,
    ]);
    $this->fieldUIAddNewField('/admin/structure/types/manage/page', 'foo_field', 'Foo field', 'field_ui:entity_reference:media', [], [
        'settings[handler_settings][target_bundles][image]' => TRUE,
    ]);
    $this->drupalGet('/admin/structure/types/manage/page/display');
    $assert_session->fieldValueEquals('fields[field_foo_field][type]', 'entity_reference_entity_view');
}

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