From 57d35b7fb18619cb68e405f586471ea0ac1453fe Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 5 Nov 2008 17:06:18 +0000 Subject: - Patch #243532 by Damien Tournoud et al: catch notices, warnings and fatal errors during testing. Woop, woop. --- modules/simpletest/drupal_web_test_case.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'modules/simpletest/drupal_web_test_case.php') diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 43795312b..3d8c6d522 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -801,6 +801,7 @@ class DrupalWebTestCase { CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE, // Required to make the tests run on https:// CURLOPT_SSL_VERIFYHOST => FALSE, // Required to make the tests run on https:// + CURLOPT_HEADERFUNCTION => array(&$this, 'curlHeaderCallback'), ); if (preg_match('/simpletest\d+/', $db_prefix, $matches)) { $curl_options[CURLOPT_USERAGENT] = $matches[0]; @@ -832,6 +833,26 @@ class DrupalWebTestCase { return $this->drupalGetContent(); } + /** + * Reads headers and registers errors received from the tested site. + * + * @see _drupal_log_error(). + * + * @param $ch the cURL handler. + * @param $header a header. + */ + protected function curlHeaderCallback($ch, $header) { + // Errors are being sent via X-Drupal-Assertion-* headers, + // generated by _drupal_log_error() in the exact form required + // by DrupalWebTestCase::error(). + if (preg_match('/^X-Drupal-Assertion-[0-9]+: (.*)$/', $header, $matches)) { + // Call DrupalWebTestCase::error() with the parameters from the header. + call_user_func_array(array(&$this, 'error'), unserialize(urldecode($matches[1]))); + } + // This is required by cURL. + return strlen($header); + } + /** * Close the cURL handler and unset the handler. */ -- cgit v1.2.3