function SafeMarkupTest::providerCheckPlain

Data provider for testCheckPlain() and testHtmlEscapedText().

See also

testCheckPlain()

testHtmlEscapedText()

File

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

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\xc0barbaz",
        'Foo�barbaz',
        'Escapes invalid sequence "Foo\\xC0barbaz"',
    ];
    $tests[] = [
        "\xc2\"",
        '�"',
        '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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.