diff options
Diffstat (limited to 'modules/simpletest/drupal_web_test_case.php')
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 21 |
1 files changed, 21 insertions, 0 deletions
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]; @@ -833,6 +834,26 @@ class DrupalWebTestCase { } /** + * 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. */ protected function curlClose() { |