public function DateUpdatesTestCase::testUpdate7201 in Date 7.3
Test update 7200.
File
- tests/
DateUpdatesTestCase.test, line 83 - Test updates for the Date module.
Class
- DateUpdatesTestCase
- Test updates for the Date module.
Code
public function testUpdate7201() {
// The suffix that is used for the "all day" flag.
$all_day_suffix = '_all_day';
// Load the install file, so that the update script is available.
module_load_include('install', 'date');
$this
->assertEqual(function_exists('date_update_7201'), TRUE, 'Update 7201 exists.');
// All of the "date" fields added by the Date Test Feature module.
$field_names = array(
'field_date',
'field_date_range',
'field_date_repeat',
'field_datestamp',
'field_datestamp_range',
'field_datetime',
'field_datetime_range',
);
// Delete the field so that it can be added again through the update script.
// Yes, this is convoluted, but I'm not sure here's an easier way of doing
// it?
foreach ($field_names as $field_name) {
db_drop_field('field_data_' . $field_name, $field_name . $all_day_suffix);
}
// Force the schema to be rebuilt so that it correctly reports that the
// table was removed.
drupal_get_complete_schema(TRUE);
// Confirm the fields doesn't exist anymore.
// @todo Directly query the database to make sure the fields were actually
// removed. MySQL supports the "DESCRIBE $tablename" command, while
// PostgreSQL supports the "\d $tablename" command.
foreach ($field_names as $field_name) {
$this
->assertFalse(db_field_exists('field_data_' . $field_name, $field_name . $all_day_suffix), 'The "all_day" column was removed from the ' . $field_name . ' field.');
}
// Execute the update function.
date_update_7201();
// Rebuild the schema so that the field specs are properly loaded again.
drupal_get_complete_schema(TRUE);
// Confirm the fields now exist.
// @todo Directly query the database to make sure the fields were actually
// removed. DESCRIBE $tablename
foreach ($field_names as $field_name) {
// Check to see if the field now exists on the table.
$this
->assertTrue(db_field_exists('field_data_' . $field_name, $field_name . $all_day_suffix), 'The "all_day" column now exists for the ' . $field_name . ' field.');
}
}