diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-08-16 07:31:01 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-08-16 07:31:01 +0000 |
commit | c639b5135f669e9e26b9f0982cacda44e788bd1c (patch) | |
tree | 00fae350d7cb030caa988a8f7a6241544036eb97 /modules/simpletest/drupal_web_test_case.php | |
parent | bb153976b131a3382a1605e3a6ad9a1c0952b71e (diff) | |
download | brdo-c639b5135f669e9e26b9f0982cacda44e788bd1c.tar.gz brdo-c639b5135f669e9e26b9f0982cacda44e788bd1c.tar.bz2 |
- Patch #295564 by boombatower, Damien Tournoud: fixed drupal_http_request error and cleaned up some simpletest stuff. We should have a much more funky 'all tests passed' screen. Having all tests pass shouldn't be this boring. Let's be a bit more creative and injest some fun ... ;-)
Diffstat (limited to 'modules/simpletest/drupal_web_test_case.php')
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 2c3016369..e5445af29 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -7,6 +7,7 @@ class DrupalWebTestCase { protected $_logged_in = FALSE; protected $_content; + protected $_url; protected $plain_text; protected $ch; protected $elements; @@ -756,11 +757,9 @@ class DrupalWebTestCase { $this->curlConnect(); $url = empty($curl_options[CURLOPT_URL]) ? curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL) : $curl_options[CURLOPT_URL]; curl_setopt_array($this->ch, $this->curl_options + $curl_options); - $this->_content = curl_exec($this->ch); - $this->plain_text = FALSE; - $this->elements = FALSE; + $this->drupalSetContent(curl_exec($this->ch), curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL)); $this->assertTrue($this->_content !== FALSE, t('!method to !url, response is !length bytes.', array('!method' => !empty($curl_options[CURLOPT_NOBODY]) ? 'HEAD' : (empty($curl_options[CURLOPT_POSTFIELDS]) ? 'GET' : 'POST'), '!url' => $url, '!length' => strlen($this->_content))), t('Browser')); - return $this->_content; + return $this->drupalGetContent(); } /** @@ -1124,7 +1123,7 @@ class DrupalWebTestCase { * The current url. */ function getUrl() { - return curl_getinfo($this->ch, CURLINFO_EFFECTIVE_URL); + return $this->_url; } /** @@ -1135,6 +1134,22 @@ class DrupalWebTestCase { } /** + * Sets the raw HTML content. This can be useful when a page has been fetched + * outside of the internal browser and assertions need to be made on the + * returned page. + * + * A good example would be when testing drupal_http_request(). After fetching + * the page the content can be set and page elements can be checked to ensure + * that the function worked properly. + */ + function drupalSetContent($content, $url = 'internal:') { + $this->_content = $content; + $this->_url = $url; + $this->plain_text = FALSE; + $this->elements = FALSE; + } + + /** * Pass if the raw text IS found on the loaded page, fail otherwise. Raw text * refers to the raw HTML that the page generated. * |