function CommonURLWebTest::testInternalPathMimicsExternal in Drupal 7
Tests the url() function on internal paths which mimic external URLs.
File
- modules/
simpletest/ tests/ common.test, line 394 - Tests for common.inc functionality.
Class
- CommonURLWebTest
- Web tests for URL generation functions.
Code
function testInternalPathMimicsExternal() {
// Ensure that calling url(current_path()) on "/http://example.com" (an
// internal path which mimics an external URL) always links to the internal
// path, not the external URL. This helps protect against external URL link
// injection vulnerabilities.
variable_set('common_test_link_to_current_path', TRUE);
$this
->drupalGet('/http://example.com');
$this
->clickLink('link which should point to the current path');
$this
->assertUrl('/http://example.com');
$this
->assertText('link which should point to the current path');
}