function simpletest_log_read

Read the error log and report any errors as assertion failures.

The errors in the log should only be fatal errors since any other errors will have been recorded by the error handler.

Parameters

$test_id: The test ID to which the log relates.

$prefix: The database prefix to which the log relates.

$test_class: The test class to which the log relates.

$during_test: Indicates that the current file directory path is a temporary file file directory used during testing.

Return value

Found any entries in log.

2 calls to simpletest_log_read()
DrupalWebTestCase::tearDown in drupal/modules/simpletest/drupal_web_test_case.php
Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix.
_simpletest_batch_finished in drupal/modules/simpletest/simpletest.module
Implements callback_batch_finished().

File

drupal/modules/simpletest/simpletest.module, line 264
Provides testing functionality.

Code

function simpletest_log_read($test_id, $prefix, $test_class, $during_test = FALSE) {
  $log = 'public://' . ($during_test ? '' : '/simpletest/' . substr($prefix, 10)) . '/error.log';
  $found = FALSE;
  if (file_exists($log)) {
    foreach (file($log) as $line) {
      if (preg_match('/\\[.*?\\] (.*?): (.*?) in (.*) on line (\\d+)/', $line, $match)) {

        // Parse PHP fatal errors for example: PHP Fatal error: Call to
        // undefined function break_me() in /path/to/file.php on line 17
        $caller = array(
          'line' => $match[4],
          'file' => $match[3],
        );
        DrupalTestCase::insertAssert($test_id, $test_class, FALSE, $match[2], $match[1], $caller);
      }
      else {

        // Unknown format, place the entire message in the log.
        DrupalTestCase::insertAssert($test_id, $test_class, FALSE, $line, 'Fatal error');
      }
      $found = TRUE;
    }
  }
  return $found;
}