class RoutingExtensionTest extends TestCase
{ /**
* @dataProvider getEscapingTemplates
*/
public function testEscaping($template,
$mustBeEscaped) { $twig =
new Environment($this->
createMock(LoaderInterface::
class),
['debug' => true, 'cache' => false, 'autoescape' => 'html', 'optimizations' => 0
]);
$twig->
addExtension(new RoutingExtension($this->
createMock(UrlGeneratorInterface::
class)));
$nodes =
$twig->
parse($twig->
tokenize(new Source($template, ''
)));
$this->
assertSame($mustBeEscaped,
$nodes->
getNode('body'
)->
getNode(0
)->
getNode('expr'
) instanceof FilterExpression
);
} public static function getEscapingTemplates() { return [ ['{{ path("foo") }}', false
],
['{{ path("foo", {}) }}', false
],
['{{ path("foo", { foo: "foo" }) }}', false
],
['{{ path("foo", foo) }}', true
],
[