SpacelessTest.php 1.2KB

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. class Twig_Tests_Node_SpacelessTest extends Twig_Test_NodeTestCase
  11. {
  12. /**
  13. * @covers Twig_Node_Spaceless::__construct
  14. */
  15. public function testConstructor()
  16. {
  17. $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1)));
  18. $node = new Twig_Node_Spaceless($body, 1);
  19. $this->assertEquals($body, $node->getNode('body'));
  20. }
  21. /**
  22. * @covers Twig_Node_Spaceless::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. $body = new Twig_Node(array(new Twig_Node_Text('<div> <div> foo </div> </div>', 1)));
  32. $node = new Twig_Node_Spaceless($body, 1);
  33. return array(
  34. array($node, <<<EOF
  35. // line 1
  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. }