You are here

protected function LingotekFieldOptionsTranslationTest::createOptionsField in Lingotek Translation 3.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()
  2. 4.0.x tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()
  3. 3.1.x tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()
  4. 3.2.x tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()
  5. 3.3.x tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()
  6. 3.4.x tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()
  7. 3.5.x tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()
  8. 3.6.x tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()
  9. 3.7.x tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()
  10. 3.8.x tests/src/Functional/LingotekFieldOptionsTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekFieldOptionsTranslationTest::createOptionsField()

Helper function to create list field of a given type.

Parameters

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

1 call to LingotekFieldOptionsTranslationTest::createOptionsField()
LingotekFieldOptionsTranslationTest::setUp in tests/src/Functional/LingotekFieldOptionsTranslationTest.php

File

tests/src/Functional/LingotekFieldOptionsTranslationTest.php, line 115

Class

LingotekFieldOptionsTranslationTest
Tests translating a options field.

Namespace

Drupal\Tests\lingotek\Functional

Code

protected function createOptionsField($type, $bundle, $field_name, $label) {

  // Create a field.
  FieldStorageConfig::create([
    'field_name' => $field_name,
    'entity_type' => 'node',
    'type' => $type,
  ])
    ->save();
  FieldConfig::create([
    'field_name' => $field_name,
    'label' => $label,
    'entity_type' => 'node',
    'bundle' => $bundle,
  ])
    ->save();
  EntityFormDisplay::load('node.' . $bundle . '.default')
    ->setComponent($field_name)
    ->save();
  $adminPath = 'admin/structure/types/manage/' . $bundle . '/fields/node.' . $bundle . '.' . $field_name . '/storage';
  $input_string = "zero|Zero\none|One";
  $edit = [
    'settings[allowed_values]' => $input_string,
  ];
  $this
    ->drupalPostForm($adminPath, $edit, t('Save field settings'));
}