summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/common.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/simpletest/tests/common.test')
-rw-r--r--modules/simpletest/tests/common.test53
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.'));
+ }
}
/**