1<?php 2 3/* 4 * This file is part of Twig. 5 * 6 * (c) Fabien Potencier 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12use Twig\Node\Expression\AssignNameExpression; 13use Twig\Node\Expression\ConstantExpression; 14use Twig\Node\ImportNode; 15use Twig\Test\NodeTestCase; 16 17class Twig_Tests_Node_ImportTest extends NodeTestCase 18{ 19 public function testConstructor() 20 { 21 $macro = new ConstantExpression('foo.twig', 1); 22 $var = new AssignNameExpression('macro', 1); 23 $node = new ImportNode($macro, $var, 1); 24 25 $this->assertEquals($macro, $node->getNode('expr')); 26 $this->assertEquals($var, $node->getNode('var')); 27 } 28 29 public function getTests() 30 { 31 $tests = []; 32 33 $macro = new ConstantExpression('foo.twig', 1); 34 $var = new AssignNameExpression('macro', 1); 35 $node = new ImportNode($macro, $var, 1); 36 37 $tests[] = [$node, <<<EOF 38// line 1 39\$context["macro"] = \$this->loadTemplate("foo.twig", null, 1); 40EOF 41 ]; 42 43 return $tests; 44 } 45} 46