ImportTest.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. require_once dirname(__FILE__).'/TestCase.php';
  11. class Twig_Tests_Node_ImportTest extends Twig_Tests_Node_TestCase
  12. {
  13. /**
  14. * @covers Twig_Node_Import::__construct
  15. */
  16. public function testConstructor()
  17. {
  18. $macro = new Twig_Node_Expression_Constant('foo.twig', 0);
  19. $var = new Twig_Node_Expression_AssignName('macro', 0);
  20. $node = new Twig_Node_Import($macro, $var, 0);
  21. $this->assertEquals($macro, $node->getNode('expr'));
  22. $this->assertEquals($var, $node->getNode('var'));
  23. }
  24. /**
  25. * @covers Twig_Node_Import::compile
  26. * @dataProvider getTests
  27. */
  28. public function testCompile($node, $source, $environment = null)
  29. {
  30. parent::testCompile($node, $source, $environment);
  31. }
  32. public function getTests()
  33. {
  34. $tests = array();
  35. $macro = new Twig_Node_Expression_Constant('foo.twig', 0);
  36. $var = new Twig_Node_Expression_AssignName('macro', 0);
  37. $node = new Twig_Node_Import($macro, $var, 0);
  38. $tests[] = array($node, '$context["macro"] = $this->env->loadTemplate("foo.twig");');
  39. return $tests;
  40. }
  41. }