function OptionsFieldUITest::createOptionsField

Same name in other branches
  1. 8.9.x core/modules/options/tests/src/Functional/OptionsFieldUITest.php \Drupal\Tests\options\Functional\OptionsFieldUITest::createOptionsField()
  2. 10 core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUITest.php \Drupal\Tests\options\FunctionalJavascript\OptionsFieldUITest::createOptionsField()
  3. 10 core/modules/options/tests/src/Functional/OptionsFieldUITest.php \Drupal\Tests\options\Functional\OptionsFieldUITest::createOptionsField()
  4. 11.x core/modules/options/tests/src/FunctionalJavascript/OptionsFieldUITest.php \Drupal\Tests\options\FunctionalJavascript\OptionsFieldUITest::createOptionsField()
  5. 11.x core/modules/options/tests/src/Functional/OptionsFieldUITest.php \Drupal\Tests\options\Functional\OptionsFieldUITest::createOptionsField()

Helper function to create list field of a given type.

Parameters

string $type: One of 'list_integer', 'list_float' or 'list_string'.

5 calls to OptionsFieldUITest::createOptionsField()
OptionsFieldUITest::testNodeDisplay in core/modules/options/tests/src/Functional/OptionsFieldUITest.php
Tests normal and key formatter display on node display.
OptionsFieldUITest::testOptionsAllowedValuesFloat in core/modules/options/tests/src/Functional/OptionsFieldUITest.php
Options (float) : test 'allowed values' input.
OptionsFieldUITest::testOptionsAllowedValuesInteger in core/modules/options/tests/src/Functional/OptionsFieldUITest.php
Options (integer) : test 'allowed values' input.
OptionsFieldUITest::testOptionsAllowedValuesText in core/modules/options/tests/src/Functional/OptionsFieldUITest.php
Options (text) : test 'allowed values' input.
OptionsFieldUITest::testOptionsTrimmedValuesText in core/modules/options/tests/src/Functional/OptionsFieldUITest.php
Options (text) : test 'trimmed values' input.

File

core/modules/options/tests/src/Functional/OptionsFieldUITest.php, line 288

Class

OptionsFieldUITest
Tests the Options field UI functionality.

Namespace

Drupal\Tests\options\Functional

Code

protected function createOptionsField($type) {
    // Create a field.
    FieldStorageConfig::create([
        'field_name' => $this->fieldName,
        'entity_type' => 'node',
        'type' => $type,
    ])
        ->save();
    FieldConfig::create([
        'field_name' => $this->fieldName,
        'entity_type' => 'node',
        'bundle' => $this->type,
    ])
        ->save();
    \Drupal::service('entity_display.repository')->getFormDisplay('node', $this->type)
        ->setComponent($this->fieldName)
        ->save();
    $this->adminPath = 'admin/structure/types/manage/' . $this->type . '/fields/node.' . $this->type . '.' . $this->fieldName . '/storage';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.