You are here

public function MediaSourceTest::testDifferentSourceFieldDisplays in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/tests/src/Kernel/MediaSourceTest.php \Drupal\Tests\media\Kernel\MediaSourceTest::testDifferentSourceFieldDisplays()
  2. 10 core/modules/media/tests/src/Kernel/MediaSourceTest.php \Drupal\Tests\media\Kernel\MediaSourceTest::testDifferentSourceFieldDisplays()

Tests different display options for the source field.

File

core/modules/media/tests/src/Kernel/MediaSourceTest.php, line 530

Class

MediaSourceTest
Tests media source plugins related logic.

Namespace

Drupal\Tests\media\Kernel

Code

public function testDifferentSourceFieldDisplays() {
  $id = 'test_different_displays';
  $field_name = 'field_media_different_display';
  $this
    ->createMediaTypeViaForm($id, $field_name);

  // Source field not in displays.
  $display = \Drupal::service('entity_display.repository')
    ->getViewDisplay('media', $id);
  $components = $display
    ->getComponents();
  $this
    ->assertArrayHasKey($field_name, $components);
  $this
    ->assertSame('entity_reference_entity_id', $components[$field_name]['type']);
  $display = \Drupal::service('entity_display.repository')
    ->getFormDisplay('media', $id);
  $components = $display
    ->getComponents();
  $this
    ->assertArrayHasKey($field_name, $components);
  $this
    ->assertSame('entity_reference_autocomplete_tags', $components[$field_name]['type']);
}