You are here

public function ShortcodeTest::testHighlightShortcode in Shortcode 2.0.x

Same name and namespace in other branches
  1. 8 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\Functional

Code

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.');
}