You are here

public function ShortcodeTest::testItemShortcode in Shortcode 8

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

Tests that the Item shortcode returns the right content.

File

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

Class

ShortcodeTest
Tests the Drupal 8 shortcode module functionality.

Namespace

Drupal\Tests\shortcode\Functional

Code

public function testItemShortcode() {
  $sets = [
    [
      'input' => '[item]Item body here[/item]',
      'output' => '<div>Item body here</div>',
      'message' => 'Item shortcode output matches.',
    ],
    [
      'input' => '[item type="s"]Item body here[/item]',
      'output' => '<span>Item body here</span>',
      'message' => 'Item shortcode with custom type "s" output matches.',
    ],
    [
      'input' => '[item type="d" class="item-class-here" style="background-color:#F00"]Item body here[/item]',
      'output' => '<div class="item-class-here" style="background-color:#F00">Item body here</div>',
      'message' => 'Item shortcode with custom type "d" and class and styles output matches.',
    ],
    [
      'input' => '[item type="s" class="item-class-here" style="background-color:#F00"]Item body here[/item]',
      'output' => '<span class="item-class-here" style="background-color:#F00">Item body here</span>',
      'message' => 'Item shortcode with custom type "s" and class and styles output matches.',
    ],
  ];
  foreach ($sets as $set) {
    $output = $this->shortcodeService
      ->process($set['input']);
    $this
      ->assertEqual($output, $set['output'], $set['message']);
  }
}