NameTest.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_Expression_NameTest extends Twig_Tests_Node_TestCase
  12. {
  13. /**
  14. * @covers Twig_Node_Expression_Name::__construct
  15. */
  16. public function testConstructor()
  17. {
  18. $node = new Twig_Node_Expression_Name('foo', 0);
  19. $this->assertEquals('foo', $node->getAttribute('name'));
  20. }
  21. /**
  22. * @covers Twig_Node_Expression_Name::compile
  23. * @dataProvider getTests
  24. */
  25. public function testCompile($node, $source, $environment = null)
  26. {
  27. parent::testCompile($node, $source, $environment);
  28. }
  29. public function getTests()
  30. {
  31. $node = new Twig_Node_Expression_Name('foo', 0);
  32. $self = new Twig_Node_Expression_Name('_self', 0);
  33. $context = new Twig_Node_Expression_Name('_context', 0);
  34. $env = new Twig_Environment(null, array('strict_variables' => true));
  35. $env1 = new Twig_Environment(null, array('strict_variables' => false));
  36. return array(
  37. array($node, '$this->getContext($context, "foo")', $env),
  38. array($node, $this->getVariableGetter('foo'), $env1),
  39. array($self, '$this'),
  40. array($context, '$context'),
  41. );
  42. }
  43. }