summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/drupal_web_test_case.php21
-rw-r--r--modules/simpletest/tests/session_test.module7
-rw-r--r--modules/simpletest/tests/system_test.module3
3 files changed, 30 insertions, 1 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() {
diff --git a/modules/simpletest/tests/session_test.module b/modules/simpletest/tests/session_test.module
index 42c47a08c..b183ec38c 100644
--- a/modules/simpletest/tests/session_test.module
+++ b/modules/simpletest/tests/session_test.module
@@ -33,7 +33,12 @@ function session_test_menu() {
* Page callback, prints the stored session value to the screen.
*/
function _session_test_get() {
- return t('The current value of the stored session variable is: %val', array('%val' => $_SESSION['session_test_value']));
+ if (!empty($_SESSION['session_test_value'])) {
+ return t('The current value of the stored session variable is: %val', array('%val' => $_SESSION['session_test_value']));
+ }
+ else {
+ return "";
+ }
}
/**
diff --git a/modules/simpletest/tests/system_test.module b/modules/simpletest/tests/system_test.module
index bd3eff6c5..2134359d2 100644
--- a/modules/simpletest/tests/system_test.module
+++ b/modules/simpletest/tests/system_test.module
@@ -146,6 +146,7 @@ function system_test_modules_uninstalled($modules) {
* Menu callback; generate warnings to test the error handler.
*/
function system_test_generate_warnings() {
+ define('SIMPLETEST_DONT_COLLECT_ERRORS', TRUE);
// This will generate a notice.
$monkey_love = $bananas;
// This will generate a warning.
@@ -159,6 +160,7 @@ function system_test_generate_warnings() {
* Menu callback; trigger an exception to test the exception handler.
*/
function system_test_trigger_exception() {
+ define('SIMPLETEST_DONT_COLLECT_ERRORS', TRUE);
throw new Exception("Drupal is awesome");
}
@@ -166,5 +168,6 @@ function system_test_trigger_exception() {
* Menu callback; trigger an exception to test the exception handler.
*/
function system_test_trigger_pdo_exception() {
+ define('SIMPLETEST_DONT_COLLECT_ERRORS', TRUE);
db_query("SELECT * FROM bananas_are_awesome");
}