You are here

public function Twig_Tests_Node_ForTest::testConstructor in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/twig/twig/test/Twig/Tests/Node/ForTest.php \Twig_Tests_Node_ForTest::testConstructor()

File

vendor/twig/twig/test/Twig/Tests/Node/ForTest.php, line 14

Class

Twig_Tests_Node_ForTest

Code

public function testConstructor() {
  $keyTarget = new Twig_Node_Expression_AssignName('key', 1);
  $valueTarget = new Twig_Node_Expression_AssignName('item', 1);
  $seq = new Twig_Node_Expression_Name('items', 1);
  $ifexpr = new Twig_Node_Expression_Constant(true, 1);
  $body = new Twig_Node(array(
    new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1),
  ), array(), 1);
  $else = null;
  $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
  $node
    ->setAttribute('with_loop', false);
  $this
    ->assertEquals($keyTarget, $node
    ->getNode('key_target'));
  $this
    ->assertEquals($valueTarget, $node
    ->getNode('value_target'));
  $this
    ->assertEquals($seq, $node
    ->getNode('seq'));
  $this
    ->assertTrue($node
    ->getAttribute('ifexpr'));
  $this
    ->assertEquals('Twig_Node_If', get_class($node
    ->getNode('body')));
  $this
    ->assertEquals($body, $node
    ->getNode('body')
    ->getNode('tests')
    ->getNode(1)
    ->getNode(0));
  $this
    ->assertNull($node
    ->getNode('else'));
  $else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 1), 1);
  $node = new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
  $node
    ->setAttribute('with_loop', false);
  $this
    ->assertEquals($else, $node
    ->getNode('else'));
}