BlockTest.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_BlockTest extends Twig_Test_NodeTestCase
  11. {
  12. /**
  13. * @covers Twig_Node_Block::__construct
  14. */
  15. public function testConstructor()
  16. {
  17. $body = new Twig_Node_Text('foo', 1);
  18. $node = new Twig_Node_Block('foo', $body, 1);
  19. $this->assertEquals($body, $node->getNode('body'));
  20. $this->assertEquals('foo', $node->getAttribute('name'));
  21. }
  22. /**
  23. * @covers Twig_Node_Block::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. $body = new Twig_Node_Text('foo', 1);
  33. $node = new Twig_Node_Block('foo', $body, 1);
  34. return array(
  35. array($node, <<<EOF
  36. // line 1
  37. public function block_foo(\$context, array \$blocks = array())
  38. {
  39. echo "foo";
  40. }
  41. EOF
  42. ),
  43. );
  44. }
  45. }