You are here

protected function DiffPluginTest::addArticleTextField in Diff 8

Adds a text field.

Parameters

string $field_name: The machine field name.

string $label: The field label.

string $field_type: The field type.

string $widget_type: The widget type.

2 calls to DiffPluginTest::addArticleTextField()
DiffPluginTest::testApplicablePlugin in tests/src/Functional/DiffPluginTest.php
Tests plugin applicability and weight relevance.
DiffPluginTest::testFieldNoAccess in tests/src/Functional/DiffPluginTest.php
Tests the access check for a field while comparing revisions.

File

tests/src/Functional/DiffPluginTest.php, line 38

Class

DiffPluginTest
Tests the Diff module plugins.

Namespace

Drupal\Tests\diff\Functional

Code

protected function addArticleTextField($field_name, $label, $field_type, $widget_type) {

  // Create a field.
  $field_storage = FieldStorageConfig::create([
    'field_name' => $field_name,
    'entity_type' => 'node',
    'type' => $field_type,
  ]);
  $field_storage
    ->save();
  FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => 'article',
    'label' => $label,
  ])
    ->save();
  $this->formDisplay
    ->load('node.article.default')
    ->setComponent($field_name, [
    'type' => $widget_type,
  ])
    ->save();
  $this->viewDisplay
    ->load('node.article.default')
    ->setComponent($field_name)
    ->save();
}