You are here

function simpletest_verbose in SimpleTest 6.2

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

Logs 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.
DrupalTestCase::verbose in ./drupal_web_test_case.php
Logs 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
Implements hook_uninstall().

File

./drupal_web_test_case.php, line 3108

Code

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

  // 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', TRUE);
    $directory = $file_directory . '/simpletest/verbose';
    $writable = file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
    if ($writable && !file_exists($directory . '/.htaccess')) {
      file_put_contents($directory . '/.htaccess', "<IfModule mod_expires.c>\nExpiresActive Off\n</IfModule>\n");
    }
    return $writable;
  }
  return FALSE;
}