? .DS_Store
? .cache
? .git
? .project
? .settings
? empty
? file_329226_2.patch
? file_74645_0.patch
? logs
? test.php
? upload-js-fix_1.diff
? sites/all/modules
? sites/default/files
? sites/default/settings.php
Index: modules/simpletest/tests/file.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/file.test,v
retrieving revision 1.7
diff -u -p -r1.7 file.test
--- modules/simpletest/tests/file.test	12 Oct 2008 06:37:40 -0000	1.7
+++ modules/simpletest/tests/file.test	6 Nov 2008 18:39:16 -0000
@@ -1018,14 +1018,14 @@ class FileValidateTest extends FileHookT
     // Use the file_test.module's test validator to ensure that passing tests
     // return correctly.
     file_test_reset();
-    $GLOBALS['file_test_hook_return']['validate'] = array();
+    file_test_set_return('validate', array());
     $passing = array('file_test_validator' => array(array()));
     $this->assertEqual(file_validate($file, $passing), array(), t('Validating passes.'));
     $this->assertFileHookCalled('validate', 1);
 
     // Now test for failures in validators passed in and by hook_validate.
     file_test_reset();
-    $GLOBALS['file_test_hook_return']['validate'] = array('Epic fail');
+    file_test_set_return('validate', array('Epic fail'));
     $failing = array('file_test_validator' => array(array('Failed', 'Badly')));
     $this->assertEqual(file_validate($file, $failing), array('Failed', 'Badly', 'Epic fail'), t('Validating returns errors.'));
     $this->assertFileHookCalled('validate', 1);
Index: modules/simpletest/tests/file_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/file_test.module,v
retrieving revision 1.2
diff -u -p -r1.2 file_test.module
--- modules/simpletest/tests/file_test.module	9 Oct 2008 00:02:29 -0000	1.2
+++ modules/simpletest/tests/file_test.module	6 Nov 2008 18:39:16 -0000
@@ -54,10 +54,12 @@ function _file_test_form_submit(&$form, 
 
 /**
  * Reset/initialize the history of calls to the file_* hooks.
+ *
+ * @see the getter/setter functions file_test_get_calls() and file_test_reset().
  */
 function file_test_reset() {
   // Keep track of calls to these hooks
-  $GLOBALS['file_test_results'] = array(
+  $results = array(
     'load' => array(),
     'validate' => array(),
     'download' => array(),
@@ -69,30 +71,81 @@ function file_test_reset() {
     'move' => array(),
     'delete' => array(),
   );
+  variable_set('file_test_results', $results);
 
-  // These hooks will return these values.
-  $GLOBALS['file_test_hook_return'] = array(
-    'validate' => NULL,
+  // These hooks will return these values, @see file_test_set_return().
+  $return = array(
+    'validate' => array(),
     'download' => NULL,
     'references' => NULL,
   );
+  variable_set('file_test_return', $return);
 }
 
 /**
- * Get the values passed to a the hook calls for a given operation.
+ * Get the arguments passed to invocation of a given hook since
+ * file_test_reset() was last called.
  *
- * @param $op One of the hook_file_* operations.
- * @returns Array of the parameters passed to each call.
+ * @param $op
+ *   One of the hook_file_* operations: "load", "validate", etc.
+ * @returns
+ *   Array of the parameters passed to each call.
+ * @see _file_test_log_call() and file_test_reset()
  */
 function file_test_get_calls($op) {
-  return $GLOBALS['file_test_results'][$op];
+  $results = variable_get('file_test_results', array());
+  return $results[$op];
+}
+
+/**
+ * Store the values passed to a hook invocation.
+ *
+ * @param $op
+ *   One of the hook_file_* operations: "load", "validate", etc.
+ * @param $args
+ *   Values passed to hook.
+ * @see file_test_get_calls() and file_test_reset()
+ */
+function _file_test_log_call($op, $args) {
+  $results = variable_get('file_test_results', array());
+  $results[$op][] = $args;
+  variable_set('file_test_results', $results);
+}
+
+/**
+ * Load the appropriate return value.
+ *
+ * @param $op
+ *   One of the hook_file_[validate,download,references] operations.
+ * @return
+ *   Value set by file_test_set_return().
+* @see file_test_set_return() and file_test_reset().
+ */
+function _file_test_get_return($op) {
+  $return = variable_get('file_test_return', array($op => NULL));
+  return $return[$op];
+}
+
+/**
+ * Assign a return value for a given operation.
+ *
+ * @param $op
+ *   One of the hook_file_[validate,download,references] operations.
+ * @param $value
+ *   Value for the hook to return.
+ * @see _file_test_get_return() and file_test_reset().
+ */
+function file_test_set_return($op, $value) {
+  $return = variable_get('file_test_return', array());
+  $return[$op] = $value;
+  variable_set('file_test_return', $return);
 }
 
 /**
  * Implementation of hook_file_load().
  */
-function file_test_file_load(&$file) {
-  $GLOBALS['file_test_results']['load'][] = func_get_args();
+function file_test_file_load($file) {
+  _file_test_log_call('load', array($file));
   // Assign a value on the object so that we can test that the $file is passed
   // by reference.
   $file->file_test['loaded'] = TRUE;
@@ -101,66 +154,65 @@ function file_test_file_load(&$file) {
 /**
  * Implementation of hook_file_validate().
  */
-function file_test_file_validate(&$file) {
-  $GLOBALS['file_test_results']['validate'][] = func_get_args();
-  return $GLOBALS['file_test_hook_return']['validate'];
+function file_test_file_validate($file) {
+  _file_test_log_call('validate', array($file));
+  return _file_test_get_return('validate');
 }
 
 /**
  * Implementation of hook_file_status().
  */
-function file_test_file_status(&$file) {
-  $GLOBALS['file_test_results']['status'][] = func_get_args();
+function file_test_file_status($file) {
+  _file_test_log_call('status', array($file));
 }
 
 /**
  * Implementation of hook_file_download().
  */
-function file_test_file_download(&$file) {
-  $GLOBALS['file_test_results']['download'][] = func_get_args();
-  return $GLOBALS['file_test_hook_return']['download'];
+function file_test_file_download($file) {
+  _file_test_log_call('download', array($file));
+  return _file_test_get_return('download');
 }
 
 /**
  * Implementation of hook_file_references().
  */
-function file_test_file_references(&$file) {
-  $GLOBALS['file_test_results']['references'][] = func_get_args();
-  return $GLOBALS['file_test_hook_return']['references'];
+function file_test_file_references($file) {
+  _file_test_log_call('references', array($file));
+  return _file_test_get_return('references');
 }
 
 /**
  * Implementation of hook_file_insert().
  */
-function file_test_file_insert(&$file) {
-  $GLOBALS['file_test_results']['insert'][] = func_get_args();
+function file_test_file_insert($file) {
+  _file_test_log_call('insert', array($file));
 }
 
 /**
  * Implementation of hook_file_update().
  */
-function file_test_file_update(&$file) {
-  $GLOBALS['file_test_results']['update'][] = func_get_args();
+function file_test_file_update($file) {
+  _file_test_log_call('update', array($file));
 }
 
 /**
  * Implemenation of hook_file_copy().
  */
-function file_test_file_copy(&$file, &$source) {
-  $GLOBALS['file_test_results']['copy'][] = func_get_args();
+function file_test_file_copy($file, $source) {
+  _file_test_log_call('copy', array($file, $source));
 }
 
 /**
  * Implemenation of hook_file_move().
  */
-function file_test_file_move(&$file, &$source) {
-  $GLOBALS['file_test_results']['move'][] = func_get_args();
+function file_test_file_move($file, $source) {
+  _file_test_log_call('move', array($file, $source));
 }
 
 /**
  * Implementation of hook_file_delete().
  */
-function file_test_file_delete(&$file) {
-  $GLOBALS['file_test_results']['delete'][] = func_get_args();
+function file_test_file_delete($file) {
+  _file_test_log_call('delete', array($file));
 }
-
