function MediaLibraryJavascriptOrderTest::setUp
Same name and namespace in other branches
- main core/themes/default_admin/tests/src/Kernel/MediaLibraryJavascriptOrderTest.php \Drupal\Tests\default_admin\Kernel\MediaLibraryJavascriptOrderTest::setUp()
File
-
core/
themes/ default_admin/ tests/ src/ Kernel/ MediaLibraryJavascriptOrderTest.php, line 46
Class
- MediaLibraryJavascriptOrderTest
- Tests that media library UI JS is not added before its dependencies.
Namespace
Drupal\Tests\default_admin\KernelCode
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('entity_test');
$this->installEntitySchema('user');
$this->installConfig([
'system',
'image',
'media',
'media_library',
]);
MediaType::create([
'id' => 'test_type',
'label' => 'Test type',
'source' => 'image',
])->save();
$fieldStorageConfig = FieldStorageConfig::create([
'field_name' => 'field_media',
'entity_type' => 'entity_test',
'type' => 'entity_reference',
'settings' => [
'target_type' => 'media',
],
]);
$fieldStorageConfig->save();
FieldConfig::create([
'field_storage' => $fieldStorageConfig,
'bundle' => 'entity_test',
'settings' => [
'handler_settings' => [
'target_bundles' => [
'test_type' => 'test_type',
],
],
],
])->save();
// Set the media field widget to media library, so that the JS library is
// added to the entity_test form.
$display = EntityFormDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
])->setStatus(TRUE);
$display->setComponent('field_media', [
'type' => 'media_library_widget',
]);
$display->save();
$this->container
->get(ThemeInstallerInterface::class)
->install([
'default_admin',
]);
// Turn off JS preprocessing, so that the individual script tags can be
// found on the page.
$this->config('system.performance')
->set('js.preprocess', 0)
->save();
$this->config('system.theme')
->set('default', 'default_admin')
->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.