You are here

public function ShortcodeTest::testQuoteShortcode in Shortcode 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/ShortcodeTest.php \Drupal\Tests\shortcode\Functional\ShortcodeTest::testQuoteShortcode()

Tests that the Quote shortcode returns the right content.

File

tests/src/Functional/ShortcodeTest.php, line 253

Class

ShortcodeTest
Tests the Drupal 8 shortcode module functionality.

Namespace

Drupal\Tests\shortcode\Functional

Code

public function testQuoteShortcode() {
  $sets = [
    [
      'input' => '[quote]This is by no one[/quote]',
      'output' => '<span class="quote"> This is by no one </span>',
      'message' => 'Quote shortcode output matches.',
    ],
    [
      'input' => '[quote class="test-quote"]This is by no one[/quote]',
      'output' => '<span class="test-quote quote"> This is by no one </span>',
      'message' => 'Quote shortcode with class output matches.',
    ],
    [
      'input' => '[quote class="test-quote" author="ryan"]This is by ryan[/quote]',
      'output' => '<span class="test-quote quote"> <span class="quote-author">ryan wrote: </span> This is by ryan </span>',
      'message' => 'Quote shortcode with class and author output matches.',
    ],
  ];
  foreach ($sets as $set) {
    $output = $this->shortcodeService
      ->process($set['input']);
    $output = preg_replace('/\\s+/', ' ', $output);
    $this
      ->assertEqual($output, $set['output'], $set['message']);
  }
}