You are here

public function ShortcodeTest::testImgShortcode in Shortcode 8

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

Tests that the Image shortcode returns the right content.

File

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

Class

ShortcodeTest
Tests the Drupal 8 shortcode module functionality.

Namespace

Drupal\Tests\shortcode\Functional

Code

public function testImgShortcode() {
  $sets = [
    [
      'input' => '[img src="/abc.jpg" alt="Test image" /]',
      'output' => '<img src="/abc.jpg" class="img" alt="Test image"/>',
      'message' => 'Image shortcode output matches.',
    ],
    [
      'input' => '[img src="/abc.jpg" class="custom-class" alt="Test image" /]',
      'output' => '<img src="/abc.jpg" class="custom-class img" alt="Test image"/>',
      'message' => 'Image shortcode with custom class output matches.',
    ],
  ];
  foreach ($sets as $set) {
    $output = $this->shortcodeService
      ->process($set['input']);
    $this
      ->assertEqual($output, $set['output'], $set['message']);
  }
}