You are here

public function ShortcodeTest::testRandomShortcode in Shortcode 2.0.x

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

Tests that the Random shortcode returns the right length.

File

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

Class

ShortcodeTest
Tests the Drupal 8 shortcode module functionality.

Namespace

Drupal\Tests\shortcode\Functional

Code

public function testRandomShortcode() {
  $sets = [
    [
      'input' => '[random/]',
      'output' => 8,
      'message' => 'Random shortcode self-closed, output length is correct.',
    ],
    [
      'input' => '[random][/random]',
      'output' => 8,
      'message' => 'Random shortcode output, length is correct.',
    ],
    [
      'input' => '[random length=10][/random]',
      'output' => 10,
      'message' => 'Random shortcode with custom length, output length is correct.',
    ],
  ];
  foreach ($sets as $set) {
    $output = $this->shortcodeService
      ->process($set['input']);
    $this
      ->assertEqual(strlen($output), $set['output'], $set['message']);
  }
}