You are here

public function Twig_Tests_NodeVisitor_OptimizerTest::getTestsForForOptimizer in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php \Twig_Tests_NodeVisitor_OptimizerTest::getTestsForForOptimizer()

File

vendor/twig/twig/test/Twig/Tests/NodeVisitor/OptimizerTest.php, line 66

Class

Twig_Tests_NodeVisitor_OptimizerTest

Code

public function getTestsForForOptimizer() {
  return array(
    array(
      '{% for i in foo %}{% endfor %}',
      array(
        'i' => false,
      ),
    ),
    array(
      '{% for i in foo %}{{ loop.index }}{% endfor %}',
      array(
        'i' => true,
      ),
    ),
    array(
      '{% for i in foo %}{% for j in foo %}{% endfor %}{% endfor %}',
      array(
        'i' => false,
        'j' => false,
      ),
    ),
    array(
      '{% for i in foo %}{% include "foo" %}{% endfor %}',
      array(
        'i' => true,
      ),
    ),
    array(
      '{% for i in foo %}{% include "foo" only %}{% endfor %}',
      array(
        'i' => false,
      ),
    ),
    array(
      '{% for i in foo %}{% include "foo" with { "foo": "bar" } only %}{% endfor %}',
      array(
        'i' => false,
      ),
    ),
    array(
      '{% for i in foo %}{% include "foo" with { "foo": loop.index } only %}{% endfor %}',
      array(
        'i' => true,
      ),
    ),
    array(
      '{% for i in foo %}{% for j in foo %}{{ loop.index }}{% endfor %}{% endfor %}',
      array(
        'i' => false,
        'j' => true,
      ),
    ),
    array(
      '{% for i in foo %}{% for j in foo %}{{ loop.parent.loop.index }}{% endfor %}{% endfor %}',
      array(
        'i' => true,
        'j' => true,
      ),
    ),
    array(
      '{% for i in foo %}{% set l = loop %}{% for j in foo %}{{ l.index }}{% endfor %}{% endfor %}',
      array(
        'i' => true,
        'j' => false,
      ),
    ),
    array(
      '{% for i in foo %}{% for j in foo %}{{ foo.parent.loop.index }}{% endfor %}{% endfor %}',
      array(
        'i' => false,
        'j' => false,
      ),
    ),
    array(
      '{% for i in foo %}{% for j in foo %}{{ loop["parent"].loop.index }}{% endfor %}{% endfor %}',
      array(
        'i' => true,
        'j' => true,
      ),
    ),
    array(
      '{% for i in foo %}{{ include("foo") }}{% endfor %}',
      array(
        'i' => true,
      ),
    ),
    array(
      '{% for i in foo %}{{ include("foo", with_context = false) }}{% endfor %}',
      array(
        'i' => false,
      ),
    ),
    array(
      '{% for i in foo %}{{ include("foo", with_context = true) }}{% endfor %}',
      array(
        'i' => true,
      ),
    ),
    array(
      '{% for i in foo %}{{ include("foo", { "foo": "bar" }, with_context = false) }}{% endfor %}',
      array(
        'i' => false,
      ),
    ),
    array(
      '{% for i in foo %}{{ include("foo", { "foo": loop.index }, with_context = false) }}{% endfor %}',
      array(
        'i' => true,
      ),
    ),
  );
}