BladeForStatementsTest.php 786 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Illuminate\Tests\View\Blade;
  3. class BladeForStatementsTest extends AbstractBladeTestCase
  4. {
  5. public function testForStatementsAreCompiled()
  6. {
  7. $string = '@for ($i = 0; $i < 10; $i++)
  8. test
  9. @endfor';
  10. $expected = '<?php for($i = 0; $i < 10; $i++): ?>
  11. test
  12. <?php endfor; ?>';
  13. $this->assertEquals($expected, $this->compiler->compileString($string));
  14. }
  15. public function testNestedForStatementsAreCompiled()
  16. {
  17. $string = '@for ($i = 0; $i < 10; $i++)
  18. @for ($j = 0; $j < 20; $j++)
  19. test
  20. @endfor
  21. @endfor';
  22. $expected = '<?php for($i = 0; $i < 10; $i++): ?>
  23. <?php for($j = 0; $j < 20; $j++): ?>
  24. test
  25. <?php endfor; ?>
  26. <?php endfor; ?>';
  27. $this->assertEquals($expected, $this->compiler->compileString($string));
  28. }
  29. }