Create a gist now

Instantly share code, notes, and snippets.

Drupal 6 simpletest curl patch ( curl spits output to stdout instead of saving to variable )
diff --git a/sites/all/modules/simpletest/drupal_web_test_case.php b/sites/all/modules/simpletest/drupal_web_test_case.php
index 9a9c360..fb67fba 100644
--- a/sites/all/modules/simpletest/drupal_web_test_case.php
+++ b/sites/all/modules/simpletest/drupal_web_test_case.php
@@ -1310,6 +1310,11 @@ class DrupalWebTestCase extends DrupalTestCase {
if (!isset($this->curlHandle)) {
$this->curlHandle = curl_init();
+
+ if (empty($this->cookieFile)) {
+ $this->cookieFile = sys_get_temp_dir() . '/cookie.jar';
+ }
+
$curl_options = $this->additionalCurlOptions + array(
CURLOPT_COOKIEJAR => $this->cookieFile,
CURLOPT_URL => $base_url,
@@ -1323,7 +1328,12 @@ class DrupalWebTestCase extends DrupalTestCase {
if (isset($this->httpauth_credentials)) {
$curl_options[CURLOPT_USERPWD] = $this->httpauth_credentials;
}
- curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
+
+ $result = curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
+
+ if (!$result) {
+ throw new \UnexpectedValueException('One or more cURL options could not be set.');
+ }
// By default, the child session name should be the same as the parent.
$this->session_name = session_name();
@@ -1354,7 +1364,11 @@ class DrupalWebTestCase extends DrupalTestCase {
// not overwritten by Curl.
$curl_options[CURLOPT_HTTPHEADER][] = 'Expect:';
}
- curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
+
+ $result = curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
+ if (!$result) {
+ throw new \UnexpectedValueException('One or more cURL options could not be set.');
+ }
// Reset headers and the session ID.
$this->session_id = NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment