Tests that deletion removes fields and instances as expected.
function testDeleteField() {
// Create a new field.
$bundle_path1 = 'admin/structure/types/manage/' . $this->type;
$edit1 = array(
'fields[_add_new_field][label]' => $this->field_label,
'fields[_add_new_field][field_name]' => $this->field_name_input,
);
$this
->fieldUIAddNewField($bundle_path1, $edit1);
// Create an additional node type.
$type_name2 = strtolower($this
->randomName(8)) . '_test';
$type2 = $this
->drupalCreateContentType(array(
'name' => $type_name2,
'type' => $type_name2,
));
$type_name2 = $type2->type;
// Add an instance to the second node type.
$bundle_path2 = 'admin/structure/types/manage/' . $type_name2;
$edit2 = array(
'fields[_add_existing_field][label]' => $this->field_label,
'fields[_add_existing_field][field_name]' => $this->field_name,
);
$this
->fieldUIAddExistingField($bundle_path2, $edit2);
// Delete the first instance.
$this
->fieldUIDeleteField($bundle_path1, $this->field_name, $this->field_label, $this->type);
// Reset the fields info.
field_info_cache_clear();
// Check that the field instance was deleted.
$this
->assertNull(field_info_instance('node', $this->field_name, $this->type), 'Field instance was deleted.');
// Check that the field was not deleted
$this
->assertNotNull(field_info_field($this->field_name), 'Field was not deleted.');
// Delete the second instance.
$this
->fieldUIDeleteField($bundle_path2, $this->field_name, $this->field_label, $type_name2);
// Reset the fields info.
field_info_cache_clear();
// Check that the field instance was deleted.
$this
->assertNull(field_info_instance('node', $this->field_name, $type_name2), 'Field instance was deleted.');
// Check that the field was deleted too.
$this
->assertNull(field_info_field($this->field_name), 'Field was deleted.');
}