You are here

protected function ConditionalFieldDateListTest::setUp in Conditional Fields 8

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

Overrides ConditionalFieldTestBase::setUp

File

tests/src/FunctionalJavascript/ConditionalFieldDateListTest.php, line 49

Class

ConditionalFieldDateListTest
Test Conditional Fields States.

Namespace

Drupal\Tests\conditional_fields\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this->fieldSelectors = [
    'day' => "[name=\"{$this->fieldName}[0][value][day]\"]",
    'month' => "[name=\"{$this->fieldName}[0][value][month]\"]",
    'year' => "[name=\"{$this->fieldName}[0][value][year]\"]",
  ];
  $fieldStorageDefinition = [
    'field_name' => $this->fieldName,
    'entity_type' => 'node',
    'type' => 'datetime',
    'settings' => [
      'datetime_type' => 'date',
    ],
  ];
  $fieldStorage = FieldStorageConfig::create($fieldStorageDefinition);
  $fieldStorage
    ->save();
  $field = FieldConfig::create([
    'field_storage' => $fieldStorage,
    'bundle' => 'article',
  ]);
  $field
    ->save();
  EntityFormDisplay::load('node.article.default')
    ->setComponent($this->fieldName, [
    'type' => 'datetime_datelist',
  ])
    ->save();
}