public function ExtlinkTest::testExtlinkDomainMatching in External Links 8
Checks to see if external link works with an extended set of links.
1 call to ExtlinkTest::testExtlinkDomainMatching()
- ExtlinkTest::testExtlinkDomainMatchingExcludeSubDomainsEnabled in tests/
src/ FunctionalJavascript/ ExtlinkTest.php - Checks to see if external link works with an extended set of links.
File
- tests/
src/ FunctionalJavascript/ ExtlinkTest.php, line 124
Class
- ExtlinkTest
- Testing the basic functionality of External Links.
Namespace
Drupal\Tests\extlink\FunctionalJavascriptCode
public function testExtlinkDomainMatching() {
// Login.
$this
->drupalLogin($this->adminUser);
$domains = [
'http://www.example.com',
'http://www.example.com:8080',
'http://www.example.co.uk',
'http://test.example.com',
'http://example.com',
'http://www.whatever.com',
'http://www.domain.org',
'http://www.domain.nl',
'http://www.domain.de',
'http://www.auspigs.com',
'http://www.usapigs.com',
'http://user:password@example.com',
];
// Build the html for the page.
$node_html = '';
foreach ($domains as $item) {
$node_html .= '<p><a href="' . $item . '">' . $item . '</a></p><p>';
}
// Create the node.
$settings = [
'type' => 'page',
'title' => 'test page',
'body' => [
[
'value' => $node_html,
'format' => $this->emptyFormat
->id(),
],
],
];
$node = $this
->drupalCreateNode($settings);
// Get the page.
$this
->drupalGet($node
->toUrl());
$page = $this
->getSession()
->getPage();
// Test that the page has an external link on each link.
foreach ($domains as $item) {
$externalLink = $page
->findLink($item);
$this
->assertTrue($externalLink
->hasAttribute('data-extlink'), 'External Link failed for "' . $item . '"');
}
}