public function ShortcodeTest::testHighlightShortcode in Shortcode 8
Same name and namespace in other branches
- 2.0.x tests/src/Functional/ShortcodeTest.php \Drupal\Tests\shortcode\Functional\ShortcodeTest::testHighlightShortcode()
Tests that the highlight shortcode returns the right content.
File
- tests/
src/ Functional/ ShortcodeTest.php, line 145
Class
- ShortcodeTest
- Tests the Drupal 8 shortcode module functionality.
Namespace
Drupal\Tests\shortcode\FunctionalCode
public function testHighlightShortcode() {
$test_input = '[highlight]highlighted text[/highlight]';
$expected_output = '<span class="highlight">highlighted text</span>';
$output = $this->shortcodeService
->process($test_input);
$this
->assertEqual($output, $expected_output, 'Highlight shortcode output matches.');
$test_input = '[highlight class="custom-class"]highlighted text[/highlight]';
$expected_output = '<span class="custom-class highlight">highlighted text</span>';
$output = $this->shortcodeService
->process($test_input);
$this
->assertEqual($output, $expected_output, 'Highlight shortcode with custom class output matches.');
}