You are here

protected function ConditionalFieldLinkFieldTest::setUp in Conditional Fields 8

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

Overrides ConditionalFieldTestBase::setUp

File

tests/src/FunctionalJavascript/ConditionalFieldLinkFieldTest.php, line 76

Class

ConditionalFieldLinkFieldTest
Test Conditional Fields Link field plugin.

Namespace

Drupal\Tests\conditional_fields\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this->fieldSelector = '[name="' . $this->fieldName . '[0][uri]"]';
  $this->fieldStorageDefinition = [
    'field_name' => $this->fieldName,
    'entity_type' => 'node',
    'type' => 'link',
  ];
  $this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
  $this->fieldStorage
    ->save();
  $this->field = FieldConfig::create([
    'field_storage' => $this->fieldStorage,
    'bundle' => 'article',
    'settings' => [
      'title' => DRUPAL_DISABLED,
      'link_type' => LinkItemInterface::LINK_GENERIC,
    ],
  ]);
  $this->field
    ->save();
  EntityFormDisplay::load('node.article.default')
    ->setComponent($this->fieldName, [
    'type' => 'link_default',
  ])
    ->save();
}