function EmbeddedFormWidgetTest::setUp

Same name in other branches
  1. 9 core/modules/media_library/tests/src/FunctionalJavascript/EmbeddedFormWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EmbeddedFormWidgetTest::setUp()
  2. 8.9.x core/modules/media_library/tests/src/FunctionalJavascript/EmbeddedFormWidgetTest.php \Drupal\Tests\media_library\FunctionalJavascript\EmbeddedFormWidgetTest::setUp()
  3. 11.x 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 39

Class

EmbeddedFormWidgetTest
Tests media widget nested inside another widget.

Namespace

Drupal\Tests\media_library\FunctionalJavascript

Code

protected function setUp() : void {
    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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.