You are here

protected function ConditionalFieldSelectMultipleTest::setUp in Conditional Fields 4.x

Same name and namespace in other branches
  1. 8 tests/src/FunctionalJavascript/ConditionalFieldSelectMultipleTest.php \Drupal\Tests\conditional_fields\FunctionalJavascript\ConditionalFieldSelectMultipleTest::setUp()

Overrides ConditionalFieldTestBase::setUp

File

tests/src/FunctionalJavascript/ConditionalFieldSelectMultipleTest.php, line 72

Class

ConditionalFieldSelectMultipleTest
Test Conditional Fields SelectMultiple Plugin.

Namespace

Drupal\Tests\conditional_fields\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this->fieldSelector = "[name=\"field_{$this->fieldName}[]\"]";
  $this->fieldStorageDefinition = [
    'field_name' => 'field_' . $this->fieldName,
    'entity_type' => 'node',
    'type' => 'list_integer',
    'cardinality' => -1,
    'settings' => [
      'allowed_values' => [
        'One',
        'Two',
        'Three',
      ],
    ],
  ];
  $this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
  $this->fieldStorage
    ->save();
  $this->field = FieldConfig::create([
    'field_storage' => $this->fieldStorage,
    'bundle' => 'article',
  ]);
  $this->field
    ->save();
  EntityFormDisplay::load('node.article.default')
    ->setComponent('field_' . $this->fieldName, [
    'type' => 'options_select',
  ])
    ->save();
}