SpacelessTest.php 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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_SpacelessTest extends Twig_Tests_Node_TestCase
  12. {
  13. /**
  14. * @covers Twig_Node_Spaceless::__construct
  15. */
  16. public function testConstructor()
  17. {
  18. $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 0)));
  19. $node = new Twig_Node_Spaceless($body, 0);
  20. $this->assertEquals($body, $node->getNode('body'));
  21. }
  22. /**
  23. * @covers Twig_Node_Spaceless::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(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 0)));
  33. $node = new Twig_Node_Spaceless($body, 0);
  34. return array(
  35. array($node, <<<EOF
  36. ob_start();
  37. echo "<div> <div> foo </div> </div>";
  38. echo trim(preg_replace('/>\s+</', '><', ob_get_clean()));
  39. EOF
  40. ),
  41. );
  42. }
  43. }