Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.46 diff -u -r1.46 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 1 Oct 2008 00:27:29 -0000 1.46 +++ modules/simpletest/drupal_web_test_case.php 2 Oct 2008 19:15:33 -0000 @@ -877,6 +877,10 @@ // previous options. $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_HEADER => FALSE, CURLOPT_NOBODY => FALSE)); $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up. + + if (($new = $this->checkForMetaRefresh())) { + $out = $new; + } return $out; } @@ -952,6 +956,10 @@ $out = $this->curlExec(array(CURLOPT_URL => $action, CURLOPT_POST => TRUE, CURLOPT_POSTFIELDS => $post, CURLOPT_HEADER => FALSE)); // Ensure that any changes to variables in the other thread are picked up. $this->refreshVariables(); + + if (($new = $this->checkForMetaRefresh())) { + $out = $new; + } return $out; } } @@ -965,6 +973,24 @@ } /** + * Check for meta refresh tag and if found call drupalGet() recursively. + * + * @return + * Either the new page content of FALSE. + */ + private function checkForMetaRefresh() { + if ($this->drupalGetContent() != '' && $this->parse()) { + $refresh = $this->xpath('//meta[@http-equiv="Refresh"]'); + if (!empty($refresh)) { + if (preg_match('/\d+;\s*URL=(?P.*)/', $refresh[0]['content'], $match)) { + return $this->drupalGet($this->getAbsoluteUrl(decode_entities($match['url']))); + } + } + } + return FALSE; + } + + /** * Retrieves only the headers for a Drupal path or an absolute path. * * @param $path Index: modules/simpletest/simpletest.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v retrieving revision 1.15 diff -u -r1.15 simpletest.module --- modules/simpletest/simpletest.module 20 Sep 2008 20:22:24 -0000 1.15 +++ modules/simpletest/simpletest.module 2 Oct 2008 19:15:34 -0000 @@ -191,7 +191,7 @@ '#value' => t('Clean environment'), '#submit' => array('simpletest_clean_environment'), ); - + return $form; } @@ -291,8 +291,6 @@ * Run selected tests. */ function simpletest_test_form_submit($form, &$form_state) { - $batch_mode = !preg_match("/^simpletest\d+$/", $_SERVER['HTTP_USER_AGENT']); - // Ensure that all classes are loaded before we create instances to get test information and run. simpletest_get_all_tests(); @@ -304,10 +302,10 @@ } } if (count($tests_list) > 0 ) { - simpletest_run_tests($tests_list, 'drupal', $batch_mode); + simpletest_run_tests($tests_list, 'drupal'); } else { - drupal_set_message(t('No test has been selected.'), 'error'); + drupal_set_message(t('No test(s) selected.'), 'error'); } } @@ -318,37 +316,25 @@ * @param $reporter * Which reporter to use. Allowed values are: text, xml, html and drupal, * drupal being the default. - * @param $batch_mode - * Whether to use the batch API or not. */ -function simpletest_run_tests($test_list, $reporter = 'drupal', $batch_mode = FALSE) { +function simpletest_run_tests($test_list, $reporter = 'drupal') { global $db_prefix, $db_prefix_original; cache_clear_all(); $test_id = db_insert('simpletest_test_id')->useDefaults(array('test_id'))->execute(); - if ($batch_mode) { - $batch = array( - 'title' => t('Running SimpleTests'), - 'operations' => array( - array('_simpletest_batch_operation', array($test_list, $test_id) - ), + $batch = array( + 'title' => t('Running SimpleTests'), + 'operations' => array( + array('_simpletest_batch_operation', array($test_list, $test_id) ), - 'finished' => '_simpletest_batch_finished', - 'redirect' => 'admin/build/testing', - 'progress_message' => t('Processing tests.'), - 'css' => array(drupal_get_path('module', 'simpletest') .'/simpletest.css'), - 'init_message' => t('SimpleTest is initializing...') . ' ' . format_plural(count($test_list), "one test case will run.", "@count test cases will run."), - ); - batch_set($batch); - } - else { - simpletest_get_all_tests(); - foreach ($test_list as $test_class) { - $test = new $test_class($test_id); - $test->run(); - } - $_SESSION['test_id'] = $test_id; - } + ), + 'finished' => '_simpletest_batch_finished', + 'redirect' => 'admin/build/testing', + 'progress_message' => t('Processing tests.'), + 'css' => array(drupal_get_path('module', 'simpletest') .'/simpletest.css'), + 'init_message' => t('SimpleTest is initializing...') . ' ' . format_plural(count($test_list), "one test case will run.", "@count test cases will run."), + ); + batch_set($batch); } /**