function MultipleValueWidgetTest::setUp

Same name in other branches
  1. 11.x core/modules/field/tests/src/FunctionalJavascript/MultipleValueWidgetTest.php \Drupal\Tests\field\FunctionalJavascript\MultipleValueWidgetTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/field/tests/src/FunctionalJavascript/MultipleValueWidgetTest.php, line 33

Class

MultipleValueWidgetTest
Tests widget form for a multiple value field.

Namespace

Drupal\Tests\field\FunctionalJavascript

Code

protected function setUp() : void {
    parent::setUp();
    $account = $this->drupalCreateUser([
        'view test entity',
        'administer entity_test content',
    ]);
    $this->drupalLogin($account);
    $field = [
        'field_name' => 'field_unlimited',
        'entity_type' => 'entity_test',
        'bundle' => 'entity_test',
        'label' => $this->randomMachineName() . '_label',
        'description' => '[site:name]_description',
        'weight' => mt_rand(0, 127),
        'settings' => [
            'test_field_setting' => $this->randomMachineName(),
        ],
    ];
    FieldStorageConfig::create([
        'field_name' => 'field_unlimited',
        'entity_type' => 'entity_test',
        'type' => 'test_field',
        'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
    ])->save();
    FieldConfig::create($field)->save();
    $entity_form_display = EntityFormDisplay::load($field['entity_type'] . '.' . $field['bundle'] . '.default');
    $entity_form_display->setComponent($field['field_name'])
        ->save();
}

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