You are here

function simpletest_verbose in SimpleTest 7

Same name and namespace in other branches
  1. 6.2 drupal_web_test_case.php \simpletest_verbose()
  2. 7.2 drupal_web_test_case.php \simpletest_verbose()

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.

Parameters

$message: The verbose message to be stored.

$original_file_directory: The original file directory, before it was changed for testing purposes.

$test_class: The active test case class.

Return value

The ID of the message to be placed in related assertion messages.

See also

DrupalTestCase->originalFileDirectory

DrupalWebTestCase->verbose()

2 calls to simpletest_verbose()
DrupalTestCase::run in ./drupal_web_test_case.php
Run all tests in this class.
DrupalWebTestCase::verbose in ./drupal_web_test_case.php
Log verbose message in a text file.
2 string references to 'simpletest_verbose'
simpletest_settings_form in ./simpletest.pages.inc
Provides settings form for SimpleTest variables.
simpletest_uninstall in ./simpletest.install
Implement hook_uninstall().

File

./drupal_web_test_case.php, line 2536

Code

function simpletest_verbose($message, $original_file_directory = NULL, $test_class = NULL) {
  static $file_directory = NULL, $class = NULL, $id = 1;
  $verbose =& drupal_static(__FUNCTION__);

  // Will pass first time during setup phase, and when verbose is TRUE.
  if (!isset($original_file_directory) && !$verbose) {
    return FALSE;
  }
  if ($message && $file_directory) {
    $message = '<hr />ID #' . $id . ' (<a href="' . $class . '-' . ($id - 1) . '.html">Previous</a> | <a href="' . $class . '-' . ($id + 1) . '.html">Next</a>)<hr />' . $message;
    file_put_contents($file_directory . "/simpletest/verbose/{$class}-{$id}.html", $message, FILE_APPEND);
    return $id++;
  }
  if ($original_file_directory) {
    $file_directory = $original_file_directory;
    $class = $test_class;
    $verbose = variable_get('simpletest_verbose', FALSE);
    $directory = $file_directory . '/simpletest/verbose';
    return file_prepare_directory($directory, FILE_CREATE_DIRECTORY);
  }
  return FALSE;
}