function MediaSourceTest::testDifferentSourceFieldDisplays

Same name in other branches
  1. 9 core/modules/media/tests/src/Kernel/MediaSourceTest.php \Drupal\Tests\media\Kernel\MediaSourceTest::testDifferentSourceFieldDisplays()
  2. 8.9.x core/modules/media/tests/src/Kernel/MediaSourceTest.php \Drupal\Tests\media\Kernel\MediaSourceTest::testDifferentSourceFieldDisplays()
  3. 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 576

Class

MediaSourceTest
Tests media source plugins related logic.

Namespace

Drupal\Tests\media\Kernel

Code

public function testDifferentSourceFieldDisplays() : void {
    $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']);
}

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