ArrayTest.php 1.3KB

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_ArrayTest extends Twig_Test_NodeTestCase
  11. {
  12. /**
  13. * @covers Twig_Node_Expression_Array::__construct
  14. */
  15. public function testConstructor()
  16. {
  17. $elements = array(new Twig_Node_Expression_Constant('foo', 1), $foo = new Twig_Node_Expression_Constant('bar', 1));
  18. $node = new Twig_Node_Expression_Array($elements, 1);
  19. $this->assertEquals($foo, $node->getNode(1));
  20. }
  21. /**
  22. * @covers Twig_Node_Expression_Array::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. $elements = array(
  32. new Twig_Node_Expression_Constant('foo', 1),
  33. new Twig_Node_Expression_Constant('bar', 1),
  34. new Twig_Node_Expression_Constant('bar', 1),
  35. new Twig_Node_Expression_Constant('foo', 1),
  36. );
  37. $node = new Twig_Node_Expression_Array($elements, 1);
  38. return array(
  39. array($node, 'array("foo" => "bar", "bar" => "foo")'),
  40. );
  41. }
  42. }