protected function LingotekFieldOptionsTranslationTest::createOptionsField in Lingotek Translation 8
Helper function to create list field of a given type.
Parameters
string $type: 'list_integer', 'list_float' or 'list_string'
1 call to LingotekFieldOptionsTranslationTest::createOptionsField()
- LingotekFieldOptionsTranslationTest::setUp in src/
Tests/ LingotekFieldOptionsTranslationTest.php - Sets up a Drupal site for running functional and integration tests.
File
- src/
Tests/ LingotekFieldOptionsTranslationTest.php, line 114
Class
- LingotekFieldOptionsTranslationTest
- Tests translating a options field.
Namespace
Drupal\lingotek\TestsCode
protected function createOptionsField($type, $bundle, $field_name, $label) {
// Create a field.
FieldStorageConfig::create(array(
'field_name' => $field_name,
'entity_type' => 'node',
'type' => $type,
))
->save();
FieldConfig::create([
'field_name' => $field_name,
'label' => $label,
'entity_type' => 'node',
'bundle' => $bundle,
])
->save();
entity_get_form_display('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 = array(
'settings[allowed_values]' => $input_string,
);
$this
->drupalPostForm($adminPath, $edit, t('Save field settings'));
}