protected function EmbeddedFormWidgetTest::setUp in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media_library/tests/src/FunctionalJavascript/EmbeddedFormWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EmbeddedFormWidgetTest::setUp()
Overrides BrowserTestBase::setUp
File
- core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ EmbeddedFormWidgetTest.php, line 36
Class
- EmbeddedFormWidgetTest
- Tests media widget nested inside another widget.
Namespace
Drupal\Tests\media_library\FunctionalJavascriptCode
protected function setUp() {
parent::setUp();
$display_repository = $this->container
->get('entity_display.repository');
FieldStorageConfig::create([
'field_name' => 'media_image_field',
'entity_type' => 'node',
'type' => 'entity_reference',
'settings' => [
'target_type' => 'media',
'required' => TRUE,
],
])
->save();
FieldConfig::create([
'label' => 'A Media Image Field',
'field_name' => 'media_image_field',
'entity_type' => 'node',
'bundle' => 'basic_page',
'field_type' => 'entity_reference',
'required' => TRUE,
'settings' => [
'handler_settings' => [
'target_bundles' => [
'type_three' => 'type_three',
],
],
],
])
->save();
$display_repository
->getFormDisplay('node', 'basic_page')
->setComponent('media_image_field', [
'type' => 'media_library_widget',
'region' => 'content',
'settings' => [
'media_types' => [
'type_three',
],
],
])
->save();
$this
->config('media_library.settings')
->set('advanced_ui', TRUE)
->save();
$user = $this
->drupalCreateUser([
'access content',
'access media overview',
'edit own basic_page content',
'create basic_page content',
'create media',
'view media',
]);
$this
->drupalLogin($user);
}