You are here

public function TokenTest::providerTestReplaceEscaping in Drupal 10

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

File

core/tests/Drupal/Tests/Core/Utility/TokenTest.php, line 278

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;
}