You are here

protected function MediaLibraryDisplayModeTest::assertViewDisplay in Drupal 8

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

Parameters

string $type_id: The media type ID.

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

1 call to MediaLibraryDisplayModeTest::assertViewDisplay()
MediaLibraryDisplayModeTest::testDisplayModes in core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php
Tests that the Media Library can automatically configure display modes.

File

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

Class

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

Namespace

Drupal\Tests\media_library\Functional

Code

protected function assertViewDisplay($type_id, $image_style) {
  $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']);
}