summaryrefslogtreecommitdiff
path: root/modules/simpletest/drupal_web_test_case.php
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-11-05 17:06:18 +0000
committerDries Buytaert <dries@buytaert.net>2008-11-05 17:06:18 +0000
commit57d35b7fb18619cb68e405f586471ea0ac1453fe (patch)
tree8aa00621a010ca8f522185543b5a43c648b9bffa /modules/simpletest/drupal_web_test_case.php
parentdc1af5e2909258358348a17b17a3f87850396e32 (diff)
downloadbrdo-57d35b7fb18619cb68e405f586471ea0ac1453fe.tar.gz
brdo-57d35b7fb18619cb68e405f586471ea0ac1453fe.tar.bz2
- Patch #243532 by Damien Tournoud et al: catch notices, warnings and fatal errors during testing. Woop, woop.
Diffstat (limited to 'modules/simpletest/drupal_web_test_case.php')
-rw-r--r--modules/simpletest/drupal_web_test_case.php21
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() {