Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.1201 diff -u -p -r1.1201 common.inc --- includes/common.inc 5 Aug 2010 08:36:08 -0000 1.1201 +++ includes/common.inc 6 Aug 2010 07:02:13 -0000 @@ -1005,6 +1005,29 @@ function drupal_http_request($url, array $result->error = $status_message; } + // Errors are being sent via X-Drupal-Assertion-* headers, generated by + // _drupal_log_error() in the exact form required by + // DrupalWebTestCase::error(). + if (!empty($result->headers)) { + $test_info = &$GLOBALS['drupal_test_info']; + $child_site = !empty($GLOBALS['drupal_test_info']['in_child_site']); + foreach ($result->headers as $name => $value) { + if (preg_match('/^x-drupal-assertion-[0-9]+$/', $name)) { + // If the request is being made inside another request (we are in the + // child site of a test making the call to drupal_http_request) then + // forward the errors back to the parent. An example of this is + // UpdateTestContribCase which calls admin/reports/updates/check which + // in term makes a drupal_http_request(). + if ($child_site) { + header($name . ': ' . $value); + } + else { + call_user_func_array(array(&DrupalTestCase::$self, 'error'), unserialize(urldecode($value))); + } + } + } + } + return $result; } /** Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.225 diff -u -p -r1.225 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 19 Jul 2010 21:54:46 -0000 1.225 +++ modules/simpletest/drupal_web_test_case.php 6 Aug 2010 07:02:14 -0000 @@ -19,6 +19,14 @@ global $drupal_test_info; * Do not extend this class, use one of the subclasses in this file. */ abstract class DrupalTestCase { + + /** + * Active DrupalTestCase instance. + * + * @var object + */ + public static $self; + /** * The test run ID. * @@ -82,6 +90,7 @@ abstract class DrupalTestCase { */ public function __construct($test_id = NULL) { $this->testId = $test_id; + self::$self = $this; } /** @@ -392,6 +401,9 @@ abstract class DrupalTestCase { /** * Fire an error assertion. * + * Called from drupal_http_request() to record errors sent back through HTTP + * headers and thus it must be public. + * * @param $message * The message to display along with the assertion. * @param $group @@ -401,7 +413,7 @@ abstract class DrupalTestCase { * @return * FALSE. */ - protected function error($message = '', $group = 'Other', array $caller = NULL) { + public function error($message = '', $group = 'Other', array $caller = NULL) { if ($group == 'User notice') { // Since 'User notice' is set by trigger_error() which is used for debug // set the message to a status of 'debug'. Index: modules/simpletest/tests/common.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v retrieving revision 1.119 diff -u -p -r1.119 common.test --- modules/simpletest/tests/common.test 5 Aug 2010 23:53:38 -0000 1.119 +++ modules/simpletest/tests/common.test 6 Aug 2010 07:02:14 -0000 @@ -1724,7 +1724,7 @@ class DrupalErrorCollectionUnitTest exte } } - protected function error($message = '', $group = 'Other', array $caller = NULL) { + public function error($message = '', $group = 'Other', array $caller = NULL) { // This function overiddes DrupalWebTestCase::error(). We collect an error... $this->collectedErrors[] = array( 'message' => $message,