You are here

public function SafeMarkupTest::providerCheckPlain in Drupal 8

Data provider for testCheckPlain() and testHtmlEscapedText().

See also

testCheckPlain()

testHtmlEscapedText()

File

core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php, line 94
Contains \Drupal\Tests\Component\Utility\SafeMarkupTest.

Class

SafeMarkupTest
Tests marking strings as safe.

Namespace

Drupal\Tests\Component\Utility

Code

public function providerCheckPlain() {

  // Checks that invalid multi-byte sequences are escaped.
  $tests[] = [
    "",
    'Foo�barbaz',
    'Escapes invalid sequence "Foo\\xC0barbaz"',
  ];
  $tests[] = [
    "",
    '�"',
    'Escapes invalid sequence "\\xc2\\""',
  ];
  $tests[] = [
    "Fooÿñ",
    "Fooÿñ",
    'Does not escape valid sequence "Fooÿñ"',
  ];

  // Checks that special characters are escaped.
  $tests[] = [
    SafeMarkupTestMarkup::create("<script>"),
    '&lt;script&gt;',
    'Escapes &lt;script&gt; even inside an object that implements MarkupInterface.',
  ];
  $tests[] = [
    "<script>",
    '&lt;script&gt;',
    'Escapes &lt;script&gt;',
  ];
  $tests[] = [
    '<>&"\'',
    '&lt;&gt;&amp;&quot;&#039;',
    'Escapes reserved HTML characters.',
  ];
  $tests[] = [
    SafeMarkupTestMarkup::create('<>&"\''),
    '&lt;&gt;&amp;&quot;&#039;',
    'Escapes reserved HTML characters even inside an object that implements MarkupInterface.',
  ];
  return $tests;
}