You are here

protected function MediaLibraryDisplayModeTest::assertViewDisplay in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php \Drupal\Tests\media_library\Functional\MediaLibraryDisplayModeTest::assertViewDisplay()
  2. 9 core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php \Drupal\Tests\media_library\Functional\MediaLibraryDisplayModeTest::assertViewDisplay()

Asserts the media library view display components for a media type.

@internal

Parameters

string $type_id: The media type ID.

string $image_style: The ID of the image style that should be configured for the thumbnail.

File

core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php, line 262

Class

MediaLibraryDisplayModeTest
Tests that the Media Library automatically configures form/view modes.

Namespace

Drupal\Tests\media_library\Functional

Code

protected function assertViewDisplay(string $type_id, string $image_style) : void {
  $view_display = EntityViewDisplay::load('media.' . $type_id . '.media_library');
  $this
    ->assertInstanceOf(EntityViewDisplay::class, $view_display);

  // Assert the media library view display contains only the thumbnail.
  $this
    ->assertSame([
    'thumbnail',
  ], array_keys($view_display
    ->getComponents()));

  // Assert the thumbnail image style.
  $thumbnail = $view_display
    ->getComponent('thumbnail');
  $this
    ->assertIsArray($thumbnail);
  $this
    ->assertSame($image_style, $thumbnail['settings']['image_style']);
}