function MediaLibraryDisplayModeTest::assertFormDisplay
Same name in other branches
- 9 core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php \Drupal\Tests\media_library\Functional\MediaLibraryDisplayModeTest::assertFormDisplay()
- 10 core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php \Drupal\Tests\media_library\Functional\MediaLibraryDisplayModeTest::assertFormDisplay()
- 11.x core/modules/media_library/tests/src/Functional/MediaLibraryDisplayModeTest.php \Drupal\Tests\media_library\Functional\MediaLibraryDisplayModeTest::assertFormDisplay()
Asserts the media library form display components for a media type.
Parameters
string $type_id: The media type ID.
bool $has_name: Whether the media library form display should contain the name field or not.
bool $has_source_field: Whether the media library form display should contain the source field or not.
1 call to MediaLibraryDisplayModeTest::assertFormDisplay()
- 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 219
Class
- MediaLibraryDisplayModeTest
- Tests that the Media Library automatically configures form/view modes.
Namespace
Drupal\Tests\media_library\FunctionalCode
protected function assertFormDisplay($type_id, $has_name, $has_source_field) {
// These components are added by default and invisible.
$components = [
'revision_log_message',
'langcode',
];
// Only assert the name and source field if needed.
if ($has_name) {
$components[] = 'name';
}
if ($has_source_field) {
$type = MediaType::load($type_id);
$components[] = $type->getSource()
->getSourceFieldDefinition($type)
->getName();
}
$form_display = EntityFormDisplay::load('media.' . $type_id . '.media_library');
$this->assertInstanceOf(EntityFormDisplay::class, $form_display);
$actual_components = array_keys($form_display->getComponents());
sort($components);
sort($actual_components);
$this->assertSame($components, $actual_components);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.