diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-05-18 06:59:46 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-05-18 06:59:46 +0000 |
commit | 7d2d610f13f0a5abd09b2f7d678fb553d1934d40 (patch) | |
tree | f3ebadf2938a333b8fd9546e6637c7818c58fac3 /modules/simpletest/tests/common.test | |
parent | f8c58bf23d9c97182cfb7262ec0ab7ec66507cb8 (diff) | |
download | brdo-7d2d610f13f0a5abd09b2f7d678fb553d1934d40.tar.gz brdo-7d2d610f13f0a5abd09b2f7d678fb553d1934d40.tar.bz2 |
- Patch #796120 by c960657: do not urldecode() parameters in drupal_goto().
Diffstat (limited to 'modules/simpletest/tests/common.test')
-rw-r--r-- | modules/simpletest/tests/common.test | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test index 07a72463c..7728b8d8f 100644 --- a/modules/simpletest/tests/common.test +++ b/modules/simpletest/tests/common.test @@ -929,19 +929,6 @@ class DrupalHTTPRequestTestCase extends DrupalWebTestCase { $redirect_307 = drupal_http_request(url('system-test/redirect/307', array('absolute' => TRUE)), array('max_redirects' => 0)); $this->assertFalse(isset($redirect_307->redirect_code), t('drupal_http_request does not follow 307 redirect if max_redirects = 0.')); } - - function testDrupalGetDestination() { - $query = $this->randomName(10); - - // Verify that a 'destination' query string is used as destination. - $this->drupalGet('system-test/destination', array('query' => array('destination' => $query))); - $this->assertText('The destination: ' . $query, t('The given query string destination is determined as destination.')); - - // Verify that the current path is used as destination. - $this->drupalGet('system-test/destination', array('query' => array($query => NULL))); - $url = 'system-test/destination?' . $query; - $this->assertText('The destination: ' . $url, t('The current path is determined as destination.')); - } } /** @@ -1007,17 +994,33 @@ class DrupalGotoTest extends DrupalWebTestCase { } /** - * Test setting and retrieving content for theme regions. + * Test drupal_goto(). */ function testDrupalGoto() { $this->drupalGet('common-test/drupal_goto/redirect'); + $headers = $this->drupalGetHeaders(TRUE); + list(, $status) = explode(' ', $headers[0][':status'], 3); + $this->assertEqual($status, 302, t('Expected response code was sent.')); + $this->assertText('drupal_goto', t('Drupal goto redirect succeeded.')); + $this->assertEqual($this->getUrl(), url('common-test/drupal_goto', array('absolute' => TRUE)), t('Drupal goto redirected to expected URL.')); - $this->assertNoText(t("Drupal goto failed to stop program"), t("Drupal goto stopped program.")); - $this->assertText('drupal_goto', t("Drupal goto redirect failed.")); + $this->drupalGet('common-test/drupal_goto/redirect_advanced'); + $headers = $this->drupalGetHeaders(TRUE); + list(, $status) = explode(' ', $headers[0][':status'], 3); + $this->assertEqual($status, 301, t('Expected response code was sent.')); + $this->assertText('drupal_goto', t('Drupal goto redirect succeeded.')); + $this->assertEqual($this->getUrl(), url('common-test/drupal_goto', array('query' => array('foo' => '123'), 'absolute' => TRUE)), t('Drupal goto redirected to expected URL.')); + + // Test that drupal_goto() respects ?destination=xxx. Use an complicated URL + // to test that the path is encoded and decoded properly. + $destination = 'common-test/drupal_goto/destination?foo=%2525&bar=123'; + $this->drupalGet('common-test/drupal_goto/redirect', array('query' => array('destination' => $destination))); + $this->assertText('drupal_goto', t('Drupal goto redirect with destination succeeded.')); + $this->assertEqual($this->getUrl(), url('common-test/drupal_goto/destination', array('query' => array('foo' => '%25', 'bar' => '123'), 'absolute' => TRUE)), t('Drupal goto redirected to given query string destination. ')); } /** - * Test setting and retrieving content for theme regions. + * Test hook_drupal_goto_alter(). */ function testDrupalGotoAlter() { $this->drupalGet('common-test/drupal_goto/redirect_fail'); @@ -1025,6 +1028,22 @@ class DrupalGotoTest extends DrupalWebTestCase { $this->assertNoText(t("Drupal goto failed to stop program"), t("Drupal goto stopped program.")); $this->assertNoText('drupal_goto_fail', t("Drupal goto redirect failed.")); } + + /** + * Test drupal_get_destination(). + */ + function testDrupalGetDestination() { + $query = $this->randomName(10); + + // Verify that a 'destination' query string is used as destination. + $this->drupalGet('common-test/destination', array('query' => array('destination' => $query))); + $this->assertText('The destination: ' . $query, t('The given query string destination is determined as destination.')); + + // Verify that the current path is used as destination. + $this->drupalGet('common-test/destination', array('query' => array($query => NULL))); + $url = 'common-test/destination?' . $query; + $this->assertText('The destination: ' . $url, t('The current path is determined as destination.')); + } } /** |