ArrayTest.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_ArrayTest extends Twig_Tests_Node_TestCase
  12. {
  13. /**
  14. * @covers Twig_Node_Expression_Array::__construct
  15. */
  16. public function testConstructor()
  17. {
  18. $elements = array(new Twig_Node_Expression_Constant('foo', 0), $foo = new Twig_Node_Expression_Constant('bar', 0));
  19. $node = new Twig_Node_Expression_Array($elements, 0);
  20. $this->assertEquals($foo, $node->getNode(1));
  21. }
  22. /**
  23. * @covers Twig_Node_Expression_Array::compile
  24. * @dataProvider getTests
  25. */
  26. public function testCompile($node, $source, $environment = null)
  27. {
  28. parent::testCompile($node, $source, $environment);
  29. }
  30. public function getTests()
  31. {
  32. $elements = array(
  33. new Twig_Node_Expression_Constant('foo', 0),
  34. new Twig_Node_Expression_Constant('bar', 0),
  35. new Twig_Node_Expression_Constant('bar', 0),
  36. new Twig_Node_Expression_Constant('foo', 0),
  37. );
  38. $node = new Twig_Node_Expression_Array($elements, 0);
  39. return array(
  40. array($node, 'array("foo" => "bar", "bar" => "foo")'),
  41. );
  42. }
  43. }