function MediaLibraryWidgetTest::setUp
Same name in other branches
- 8.9.x core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryWidgetTest::setUp()
- 10 core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryWidgetTest::setUp()
- 11.x core/modules/media_library/tests/src/Kernel/MediaLibraryWidgetTest.php \Drupal\Tests\media_library\Kernel\MediaLibraryWidgetTest::setUp()
Overrides KernelTestBase::setUp
File
-
core/
modules/ media_library/ tests/ src/ Kernel/ MediaLibraryWidgetTest.php, line 56
Class
- MediaLibraryWidgetTest
- Tests the media library widget.
Namespace
Drupal\Tests\media_library\KernelCode
protected function setUp() : void {
parent::setUp();
$this->baseField = BaseFieldDefinition::create('entity_reference')->setName('media')
->setSetting('target_type', 'media')
->setSetting('handler_settings', [
'target_bundles' => [
'test_type' => 'test_type',
],
]);
$this->container
->get('state')
->set('entity_test.additional_base_field_definitions', [
'media' => $this->baseField,
]);
$this->container
->get('state')
->set('entity_test_rev.additional_base_field_definitions', [
'media' => $this->baseField,
]);
$this->installEntitySchema('entity_test');
$this->installEntitySchema('entity_test_rev');
$this->installEntitySchema('user');
$this->installSchema('system', [
'sequences',
]);
$this->installConfig([
'system',
'image',
'media',
'media_library',
]);
MediaType::create([
'id' => 'test_type',
'label' => 'Test type',
'source' => 'image',
])->save();
// Create user 1 so the test user doesn't bypass access control.
$this->createUser();
$this->adminUser = $this->createUser([
'administer entity_test content',
'view media',
]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.