ImportTest.php 1.3KB

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