You are here

public function TokenTest::providerTestReplaceEscaping in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Utility/TokenTest.php \Drupal\Tests\Core\Utility\TokenTest::providerTestReplaceEscaping()

File

core/tests/Drupal/Tests/Core/Utility/TokenTest.php, line 283
Contains \Drupal\Tests\Core\Utility\TokenTest.

Class

TokenTest
@coversDefaultClass \Drupal\Core\Utility\Token @group Utility

Namespace

Drupal\Tests\Core\Utility

Code

public function providerTestReplaceEscaping() {
  $data = [];

  // No tokens. The first argument to Token::replace() should not be escaped.
  $data['no-tokens'] = [
    'muh',
    [],
    'muh',
  ];
  $data['html-in-string'] = [
    '<h1>Giraffe</h1>',
    [],
    '<h1>Giraffe</h1>',
  ];
  $data['html-in-string-quote'] = [
    '<h1>Giraffe"</h1>',
    [],
    '<h1>Giraffe"</h1>',
  ];
  $data['simple-placeholder-with-plain-text'] = [
    '<h1>[token:meh]</h1>',
    [
      '[token:meh]' => 'Giraffe"',
    ],
    '<h1>' . Html::escape('Giraffe"') . '</h1>',
  ];
  $data['simple-placeholder-with-safe-html'] = [
    '<h1>[token:meh]</h1>',
    [
      '[token:meh]' => Markup::create('<em>Emphasized</em>'),
    ],
    '<h1><em>Emphasized</em></h1>',
  ];
  return $data;
}