BladeEnvironmentStatementsTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. namespace Illuminate\Tests\View\Blade;
  3. class BladeEnvironmentStatementsTest extends AbstractBladeTestCase
  4. {
  5. public function testEnvStatementsAreCompiled()
  6. {
  7. $string = "@env('staging')
  8. breeze
  9. @else
  10. boom
  11. @endenv";
  12. $expected = "<?php if(app()->environment('staging')): ?>
  13. breeze
  14. <?php else: ?>
  15. boom
  16. <?php endif; ?>";
  17. $this->assertEquals($expected, $this->compiler->compileString($string));
  18. }
  19. public function testEnvStatementsWithMultipleStringParamsAreCompiled()
  20. {
  21. $string = "@env('staging', 'production')
  22. breeze
  23. @else
  24. boom
  25. @endenv";
  26. $expected = "<?php if(app()->environment('staging', 'production')): ?>
  27. breeze
  28. <?php else: ?>
  29. boom
  30. <?php endif; ?>";
  31. $this->assertEquals($expected, $this->compiler->compileString($string));
  32. }
  33. public function testEnvStatementsWithArrayParamAreCompiled()
  34. {
  35. $string = "@env(['staging', 'production'])
  36. breeze
  37. @else
  38. boom
  39. @endenv";
  40. $expected = "<?php if(app()->environment(['staging', 'production'])): ?>
  41. breeze
  42. <?php else: ?>
  43. boom
  44. <?php endif; ?>";
  45. $this->assertEquals($expected, $this->compiler->compileString($string));
  46. }
  47. public function testProductionStatementsAreCompiled()
  48. {
  49. $string = '@production
  50. breeze
  51. @else
  52. boom
  53. @endproduction';
  54. $expected = "<?php if(app()->environment('production')): ?>
  55. breeze
  56. <?php else: ?>
  57. boom
  58. <?php endif; ?>";
  59. $this->assertEquals($expected, $this->compiler->compileString($string));
  60. }
  61. }