You are here

public function MediaSourceTest::testHiddenSourceField in Drupal 10

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

Tests hidden source field in media type.

File

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

Class

MediaSourceTest
Tests media source plugins related logic.

Namespace

Drupal\Tests\media\Kernel

Code

public function testHiddenSourceField() {
  $id = 'test_hidden_source_field';
  $field_name = 'field_media_hidden';
  $this
    ->createMediaTypeViaForm($id, $field_name);

  // Source field not in displays.
  $display = \Drupal::service('entity_display.repository')
    ->getViewDisplay('media', $id);
  $this
    ->assertArrayNotHasKey($field_name, $display
    ->getComponents());
  $display = \Drupal::service('entity_display.repository')
    ->getFormDisplay('media', $id);
  $this
    ->assertArrayNotHasKey($field_name, $display
    ->getComponents());
}