function MediaLibraryDisplayModeTest::assertViewDisplay
Same name in other branches
- 9 core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php \Drupal\Tests\media_library\Functional\MediaLibraryDisplayModeTest::assertViewDisplay()
- 8.9.x core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php \Drupal\Tests\media_library\Functional\MediaLibraryDisplayModeTest::assertViewDisplay()
- 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.
@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.
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 271
Class
- MediaLibraryDisplayModeTest
- Tests that the Media Library automatically configures form/view modes.
Namespace
Drupal\Tests\media_library\FunctionalCode
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']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.