function TwigExtensionTest::providerTestEscaping

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::providerTestEscaping()
  2. 10 core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::providerTestEscaping()
  3. 11.x core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php \Drupal\Tests\Core\Template\TwigExtensionTest::providerTestEscaping()

Provides tests data for testEscaping

Return value

array An array of test data each containing of a twig template string and a boolean expecting whether the path will be safe.

File

core/tests/Drupal/Tests/Core/Template/TwigExtensionTest.php, line 102

Class

TwigExtensionTest
Tests the twig extension.

Namespace

Drupal\Tests\Core\Template

Code

public function providerTestEscaping() {
    return [
        [
            '{{ path("foo") }}',
            FALSE,
        ],
        [
            '{{ path("foo", {}) }}',
            FALSE,
        ],
        [
            '{{ path("foo", { foo: "foo" }) }}',
            FALSE,
        ],
        [
            '{{ path("foo", foo) }}',
            TRUE,
        ],
        [
            '{{ path("foo", { foo: foo }) }}',
            TRUE,
        ],
        [
            '{{ path("foo", { foo: ["foo", "bar"] }) }}',
            TRUE,
        ],
        [
            '{{ path("foo", { foo: "foo", bar: "bar" }) }}',
            TRUE,
        ],
        [
            '{{ path(name = "foo", parameters = {}) }}',
            FALSE,
        ],
        [
            '{{ path(name = "foo", parameters = { foo: "foo" }) }}',
            FALSE,
        ],
        [
            '{{ path(name = "foo", parameters = foo) }}',
            TRUE,
        ],
        [
            '{{ path(name = "foo", parameters = { foo: ["foo", "bar"] }) }}',
            TRUE,
        ],
        [
            '{{ path(name = "foo", parameters = { foo: foo }) }}',
            TRUE,
        ],
        [
            '{{ path(name = "foo", parameters = { foo: "foo", bar: "bar" }) }}',
            TRUE,
        ],
    ];
}

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