diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-11-25 02:37:33 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2008-11-25 02:37:33 +0000 |
commit | 66df602593230a2483d6538927fd66310c28c3f8 (patch) | |
tree | 2aade9b5d8e859acbb252915a86ed6da3ff133de /modules/system/system.test | |
parent | b5e0a12fa9735679ca7b0d7f8a951d6840344321 (diff) | |
download | brdo-66df602593230a2483d6538927fd66310c28c3f8.tar.gz brdo-66df602593230a2483d6538927fd66310c28c3f8.tar.bz2 |
#314870 by Rob Loach, drewish, catch, and sun: Add hook API documentation to Drupal core.
Diffstat (limited to 'modules/system/system.test')
-rw-r--r-- | modules/system/system.test | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/system/system.test b/modules/system/system.test index a88cef457..1c6be0701 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -252,6 +252,41 @@ class CronRunTestCase extends DrupalWebTestCase { // Execute cron directly. $this->assertTrue(drupal_cron_run(), t('Cron ran successfully.')); } + + /** + * Ensure that temporary files are removed. + */ + function testTempFileCleanup() { + // Create files for all the possible combinations of age and status. We're + // using UPDATE statments rather than file_save() because it would set the + // timestamp. + + // Temporary file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. + $temp_old = file_save_data(''); + db_query('UPDATE {files} SET status = :status, timestamp = :timestamp WHERE fid = :fid', array(':status' => FILE_STATUS_TEMPORARY, ':timestamp' => 1, ':fid' => $temp_old->fid)); + $this->assertTrue(file_exists($temp_old->filepath), t('Old temp file was created correctly.')); + + // Temporary file that is less than DRUPAL_MAXIMUM_TEMP_FILE_AGE. + $temp_new = file_save_data(''); + db_query('UPDATE {files} SET status = :status WHERE fid = :fid', array(':status' => FILE_STATUS_TEMPORARY, ':fid' => $temp_new->fid)); + $this->assertTrue(file_exists($temp_new->filepath), t('New temp file was created correctly.')); + + // Permanent file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. + $perm_old = file_save_data(''); + db_query('UPDATE {files} SET timestamp = :timestamp WHERE fid = :fid', array(':timestamp' => 1, ':fid' => $perm_old->fid)); + $this->assertTrue(file_exists($perm_old->filepath), t('Old permanent file was created correctly.')); + + // Permanent file that is newer than DRUPAL_MAXIMUM_TEMP_FILE_AGE. + $perm_new = file_save_data(''); + $this->assertTrue(file_exists($perm_new->filepath), t('New permanent file was created correctly.')); + + // Run cron and then ensure that only the old, temp file was deleted. + $this->assertTrue(drupal_cron_run(), t('Cron ran successfully.')); + $this->assertFalse(file_exists($temp_old->filepath), t('Old temp file was correctly removed.')); + $this->assertTrue(file_exists($temp_new->filepath), t('New temp file was correctly ignored.')); + $this->assertTrue(file_exists($perm_old->filepath), t('Old permanent file was correctly ignored.')); + $this->assertTrue(file_exists($perm_new->filepath), t('New permanent file was correctly ignored.')); + } } class AdminOverviewTestCase extends DrupalWebTestCase { |