You are here

public function Twig_Tests_TemplateTest::getAttributeExceptions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/test/Twig/Tests/TemplateTest.php \Twig_Tests_TemplateTest::getAttributeExceptions()

File

vendor/twig/twig/test/Twig/Tests/TemplateTest.php, line 56

Class

Twig_Tests_TemplateTest

Code

public function getAttributeExceptions() {
  $tests = array(
    array(
      '{{ string["a"] }}',
      'Impossible to access a key ("a") on a string variable ("foo") in "%s" at line 1',
      false,
    ),
    array(
      '{{ null["a"] }}',
      'Impossible to access a key ("a") on a null variable in "%s" at line 1',
      false,
    ),
    array(
      '{{ empty_array["a"] }}',
      'Key "a" does not exist as the array is empty in "%s" at line 1',
      false,
    ),
    array(
      '{{ array["a"] }}',
      'Key "a" for array with keys "foo" does not exist in "%s" at line 1',
      false,
    ),
    array(
      '{{ array_access["a"] }}',
      'Key "a" in object with ArrayAccess of class "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1',
      false,
    ),
    array(
      '{{ string.a }}',
      'Impossible to access an attribute ("a") on a string variable ("foo") in "%s" at line 1',
      false,
    ),
    array(
      '{{ string.a() }}',
      'Impossible to invoke a method ("a") on a string variable ("foo") in "%s" at line 1',
      false,
    ),
    array(
      '{{ null.a }}',
      'Impossible to access an attribute ("a") on a null variable in "%s" at line 1',
      false,
    ),
    array(
      '{{ null.a() }}',
      'Impossible to invoke a method ("a") on a null variable in "%s" at line 1',
      false,
    ),
    array(
      '{{ empty_array.a }}',
      'Key "a" does not exist as the array is empty in "%s" at line 1',
      false,
    ),
    array(
      '{{ array.a }}',
      'Key "a" for array with keys "foo" does not exist in "%s" at line 1',
      false,
    ),
    array(
      '{{ attribute(array, -10) }}',
      'Key "-10" for array with keys "foo" does not exist in "%s" at line 1',
      false,
    ),
    array(
      '{{ array_access.a }}',
      'Method "a" for object "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1',
      false,
    ),
    array(
      '{% from _self import foo %}{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ foo(array_access) }}',
      'Method "missing_method" for object "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1',
      false,
    ),
    array(
      '{{ magic_exception.test }}',
      'An exception has been thrown during the rendering of a template ("Hey! Don\'t try to isset me!") in "%s" at line 1.',
      false,
    ),
    array(
      '{{ object["a"] }}',
      'Impossible to access a key "a" on an object of class "stdClass" that does not implement ArrayAccess interface in "%s" at line 1',
      false,
    ),
  );
  if (function_exists('twig_template_get_attributes')) {
    foreach (array_slice($tests, 0) as $test) {
      $test[2] = true;
      $tests[] = $test;
    }
  }
  return $tests;
}