Commit 99f7e594 authored by catch's avatar catch
Browse files

Issue #2004908 by sdboyer: Added Allow tests to specify that response headers...

Issue #2004908 by sdboyer: Added Allow tests to specify that response headers should be dumped in verbose mode.
parent 7ee44e45
......@@ -53,6 +53,16 @@ abstract class WebTestBase extends TestBase {
*/
protected $headers;
/**
* Indicates that headers should be dumped if verbose output is enabled.
*
* Headers are dumped to verbose by drupalGet(), drupalHead(), and
* drupalPost().
*
* @var bool
*/
protected $dumpHeaders = FALSE;
/**
* The content of the page currently loaded in the internal browser.
*
......@@ -1191,9 +1201,15 @@ protected function drupalGet($path, array $options = array(), array $headers = a
if ($new = $this->checkForMetaRefresh()) {
$out = $new;
}
$this->verbose('GET request to: ' . $path .
'<hr />Ending URL: ' . $this->getUrl() .
'<hr />' . $out);
$verbose = 'GET request to: ' . $path .
'<hr />Ending URL: ' . $this->getUrl();
if ($this->dumpHeaders) {
$verbose .= '<hr />Headers: <pre>' . check_plain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
}
$verbose .= '<hr />' . $out;
$this->verbose($verbose);
return $out;
}
......@@ -1373,10 +1389,16 @@ protected function drupalPost($path, $edit, $submit, array $options = array(), a
if ($new = $this->checkForMetaRefresh()) {
$out = $new;
}
$this->verbose('POST request to: ' . $path .
'<hr />Ending URL: ' . $this->getUrl() .
'<hr />Fields: ' . highlight_string('<?php ' . var_export($post_array, TRUE), TRUE) .
'<hr />' . $out);
$verbose = 'POST request to: ' . $path;
$verbose .= '<hr />Ending URL: ' . $this->getUrl();
if ($this->dumpHeaders) {
$verbose .= '<hr />Headers: <pre>' . check_plain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
}
$verbose .= '<hr />Fields: ' . highlight_string('<?php ' . var_export($post_array, TRUE), TRUE);
$verbose .= '<hr />' . $out;
$this->verbose($verbose);
return $out;
}
}
......@@ -1633,6 +1655,13 @@ protected function drupalHead($path, array $options = array(), array $headers =
$options['absolute'] = TRUE;
$out = $this->curlExec(array(CURLOPT_NOBODY => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_HTTPHEADER => $headers));
$this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
if ($this->dumpHeaders) {
$this->verbose('GET request to: ' . $path .
'<hr />Ending URL: ' . $this->getUrl() .
'<hr />Headers: <pre>' . check_plain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>');
}
return $out;
}
......
......@@ -14,6 +14,8 @@
*/
class PageCacheTest extends WebTestBase {
protected $dumpHeaders = TRUE;
/**
* Modules to enable.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment