diff options
-rw-r--r-- | includes/common.inc | 8 | ||||
-rw-r--r-- | modules/simpletest/tests/common.test (renamed from includes/tests/common.test) | 26 |
2 files changed, 29 insertions, 5 deletions
diff --git a/includes/common.inc b/includes/common.inc index e791deca2..7a61a7512 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -436,13 +436,13 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data = // Parse the URL and make sure we can handle the schema. $uri = parse_url($url); - if (!isset($uri['scheme'])) { - $result->error = 'missing schema'; + if ($uri == FALSE) { + $result->error = 'unable to parse URL'; return $result; } - if (!isset($uri['host'])) { - $result->error = 'missing host'; + if (!isset($uri['scheme'])) { + $result->error = 'missing schema'; return $result; } diff --git a/includes/tests/common.test b/modules/simpletest/tests/common.test index 2fed68527..d9c6ceaa1 100644 --- a/includes/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -112,4 +112,28 @@ class DrupalTagsHandlingTestCase extends DrupalWebTestCase { $this->_assert(FALSE, t('Leftover tag %leftover was left over.', array('%leftover' => $leftover))); } } -}
\ No newline at end of file +} + +/** + * Test drupal_http_request(). + */ +class DrupalHTTPRequestTestCase extends DrupalWebTestCase { + /** + * Implementation of getInfo(). + */ + function getInfo() { + return array( + 'name' => t('Drupal HTTP request'), + 'description' => t("Performs tests on Drupal's HTTP request mechanism."), + 'group' => t('System') + ); + } + + function testDrupalHTTPRequest() { + $missing_scheme = drupal_http_request('example.com/path'); + $this->assertEqual($missing_scheme->error, 'missing schema', t('Returned with missing scheme error.')); + + $unable_to_parse = drupal_http_request('http:///path'); + $this->assertEqual($unable_to_parse->error, 'unable to parse URL', t('Returned with unable to parse URL error.')); + } +} |