BladeIfStatementsTest.php 853 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace Illuminate\Tests\View\Blade;
  3. class BladeIfStatementsTest extends AbstractBladeTestCase
  4. {
  5. public function testIfStatementsAreCompiled()
  6. {
  7. $string = '@if (name(foo(bar)))
  8. breeze
  9. @endif';
  10. $expected = '<?php if(name(foo(bar))): ?>
  11. breeze
  12. <?php endif; ?>';
  13. $this->assertEquals($expected, $this->compiler->compileString($string));
  14. }
  15. public function testSwitchstatementsAreCompiled()
  16. {
  17. $string = '@switch(true)
  18. @case(1)
  19. foo
  20. @case(2)
  21. bar
  22. @endswitch
  23. foo
  24. @switch(true)
  25. @case(1)
  26. foo
  27. @case(2)
  28. bar
  29. @endswitch';
  30. $expected = '<?php switch(true):
  31. case (1): ?>
  32. foo
  33. <?php case (2): ?>
  34. bar
  35. <?php endswitch; ?>
  36. foo
  37. <?php switch(true):
  38. case (1): ?>
  39. foo
  40. <?php case (2): ?>
  41. bar
  42. <?php endswitch; ?>';
  43. $this->assertEquals($expected, $this->compiler->compileString($string));
  44. }
  45. }