public function Twig_Tests_ErrorTest::testTwigExceptionAddsFileAndLineWhenMissingWithInheritanceAgain

File

drupal/core/vendor/twig/twig/test/Twig/Tests/ErrorTest.php, line 102

Class

Twig_Tests_ErrorTest

Code

public function testTwigExceptionAddsFileAndLineWhenMissingWithInheritanceAgain() {
  $loader = new Twig_Loader_Array(array(
    'index' => "{% extends 'base' %}\n            {% block content %}\n                {{ parent() }}\n            {% endblock %}",
    'base' => '{% block content %}{{ foo }}{% endblock %}',
  ));
  $twig = new Twig_Environment($loader, array(
    'strict_variables' => true,
    'debug' => true,
    'cache' => false,
  ));
  $template = $twig
    ->loadTemplate('index');
  try {
    $template
      ->render(array());
    $this
      ->fail();
  } catch (Twig_Error_Runtime $e) {
    $this
      ->assertEquals('Variable "foo" does not exist in "base" at line 1', $e
      ->getMessage());
    $this
      ->assertEquals(1, $e
      ->getTemplateLine());
    $this
      ->assertEquals('base', $e
      ->getTemplateFile());
  }
}