function MediaLibraryDisplayModeTest::assertViewDisplay

Same name in other branches
  1. 9 core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php \Drupal\Tests\media_library\Functional\MediaLibraryDisplayModeTest::assertViewDisplay()
  2. 10 core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php \Drupal\Tests\media_library\Functional\MediaLibraryDisplayModeTest::assertViewDisplay()
  3. 11.x 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']);
}

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