You are here

public function Twig_Tests_Extension_SandboxTest::testMacrosInASandbox in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php \Twig_Tests_Extension_SandboxTest::testMacrosInASandbox()

File

vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php, line 164

Class

Twig_Tests_Extension_SandboxTest

Code

public function testMacrosInASandbox() {
  $twig = $this
    ->getEnvironment(true, array(
    'autoescape' => 'html',
  ), array(
    'index' => <<<EOF
{%- import _self as macros %}

{%- macro test(text) %}<p>{{ text }}</p>{% endmacro %}

{{- macros.test('username') }}
EOF
,
  ), array(
    'macro',
    'import',
  ), array(
    'escape',
  ));
  $this
    ->assertEquals('<p>username</p>', $twig
    ->loadTemplate('index')
    ->render(array()));
}