NestedPartialIndentTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of Mustache.php.
  4. *
  5. * (c) 2010-2015 Justin Hileman
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * @group functional
  12. * @group partials
  13. */
  14. class Mustache_Test_Functional_NestedPartialIndentTest extends PHPUnit_Framework_TestCase
  15. {
  16. /**
  17. * @dataProvider partialsAndStuff
  18. */
  19. public function testNestedPartialsAreIndentedProperly($src, array $partials, $expected)
  20. {
  21. $m = new Mustache_Engine(array(
  22. 'partials' => $partials,
  23. ));
  24. $tpl = $m->loadTemplate($src);
  25. $this->assertEquals($expected, $tpl->render());
  26. }
  27. public function partialsAndStuff()
  28. {
  29. $partials = array(
  30. 'a' => ' {{> b }}',
  31. 'b' => ' {{> d }}',
  32. 'c' => ' {{> d }}{{> d }}',
  33. 'd' => 'D!',
  34. );
  35. return array(
  36. array(' {{> a }}', $partials, ' D!'),
  37. array(' {{> b }}', $partials, ' D!'),
  38. array(' {{> c }}', $partials, ' D!D!'),
  39. );
  40. }
  41. }