public function ManageFieldsTest::testPreconfiguredFields in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field_ui/src/Tests/ManageFieldsTest.php \Drupal\field_ui\Tests\ManageFieldsTest::testPreconfiguredFields()
Tests the "preconfigured field" functionality.
See also
\Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface
File
- core/
modules/ field_ui/ src/ Tests/ ManageFieldsTest.php, line 697 - Contains \Drupal\field_ui\Tests\ManageFieldsTest.
Class
- ManageFieldsTest
- Tests the Field UI "Manage fields" screen.
Namespace
Drupal\field_ui\TestsCode
public function testPreconfiguredFields() {
$this
->drupalGet('admin/structure/types/manage/article/fields/add-field');
// Check that the preconfigured field option exist alongside the regular
// field type option.
$this
->assertOption('edit-new-storage-type', 'field_ui:test_field_with_preconfigured_options:custom_options');
$this
->assertOption('edit-new-storage-type', 'test_field_with_preconfigured_options');
// Add a field with every possible preconfigured value.
$this
->fieldUIAddNewField(NULL, 'test_custom_options', 'Test label', 'field_ui:test_field_with_preconfigured_options:custom_options');
$field_storage = FieldStorageConfig::loadByName('node', 'field_test_custom_options');
$this
->assertEqual($field_storage
->getCardinality(), FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this
->assertEqual($field_storage
->getSetting('test_field_storage_setting'), 'preconfigured_storage_setting');
$field = FieldConfig::loadByName('node', 'article', 'field_test_custom_options');
$this
->assertTrue($field
->isRequired());
$this
->assertEqual($field
->getSetting('test_field_setting'), 'preconfigured_field_setting');
$form_display = entity_get_form_display('node', 'article', 'default');
$this
->assertEqual($form_display
->getComponent('field_test_custom_options')['type'], 'test_field_widget_multiple');
$view_display = entity_get_display('node', 'article', 'default');
$this
->assertEqual($view_display
->getComponent('field_test_custom_options')['type'], 'field_test_multiple');
}