You are here

protected function ConditionalFieldNumberTest::setUp in Conditional Fields 8

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

Overrides ConditionalFieldTestBase::setUp

File

tests/src/FunctionalJavascript/ConditionalFieldNumberTest.php, line 60

Class

ConditionalFieldNumberTest
Test Conditional Fields Number Plugin.

Namespace

Drupal\Tests\conditional_fields\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this->fieldSelector = '[name="field_' . $this->fieldName . '[0][value]"]';
  FieldStorageConfig::create([
    'field_name' => 'field_' . $this->fieldName,
    'entity_type' => 'node',
    'type' => 'integer',
    'cardinality' => 1,
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_' . $this->fieldName,
    'entity_type' => 'node',
    'bundle' => 'article',
    'settings' => [
      'min' => '',
      'max' => '',
      'prefix' => '',
    ],
  ])
    ->save();
  EntityFormDisplay::load('node.article.default')
    ->setComponent('field_' . $this->fieldName, [
    'type' => 'number',
    'settings' => [
      'prefix_suffix' => FALSE,
    ],
  ])
    ->save();
}