protected function MediaSourceImageTest::assertViewDisplayConfigured in Drupal 9
Same name and namespace in other branches
- 8 core/modules/media/tests/src/FunctionalJavascript/MediaSourceImageTest.php \Drupal\Tests\media\FunctionalJavascript\MediaSourceImageTest::assertViewDisplayConfigured()
Asserts the proper entity view display components for a media type.
Parameters
string $media_type_id: The media type ID.
1 call to MediaSourceImageTest::assertViewDisplayConfigured()
- MediaSourceImageTest::testMediaImageSource in core/
modules/ media/ tests/ src/ FunctionalJavascript/ MediaSourceImageTest.php - Tests the image media source.
File
- core/
modules/ media/ tests/ src/ FunctionalJavascript/ MediaSourceImageTest.php, line 163
Class
- MediaSourceImageTest
- Tests the image media source.
Namespace
Drupal\Tests\media\FunctionalJavascriptCode
protected function assertViewDisplayConfigured($media_type_id) {
$assert_session = $this
->assertSession();
$type = MediaType::load($media_type_id);
$display = EntityViewDisplay::load('media.' . $media_type_id . '.' . EntityDisplayRepositoryInterface::DEFAULT_DISPLAY_MODE);
$this
->assertInstanceOf(EntityViewDisplay::class, $display);
$source_field_definition = $type
->getSource()
->getSourceFieldDefinition($type);
$component = $display
->getComponent($source_field_definition
->getName());
$this
->assertSame('visually_hidden', $component['label']);
if (ImageStyle::load('large')) {
$this
->assertSame('large', $component['settings']['image_style']);
}
else {
$this
->assertEmpty($component['settings']['image_style']);
}
$this
->assertEmpty($component['settings']['image_link']);
// Since components that aren't explicitly hidden can show up on the
// display edit form, check that only the image field appears enabled on
// the display edit form.
$this
->drupalGet('/admin/structure/media/manage/' . $media_type_id . '/display');
// Assert that only the source field is enabled.
$assert_session
->elementExists('css', 'input[name="' . $source_field_definition
->getName() . '_settings_edit"]');
$assert_session
->elementsCount('css', 'input[name$="_settings_edit"]', 1);
}