diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-09-22 08:44:04 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-09-22 08:44:04 +0000 |
commit | 29addd06b26192f0d3e1761e7e13b291baf7c5a1 (patch) | |
tree | bd0241978398249914c776d1f949cab6b34fed46 /modules/field/field.test | |
parent | a4b833b6deb353d28ad51f9c648061bd0a83c950 (diff) | |
download | brdo-29addd06b26192f0d3e1761e7e13b291baf7c5a1.tar.gz brdo-29addd06b26192f0d3e1761e7e13b291baf7c5a1.tar.bz2 |
- Patch #569364 by bjaspan, yched: handle failures on field storage creation.
Diffstat (limited to 'modules/field/field.test')
-rw-r--r-- | modules/field/field.test | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/modules/field/field.test b/modules/field/field.test index 9d770076f..b530885ad 100644 --- a/modules/field/field.test +++ b/modules/field/field.test @@ -1560,6 +1560,35 @@ class FieldCrudTestCase extends FieldTestCase { } /** + * Test failure to create a field. + */ + function testCreateFieldFail() { + $field_name = 'duplicate'; + $field_definition = array('field_name' => $field_name, 'type' => 'test_field'); + $query = db_select('field_config')->condition('field_name', $field_name)->countQuery(); + + // The field does not appear in field_config. + $count = $query->execute()->fetchField(); + $this->assertEqual($count, 0, 'A field_config row for the field does not exist.'); + + // Make field creation fail. + variable_set('field_storage_module', 'field_test'); + + // Try to create the field. + try { + $field = field_create_field($field_definition); + $this->assertTrue(FALSE, 'Field creation (correctly) fails.'); + } + catch (Exception $e) { + $this->assertTrue(TRUE, 'Field creation (correctly) fails.'); + } + + // The field does not appear in field_config. + $count = $query->execute()->fetchField(); + $this->assertEqual($count, 0, 'A field_config row for the field does not exist.'); + } + + /** * Test reading back a field definition. */ function testReadField() { |