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. 10 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()

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

File

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

Class

MediaUiFunctionalTest
Ensures that media UI works correctly.

Namespace

Drupal\Tests\media\Functional

Code

public function testRenderedEntityReferencedMedia() {
    $page = $this->getSession()
        ->getPage();
    $assert_session = $this->assertSession();
    $this->drupalCreateContentType([
        'type' => 'page',
        'name' => 'Page',
    ]);
    $this->drupalGet('/admin/structure/types/manage/page/fields/add-field');
    $page->selectFieldOption('new_storage_type', 'field_ui:entity_reference:media');
    $page->fillField('label', 'Foo field');
    $page->fillField('field_name', 'foo_field');
    $page->pressButton('Save and continue');
    $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.