public function NoReferrerTestCase::testNoReferrer in No Referrer 7
Functional tests for rel="noreferrer" attribute.
File
- ./
noreferrer.test, line 34 - Tests for no referrer module.
Class
- NoReferrerTestCase
- Tests basic no referrer functionality.
Code
public function testNoReferrer() {
$admin_user = $this
->drupalCreateUser(array(
'administer site configuration',
'administer menu',
));
$this
->drupalLogin($admin_user);
$edit = array(
'noreferrer_whitelisted_domains' => 'drupal.org example.org',
);
$this
->drupalPost('admin/config/content/noreferrer', $edit, t('Save configuration'));
$edit = array(
'link_title' => 'test',
);
$paths = array(
'https://example.com/',
'https://drupal.org/',
'https://DRUPAL.ORG/',
'https://api.drupal.org/',
);
foreach ($paths as $path) {
$edit['link_path'] = $path;
$this
->drupalPost('admin/structure/menu/manage/main-menu/add', $edit, t('Save'));
}
$this
->assertRaw('<a href="https://example.com/" title="" rel="noreferrer">test</a>');
$this
->assertRaw('<a href="https://drupal.org/" title="">test</a>');
$this
->assertRaw('<a href="https://DRUPAL.ORG/" title="">test</a>');
$this
->assertRaw('<a href="https://api.drupal.org/" title="">test</a>');
$this
->assertRaw('<a href="https://drupal.org/" target="_blank" rel="noopener">test</a>');
$this
->assertRaw('<a href="https://example.com/" target="_new_tab" rel="noopener noreferrer">test</a>');
$this
->assertRaw('<a href="https://example.org/" target="0" rel="nofollow noopener">test</a>');
}