diff --git a/core/modules/field_ui/src/Tests/ManageFieldsTest.php b/core/modules/field_ui/src/Tests/ManageFieldsTest.php index cd5ff6b..08cf045 100644 --- a/core/modules/field_ui/src/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/src/Tests/ManageFieldsTest.php @@ -494,7 +494,6 @@ function testHiddenFields() { // Check that the field type is not available in the 'add new field' row. $this->drupalGet('admin/structure/types/manage/' . $this->type . '/fields/add-field'); $this->assertFalse($this->xpath('//select[@id="edit-new-storage-type"]//option[@value="hidden_test_field"]'), "The 'add new field' select respects field types 'no_ui' property."); - $this->assertTrue($this->xpath('//select[@id="edit-new-storage-type"]//option[@value="shape"]'), "The 'add new field' select shows a valid option."); // Create a field storage and a field programmatically. $field_name = 'hidden_test_field'; @@ -527,16 +526,24 @@ function testHiddenFields() { $this->assertTrue($this->xpath('//select[@id="edit-existing-storage-name"]//option[@value=:field_name]', array(':field_name' => 'field_tags')), "The 're-use existing field' select shows a valid option."); // Check that non-configurable fields are not available. - $field_types = \Drupal::service('plugin.manager.field.field_type')->getDefinitions(); + /** @var \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_plugin_manager */ + $field_type_plugin_manager = \Drupal::service('plugin.manager.field.field_type'); + foreach ($field_type_plugin_manager->getGroupedDefinitions($field_type_plugin_manager->getUiDefinitions()) as $category => $field_types) { foreach ($field_types as $field_type => $definition) { if (empty($definition['no_ui'])) { + if ($category) { + $this->assertTrue($this->xpath('//select[@id="edit-new-storage-type"]//optgroup[@label=:category]//option[@value=:field_type]', array(':category' => $category, ':field_type' => $field_type)), String::format('Configurable field type @field_type of @category category is available.', array('@field_type' => $field_type, '@category' => $category))); + } + else { $this->assertTrue($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', array(':field_type' => $field_type)), String::format('Configurable field type @field_type is available.', array('@field_type' => $field_type))); } + } else { $this->assertFalse($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', array(':field_type' => $field_type)), String::format('Non-configurable field type @field_type is not available.', array('@field_type' => $field_type))); } } } + } /** * Tests renaming a bundle.