diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-12-15 04:13:48 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2010-12-15 04:13:48 +0000 |
commit | c2ec8e397a1479b28a02af79af4b75390ad57c2e (patch) | |
tree | 0c0e810f3fccc258afabb88ebaaaf060bff86a0c /modules/field/tests | |
parent | 72e8023d493a7d99af2e84878f40cd8eeef07be7 (diff) | |
download | brdo-c2ec8e397a1479b28a02af79af4b75390ad57c2e.tar.gz brdo-c2ec8e397a1479b28a02af79af4b75390ad57c2e.tar.bz2 |
#915906 by jbrown, yched: Fixed Deleting node type with only instance of a field leaves the field in a strange zombie state
Diffstat (limited to 'modules/field/tests')
-rw-r--r-- | modules/field/tests/field.test | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/modules/field/tests/field.test b/modules/field/tests/field.test index ccf8d2efe..05a6ede01 100644 --- a/modules/field/tests/field.test +++ b/modules/field/tests/field.test @@ -2545,6 +2545,11 @@ class FieldInstanceCrudTestCase extends FieldTestCase { // Make sure the other field instance is not deleted. $another_instance = field_read_instance('test_entity', $this->another_instance_definition['field_name'], $this->another_instance_definition['bundle']); $this->assertTrue(!empty($another_instance) && empty($another_instance['deleted']), t('A non-deleted field instance is not marked for deletion.')); + + // Make sure the field is deleted when its last instance is deleted. + field_delete_instance($another_instance); + $field = field_read_field($another_instance['field_name'], array('include_deleted' => TRUE)); + $this->assertTrue(!empty($field['deleted']), t('A deleted field is marked for deletion after all its instances have been marked for deletion.')); } } @@ -3081,30 +3086,32 @@ class FieldBulkDeleteTestCase extends FieldTestCase { function testPurgeField() { $field = reset($this->fields); - foreach ($this->bundles as $bundle) { - // Delete the instance. - $instance = field_info_instance($this->entity_type, $field['field_name'], $bundle); - field_delete_instance($instance); + // Delete the first instance. + $instance = field_info_instance($this->entity_type, $field['field_name'], 'bb_1'); + field_delete_instance($instance); + + // Purge the data. + field_purge_batch(10); - // Purge the data. - field_purge_batch(10); + // Purge again to purge the instance. + field_purge_batch(0); - // Purge again to purge the instance. - field_purge_batch(0); + // The field still exists, not deleted. + $fields = field_read_fields(array('id' => $field['id']), array('include_deleted' => 1)); + $this->assertTrue(isset($fields[$field['id']]) && !$fields[$field['id']]['deleted'], 'The field exists and is not deleted'); - // The field still exists, not deleted, because it was never deleted. - $fields = field_read_fields(array('id' => $field['id']), array('include_deleted' => 1, 'include_inactive' => 1)); - $this->assertTrue(isset($fields[$field['id']]), 'The field exists and is not deleted'); - } + // Delete the second instance. + $instance = field_info_instance($this->entity_type, $field['field_name'], 'bb_2'); + field_delete_instance($instance); - // Delete the field. - field_delete_field($field['field_name']); + // Purge the data. + field_purge_batch(10); // The field still exists, deleted. - $fields = field_read_fields(array('id' => $field['id']), array('include_deleted' => 1, 'include_inactive' => 1)); - $this->assertEqual($fields[$field['id']]['deleted'], 1, 'The field exists and is deleted'); + $fields = field_read_fields(array('id' => $field['id']), array('include_deleted' => 1)); + $this->assertTrue(isset($fields[$field['id']]) && $fields[$field['id']]['deleted'], 'The field exists and is deleted'); - // Purge the field. + // Purge again to purge the instance and the field. field_purge_batch(0); // The field is gone. |