You are here

protected function OptionsFieldUITest::createOptionsField in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/options/src/Tests/OptionsFieldUITest.php \Drupal\options\Tests\OptionsFieldUITest::createOptionsField()

Helper function to create list field of a given type.

Parameters

string $type: 'list_integer', 'list_float' or 'list_string'

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

File

core/modules/options/src/Tests/OptionsFieldUITest.php, line 268
Contains \Drupal\options\Tests\OptionsFieldUITest.

Class

OptionsFieldUITest
Tests the Options field UI functionality.

Namespace

Drupal\options\Tests

Code

protected function createOptionsField($type) {

  // Create a field.
  entity_create('field_storage_config', array(
    'field_name' => $this->fieldName,
    'entity_type' => 'node',
    'type' => $type,
  ))
    ->save();
  entity_create('field_config', array(
    'field_name' => $this->fieldName,
    'entity_type' => 'node',
    'bundle' => $this->type,
  ))
    ->save();
  entity_get_form_display('node', $this->type, 'default')
    ->setComponent($this->fieldName)
    ->save();
  $this->adminPath = 'admin/structure/types/manage/' . $this->type . '/fields/node.' . $this->type . '.' . $this->fieldName . '/storage';
}