Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.117 diff -u -r1.117 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 16 Jun 2009 04:43:47 -0000 1.117 +++ modules/simpletest/drupal_web_test_case.php 23 Jun 2009 23:29:31 -0000 @@ -343,6 +343,9 @@ * Run all tests in this class. */ public function run() { + // Initialize verbose debugging. + simpletest_verbose(NULL, file_directory_path()); + // HTTP auth settings (:) for the simpletest browser // when sending requests to the test site. $this->httpauth_credentials = variable_get('simpletest_httpauth_credentials', NULL); @@ -1301,6 +1304,9 @@ if (($new = $this->checkForMetaRefresh())) { $out = $new; } + $this->verbose('GET request to: ' . $path . + '
Ending URL: ' . $this->getUrl() . + '
' . $out); return $out; } @@ -1359,6 +1365,7 @@ // We post only if we managed to handle every field in edit and the // submit button matches. if (!$edit && $submit_matches) { + $post_array = $post; if ($upload) { // TODO: cURL handles file uploads for us, but the implementation // is broken. This is a less than elegant workaround. Alternatives @@ -1387,6 +1394,10 @@ if (($new = $this->checkForMetaRefresh())) { $out = $new; } + $this->verbose('POST request to: ' . $path . + '
Ending URL: ' . $this->getUrl() . + '
Fields: ' . highlight_string('' . $out); return $out; } } @@ -2356,6 +2367,24 @@ $email = end($captured_emails); return $this->assertTrue($email && isset($email[$name]) && $email[$name] == $value, $message, t('E-mail')); } + + /** + * Log verbose message in a text file. + * + * The a link to the vebose message will be placed in the test results via + * as a passing assertion with the text '[verbose message]'. + * + * @param $message + * The verbose message to be stored. + * @see simpletest_verbose() + */ + protected function verbose($message) { + $id = simpletest_verbose($message); + if ($id) { + $this->pass(t('[verbose message]', + array('@url' => url($this->originalFileDirectory . '/simpletest/verbose.html', array('fragment' => $id)))), t('Verbose')); + } + } } /** @@ -2373,3 +2402,42 @@ return TRUE; } + +/** + * Log verbose message in a text file. + * + * If verbose mode is enabled then page requests will be dumped to a file and + * presented on the test result screen. The messages will be placed in a file + * located in the simpletest directory in the original file system. + * + * @param $message + * The verbose message to be stored. + * @param $original_file_directory + * The original file directory, before it was changed for testing purposes. + * @return + * The ID of the message to be placed in related assertion messages. + * @see DrupalTestCase->originalFileDirectory + * @see DrupalWebTestCase->verbose() + */ +function simpletest_verbose($message, $original_file_directory = NULL) { + static $file_directory = NULL, $id = 0; + + if (!variable_get('simpletest_verbose', FALSE)) { + return FALSE; + } + + if ($message && $file_directory) { + $message = '
ID #' . $id . '
' . $message; + file_put_contents($file_directory . '/simpletest/verbose.html', $message, FILE_APPEND); + return $id++; + } + + if ($original_file_directory) { + $file_directory = $original_file_directory; + + // Clear out the previous log. + $message = t('Starting verbose log at @time.', array('@time' => format_date(time()))) . "\n"; + file_put_contents($file_directory . '/simpletest/verbose.html', $message); + } + return FALSE; +} Index: modules/simpletest/simpletest.install =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.install,v retrieving revision 1.21 diff -u -r1.21 simpletest.install --- modules/simpletest/simpletest.install 27 May 2009 18:34:00 -0000 1.21 +++ modules/simpletest/simpletest.install 23 Jun 2009 23:29:31 -0000 @@ -109,6 +109,7 @@ variable_del('simpletest_httpauth_username'); variable_del('simpletest_httpauth_pass'); variable_del('simpletest_devel'); + variable_del('simpletest_verbose'); // Uninstall schema. drupal_uninstall_schema('simpletest');