public function ShortcodeTest::testLinkShortcode in Shortcode 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/ShortcodeTest.php \Drupal\Tests\shortcode\Functional\ShortcodeTest::testLinkShortcode()
Tests that the Link shortcode returns the right content.
File
- tests/
src/ Functional/ ShortcodeTest.php, line 219
Class
- ShortcodeTest
- Tests the Drupal 8 shortcode module functionality.
Namespace
Drupal\Tests\shortcode\FunctionalCode
public function testLinkShortcode() {
$sets = [
[
'input' => '[link path="node/1"]Label[/link]',
'output' => '<a href="' . $this->siteUrl . 'node/1" title="Label">Label</a>',
'message' => 'Link shortcode output matches.',
],
[
'input' => '[link path="node/23" title="Google" class="link-class" style="background-color:#0FF;"] Label [/link]',
'output' => '<a href="' . $this->siteUrl . 'node/23" class="link-class" style="background-color:#0FF;" title="Google"> Label </a>',
'message' => 'Link shortcode with title and attributes output matches.',
],
[
'input' => '[link url="http://google.com" title="Google" class="link-class" style="background-color:#0FF;"] Label [/link]',
'output' => '<a href="http://google.com" class="link-class" style="background-color:#0FF;" title="Google"> Label </a>',
'message' => 'Link shortcode with url, title and attributes output matches.',
],
[
'input' => '[link path="node/23" url="http://google.com" title="Google" class="link-class" style="background-color:#0FF;"] Label [/link]',
'output' => '<a href="http://google.com" class="link-class" style="background-color:#0FF;" title="Google"> Label </a>',
'message' => 'Link shortcode with both path and url, title and attributes output matches.',
],
];
foreach ($sets as $set) {
$output = $this->shortcodeService
->process($set['input']);
$this
->assertEqual($output, $set['output'], $set['message']);
}
}