You are here

public function Twig_Tests_EnvironmentTest::testAutoescapeOption in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php \Twig_Tests_EnvironmentTest::testAutoescapeOption()

File

vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php, line 25

Class

Twig_Tests_EnvironmentTest

Code

public function testAutoescapeOption() {
  $loader = new Twig_Loader_Array(array(
    'html' => '{{ foo }} {{ foo }}',
    'js' => '{{ bar }} {{ bar }}',
  ));
  $twig = new Twig_Environment($loader, array(
    'debug' => true,
    'cache' => false,
    'autoescape' => array(
      $this,
      'escapingStrategyCallback',
    ),
  ));
  $this
    ->assertEquals('foo<br/ > foo<br/ >', $twig
    ->render('html', array(
    'foo' => 'foo<br/ >',
  )));
  $this
    ->assertEquals('foo\\x3Cbr\\x2F\\x20\\x3E foo\\x3Cbr\\x2F\\x20\\x3E', $twig
    ->render('js', array(
    'bar' => 'foo<br/ >',
  )));
}