BlockTest.php 1.2KB

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. require_once dirname(__FILE__).'/TestCase.php';
  11. class Twig_Tests_Node_BlockTest extends Twig_Tests_Node_TestCase
  12. {
  13. /**
  14. * @covers Twig_Node_Block::__construct
  15. */
  16. public function testConstructor()
  17. {
  18. $body = new Twig_Node_Text('foo', 0);
  19. $node = new Twig_Node_Block('foo', $body, 0);
  20. $this->assertEquals($body, $node->getNode('body'));
  21. $this->assertEquals('foo', $node->getAttribute('name'));
  22. }
  23. /**
  24. * @covers Twig_Node_Block::compile
  25. * @dataProvider getTests
  26. */
  27. public function testCompile($node, $source, $environment = null)
  28. {
  29. parent::testCompile($node, $source, $environment);
  30. }
  31. public function getTests()
  32. {
  33. $body = new Twig_Node_Text('foo', 0);
  34. $node = new Twig_Node_Block('foo', $body, 0);
  35. return array(
  36. array($node, <<<EOF
  37. public function block_foo(\$context, array \$blocks = array())
  38. {
  39. echo "foo";
  40. }
  41. EOF
  42. ),
  43. );
  44. }
  45. }