function EntityDisplayFormBaseTest::setUp

Same name in other branches
  1. 10 core/modules/field_ui/tests/src/Functional/EntityDisplayFormBaseTest.php \Drupal\Tests\field_ui\Functional\EntityDisplayFormBaseTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/field_ui/tests/src/Functional/EntityDisplayFormBaseTest.php, line 31

Class

EntityDisplayFormBaseTest
Tests the UI for configuring entity displays.

Namespace

Drupal\Tests\field_ui\Functional

Code

protected function setUp() : void {
    parent::setUp();
    foreach (entity_test_entity_types() as $entity_type) {
        // Auto-create fields for testing.
        FieldStorageConfig::create([
            'entity_type' => $entity_type,
            'field_name' => 'field_test_no_plugin',
            'type' => 'field_test',
            'cardinality' => 1,
        ])->save();
        FieldConfig::create([
            'entity_type' => $entity_type,
            'field_name' => 'field_test_no_plugin',
            'bundle' => $entity_type,
            'label' => 'Test field with no plugin',
            'translatable' => FALSE,
        ])->save();
        \Drupal::service('entity_display.repository')->getFormDisplay($entity_type, $entity_type)
            ->setComponent('field_test_no_plugin', [
            'type' => 'test_field_widget',
        ])
            ->save();
    }
    $this->drupalLogin($this->drupalCreateUser([
        'administer entity_test form display',
    ]));
}

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