You are here

public function MediaUiFunctionalTest::testRenderedEntityReferencedMedia in Drupal 9

Same name and namespace in other branches
  1. 8 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 176

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