diff options
Diffstat (limited to 'modules/simpletest/tests/form.test')
-rw-r--r-- | modules/simpletest/tests/form.test | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/modules/simpletest/tests/form.test b/modules/simpletest/tests/form.test index 985abe31b..675e8d189 100644 --- a/modules/simpletest/tests/form.test +++ b/modules/simpletest/tests/form.test @@ -1309,6 +1309,81 @@ class FormsRebuildTestCase extends DrupalWebTestCase { } /** + * Tests form redirection. + */ +class FormsRedirectTestCase extends DrupalWebTestCase { + + public static function getInfo() { + return array( + 'name' => 'Form redirecting', + 'description' => 'Tests functionality of drupal_redirect_form().', + 'group' => 'Form API', + ); + } + + function setUp() { + parent::setUp(array('form_test')); + } + + /** + * Tests form redirection. + */ + function testRedirect() { + $path = 'form-test/redirect'; + $options = array('query' => array('foo' => 'bar')); + $options['absolute'] = TRUE; + + // Test basic redirection. + $edit = array( + 'redirection' => TRUE, + 'destination' => $this->randomName(), + ); + $this->drupalPost($path, $edit, t('Submit')); + $this->assertUrl($edit['destination'], array(), 'Basic redirection works.'); + + + // Test without redirection. + $edit = array( + 'redirection' => FALSE, + ); + $this->drupalPost($path, $edit, t('Submit')); + $this->assertUrl($path, array(), 'When redirect is set to FALSE, there should be no redirection.'); + + // Test redirection with query parameters. + $edit = array( + 'redirection' => TRUE, + 'destination' => $this->randomName(), + ); + $this->drupalPost($path, $edit, t('Submit'), $options); + $this->assertUrl($edit['destination'], array(), 'Redirection with query parameters works.'); + + // Test without redirection but with query parameters. + $edit = array( + 'redirection' => FALSE, + ); + $this->drupalPost($path, $edit, t('Submit'), $options); + $this->assertUrl($path, $options, 'When redirect is set to FALSE, there should be no redirection, and the query parameters should be passed along.'); + + // Test redirection back to the original path. + $edit = array( + 'redirection' => TRUE, + 'destination' => '', + ); + $this->drupalPost($path, $edit, t('Submit')); + $this->assertUrl($path, array(), 'When using an empty redirection string, there should be no redirection.'); + + // Test redirection back to the original path with query parameters. + $edit = array( + 'redirection' => TRUE, + 'destination' => '', + ); + $this->drupalPost($path, $edit, t('Submit'), $options); + $this->assertUrl($path, $options, 'When using an empty redirection string, there should be no redirection, and the query parameters should be passed along.'); + } + +} + +/** * Test the programmatic form submission behavior. */ class FormsProgrammaticTestCase extends DrupalWebTestCase { |