public function ShortcodeTest::testClearShortcode in Shortcode 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/ShortcodeTest.php \Drupal\Tests\shortcode\Functional\ShortcodeTest::testClearShortcode()
Tests that the Clear shortcode returns the right content.
File
- tests/
src/ Functional/ ShortcodeTest.php, line 82
Class
- ShortcodeTest
- Tests the Drupal 8 shortcode module functionality.
Namespace
Drupal\Tests\shortcode\FunctionalCode
public function testClearShortcode() {
$sets = [
[
'input' => '[clear]<div>Other elements</div>[/clear]',
'output' => '<div class="clearfix"><div>Other elements</div></div>',
'message' => 'Clear shortcode output matches.',
],
[
'input' => '[clear type="s"]<div>Other elements</div>[/clear]',
'output' => '<span class="clearfix"><div>Other elements</div></span>',
'message' => 'Clear shortcode with custom type "s" output matches.',
],
[
'input' => '[clear type="span"]<div>Other elements</div>[/clear]',
'output' => '<span class="clearfix"><div>Other elements</div></span>',
'message' => 'Clear shortcode with custom type "span" output matches.',
],
[
'input' => '[clear type="d"]<div>Other elements</div>[/clear]',
'output' => '<div class="clearfix"><div>Other elements</div></div>',
'message' => 'Clear shortcode with custom type "d" output matches.',
],
[
'input' => '[clear type="d" class="custom-class" id="theLabel" style="background-color: #F00;"]<div>Other elements</div>[/clear]',
'output' => '<div class="custom-class clearfix" id="theLabel" style="background-color: #F00;"><div>Other elements</div></div>',
'message' => 'Clear shortcode with custom attributes output matches.',
],
];
foreach ($sets as $set) {
$output = $this->shortcodeService
->process($set['input']);
$this
->assertEqual($output, $set['output'], $set['message']);
}
}