You are here

function SafeMarkupTest::providerCheckPlain in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Component/Utility/SafeMarkupTest.php \Drupal\Tests\Component\Utility\SafeMarkupTest::providerCheckPlain()

Data provider for testCheckPlain() and testEscapeString().

See also

testCheckPlain()

File

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

Class

SafeMarkupTest
Tests marking strings as safe.

Namespace

Drupal\Tests\Component\Utility

Code

function providerCheckPlain() {

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

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