You are here

protected function FormJSAddMoreTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/FunctionalJavascript/FormJSAddMoreTest.php \Drupal\Tests\field\FunctionalJavascript\FormJSAddMoreTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/field/tests/src/FunctionalJavascript/FormJSAddMoreTest.php, line 31

Class

FormJSAddMoreTest
Tests add more behavior for a multiple value field.

Namespace

Drupal\Tests\field\FunctionalJavascript

Code

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