summaryrefslogtreecommitdiff
path: root/modules/simpletest
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-11-01 20:11:37 -0400
committerDavid Rothstein <drothstein@gmail.com>2014-11-01 20:11:37 -0400
commit6b47cbf7d0aa4b0ad3b249a3e16d023fac0b140a (patch)
treeb5c5d3498859a0c540e2943665d7bc504ae4de69 /modules/simpletest
parent0e3d0beddbdd170165666af4451c088a0eb330d2 (diff)
downloadbrdo-6b47cbf7d0aa4b0ad3b249a3e16d023fac0b140a.tar.gz
brdo-6b47cbf7d0aa4b0ad3b249a3e16d023fac0b140a.tar.bz2
Issue #205969 by Mile23, oadaeh, twistor, ssm2017 Binder, barraponto, superspring: Fixed drupal_http_request() assumes presence of Reason-Phrase in response Status-Line.
Diffstat (limited to 'modules/simpletest')
-rw-r--r--modules/simpletest/tests/common.test68
1 files changed, 68 insertions, 0 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index f6e03b006..6e03253a6 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -1083,6 +1083,74 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase {
}
/**
+ * Tests parsing of the HTTP response status line.
+ */
+class DrupalHTTPResponseStatusLineTest extends DrupalUnitTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Drupal HTTP request response status parsing',
+ 'description' => 'Perform unit tests on _drupal_parse_response_status().',
+ 'group' => 'System',
+ );
+ }
+
+ /**
+ * Tests parsing HTTP response status line.
+ */
+ public function testStatusLine() {
+ // Grab the big array of test data from statusLineData().
+ $data = $this->statusLineData();
+ foreach($data as $test_case) {
+ $test_data = array_shift($test_case);
+ $expected = array_shift($test_case);
+
+ $outcome = _drupal_parse_response_status($test_data);
+
+ foreach(array_keys($expected) as $key) {
+ $this->assertIdentical($outcome[$key], $expected[$key]);
+ }
+ }
+ }
+
+ /**
+ * Data provider for testStatusLine().
+ *
+ * @return array
+ * Test data.
+ */
+ protected function statusLineData() {
+ return array(
+ array(
+ 'HTTP/1.1 200 OK',
+ array(
+ 'http_version' => 'HTTP/1.1',
+ 'response_code' => '200',
+ 'reason_phrase' => 'OK',
+ ),
+ ),
+ // Data set with no reason phrase.
+ array(
+ 'HTTP/1.1 200',
+ array(
+ 'http_version' => 'HTTP/1.1',
+ 'response_code' => '200',
+ 'reason_phrase' => '',
+ ),
+ ),
+ // Arbitrary strings.
+ array(
+ 'version code multi word explanation',
+ array(
+ 'http_version' => 'version',
+ 'response_code' => 'code',
+ 'reason_phrase' => 'multi word explanation',
+ ),
+ ),
+ );
+ }
+}
+
+/**
* Testing drupal_add_region_content and drupal_get_region_content.
*/
class DrupalSetContentTestCase extends DrupalWebTestCase {