class Twig_Tests_EnvironmentTest

Hierarchy

Expanded class hierarchy of Twig_Tests_EnvironmentTest

File

drupal/core/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php, line 12

View source
class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase {
  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 \\x3e foo\\x3cbr\\x2f \\x3e', $twig
      ->render('js', array(
      'bar' => 'foo<br/ >',
    )));
  }
  public function escapingStrategyCallback($filename) {
    return $filename;
  }

}

Members