You are here

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

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

Overrides ConditionalFieldTestBase::setUp

File

tests/src/FunctionalJavascript/ConditionalFieldTextfieldTest.php, line 57

Class

ConditionalFieldTextfieldTest
Test Conditional Fields Text Handler.

Namespace

Drupal\Tests\conditional_fields\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this->fieldSelector = '[name="field_' . $this->fieldName . '[0][value]"]';
  $this->targetFieldWrapp = '.field--name-' . str_replace('_', '-', $this->targetFieldName);
  $fieldStorageDefinition = [
    'field_name' => 'field_' . $this->fieldName,
    'entity_type' => 'node',
    'type' => 'text',
    'cardinality' => 1,
  ];
  $fieldStorage = FieldStorageConfig::create($fieldStorageDefinition);
  $fieldStorage
    ->save();
  FieldConfig::create([
    'field_name' => 'field_' . $this->fieldName,
    'entity_type' => 'node',
    'bundle' => 'article',
  ])
    ->save();
  EntityFormDisplay::load('node.article.default')
    ->setComponent('field_' . $this->fieldName, [
    'type' => 'text_textfield',
  ])
    ->save();
}