You are here

public function TwigExtensionTest::providerTestEscaping in Drupal 8

Same name and namespace in other branches
  1. 9 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,
    ],
  ];
}