diff options
author | David Rothstein <drothstein@gmail.com> | 2015-03-18 15:20:37 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2015-03-18 15:20:37 -0400 |
commit | b44056d2f8e8c71d35c85ec5c2fb8f7c8a02d8a8 (patch) | |
tree | 466ec33c9527f1eaffd1b37031af6047d606cd60 /modules/system | |
parent | 81586d9e9d04dcee487c50de426c04221899b6d0 (diff) | |
download | brdo-b44056d2f8e8c71d35c85ec5c2fb8f7c8a02d8a8.tar.gz brdo-b44056d2f8e8c71d35c85ec5c2fb8f7c8a02d8a8.tar.bz2 |
Drupal 7.35
Diffstat (limited to 'modules/system')
-rw-r--r-- | modules/system/system.test | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/modules/system/system.test b/modules/system/system.test index aefbfbc46..dcc86e539 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -2825,3 +2825,46 @@ class SystemValidTokenTest extends DrupalUnitTestCase { return TRUE; } } + +/** + * Tests confirm form destinations. + */ +class ConfirmFormTest extends DrupalWebTestCase { + protected $admin_user; + + public static function getInfo() { + return array( + 'name' => 'Confirm form', + 'description' => 'Tests that the confirm form does not use external destinations.', + 'group' => 'System', + ); + } + + function setUp() { + parent::setUp(); + + $this->admin_user = $this->drupalCreateUser(array('administer users')); + $this->drupalLogin($this->admin_user); + } + + /** + * Tests that the confirm form does not use external destinations. + */ + function testConfirmForm() { + $this->drupalGet('user/1/cancel'); + $this->assertCancelLinkUrl(url('user/1')); + $this->drupalGet('user/1/cancel', array('query' => array('destination' => 'node'))); + $this->assertCancelLinkUrl(url('node')); + $this->drupalGet('user/1/cancel', array('query' => array('destination' => 'http://example.com'))); + $this->assertCancelLinkUrl(url('user/1')); + } + + /** + * Asserts that a cancel link is present pointing to the provided URL. + */ + function assertCancelLinkUrl($url, $message = '', $group = 'Other') { + $links = $this->xpath('//a[normalize-space(text())=:label and @href=:url]', array(':label' => t('Cancel'), ':url' => $url)); + $message = ($message ? $message : format_string('Cancel link with url %url found.', array('%url' => $url))); + return $this->assertTrue(isset($links[0]), $message, $group); + } +} |