You are here

public function TwigExtensionTest::providerTestEscaping in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 56
Contains \Drupal\Tests\Core\Template\TwigExtensionTest.

Class

TwigExtensionTest
Tests the twig extension.

Namespace

Drupal\Tests\Core\Template

Code

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