You are here

function ImageTestCase::__tearDown in Image 7

Same name and namespace in other branches
  1. 6 tests/image.test \ImageTestCase::__tearDown()

Clean-up temporary files.

@todo This lets SimpleTest die for any reason.

See also

system_cron()

File

tests/image.test, line 50

Class

ImageTestCase
Test image functionality.

Code

function __tearDown() {
  $result = db_query('SELECT * FROM {files} WHERE status = %d', FILE_STATUS_TEMPORARY);
  while ($file = db_fetch_object($result)) {
    if (file_exists($file->filepath)) {

      // If files that exist cannot be deleted, continue so the database remains
      // consistent.
      if (!file_delete($file->filepath)) {
        $this
          ->error(t('Could not delete temporary file "%path" during garbage collection', array(
          '%path' => $file->filepath,
        )));
        continue;
      }
    }
    db_query('DELETE FROM {files} WHERE fid = %d', $file->fid);
  }
}