NameTest.php 1.4KB

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