diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php index ab03d41..c0f806f 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php @@ -117,4 +117,41 @@ function testCommentFormat() { $edit = array('comment_body[und][0][value]' => $this->randomName(8)); $this->drupalPost('node/' . $this->node->nid, $edit, t('Save')); } + + /** + * Tests that comment fields can be managed through the UI. + */ + function testCommentFieldUI() { + // Log in as the administrative user. + $this->drupalLogin($this->admin_user); + + // Create a test node type and a node of that type. + $this->drupalCreateContentType(array('type' => 'test_node_type')); + $node = $this->drupalCreateNode(array('type' => 'test_node_type')); + + // Add a field to the comments for this node type through the UI. + $edit = array( + 'fields[_add_new_field][label]' => t('Test field label'), + 'fields[_add_new_field][field_name]' => 'test_field', + 'fields[_add_new_field][type]' => 'text', + 'fields[_add_new_field][widget_type]' => 'text_textfield', + ); + $this->drupalPost('admin/structure/types/manage/test_node_type/comment/fields', $edit, t('Save')); + + // Confirm that the field is present + $this->drupalGet('comment/reply/' . $node->nid); + $this->assertText(t('Test field label')); + + $this->drupalGet('admin/structure/types/manage/test_node_type/comment/fields'); + + // Delete the field through the UI. + $this->drupalPost('admin/structure/types/manage/test_node_type/comment/fields/field_test_field/delete', array(), t('Delete')); + $this->assertResponse(200); + + // Confirm that the field is no longer present + $this->drupalGet('comment/reply/' . $node->nid); + $this->assertNoText(t('Test field label')); + + } + } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php index 39324bf..9df56b7 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/FieldUiTestBase.php @@ -124,6 +124,7 @@ function fieldUIDeleteField($bundle_path, $field_name, $label, $bundle_label) { // Submit confirmation form. $this->drupalPost(NULL, array(), t('Delete')); + $this->assertResponse(200); $this->assertRaw(t('The field %label has been deleted from the %type content type.', array('%label' => $label, '%type' => $bundle_label)), 'Delete message was found.'); // Check that the field does not appear in the overview form. diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php index 17d4bd7..705025e 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php @@ -353,4 +353,27 @@ function testDuplicateFieldName() { $this->assertText(t('The machine-readable name is already in use. It must be unique.')); $this->assertUrl($url, array(), 'Stayed on the same page.'); } + + /** + * Tests that deletion removes fields and instances as expected for a term. + */ + function testDeleteTaxonomyField() { + // Create a new field. + $bundle_path = 'admin/structure/taxonomy/tags'; + $edit1 = array( + 'fields[_add_new_field][label]' => $this->field_label, + 'fields[_add_new_field][field_name]' => $this->field_name_input, + ); + $this->fieldUIAddNewField($bundle_path, $edit1); + + // Delete the field. + $this->fieldUIDeleteField($bundle_path, $this->field_name, $this->field_label, 'Tags'); + + // Reset the fields info. + field_info_cache_clear(); + // Check that the field instance was deleted. + $this->assertNull(field_info_instance('taxonomy_term', $this->field_name, 'tags'), 'Field instance was deleted.'); + // Check that the field was deleted too. + $this->assertNull(field_info_field($this->field_name), 'Field was deleted.'); + } }