public function LinkViewsTokensTest::testLinkViewsTokens in Drupal 8
Same name and namespace in other branches
- 9 core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php \Drupal\Tests\link\Functional\Views\LinkViewsTokensTest::testLinkViewsTokens()
- 10 core/modules/link/tests/src/Functional/Views/LinkViewsTokensTest.php \Drupal\Tests\link\Functional\Views\LinkViewsTokensTest::testLinkViewsTokens()
File
- core/
modules/ link/ tests/ src/ Functional/ Views/ LinkViewsTokensTest.php, line 72
Class
- LinkViewsTokensTest
- Tests the views integration for link tokens.
Namespace
Drupal\Tests\link\Functional\ViewsCode
public function testLinkViewsTokens() {
// Array of URI's to test.
$uris = [
'http://www.drupal.org' => 'Drupal.org',
];
// Add nodes with the URI's and titles.
foreach ($uris as $uri => $title) {
$values = [
'type' => 'page',
];
$values[$this->fieldName][] = [
'uri' => $uri,
'title' => $title,
'options' => [
'attributes' => [
'class' => 'test-link-class',
],
],
];
$this
->drupalCreateNode($values);
}
$this
->drupalGet('test_link_tokens');
foreach ($uris as $uri => $title) {
// Formatted link: {{ field_link }}<br />
$this
->assertRaw("Formated: <a href=\"{$uri}\" class=\"test-link-class\">{$title}</a>");
// Raw uri: {{ field_link__uri }}<br />
$this
->assertRaw("Raw uri: {$uri}");
// Raw title: {{ field_link__title }}<br />
$this
->assertRaw("Raw title: {$title}");
// Raw options: {{ field_link__options }}<br />
// Options is an array and should return empty after token replace.
$this
->assertRaw("Raw options: .");
}
}