BladeCannotStatementsTest.php 626 B

123456789101112131415161718192021
  1. <?php
  2. namespace Illuminate\Tests\View\Blade;
  3. class BladeCannotStatementsTest extends AbstractBladeTestCase
  4. {
  5. public function testCannotStatementsAreCompiled()
  6. {
  7. $string = '@cannot (\'update\', [$post])
  8. breeze
  9. @elsecannot(\'delete\', [$post])
  10. sneeze
  11. @endcannot';
  12. $expected = '<?php if (app(\\Illuminate\\Contracts\\Auth\\Access\\Gate::class)->denies(\'update\', [$post])): ?>
  13. breeze
  14. <?php elseif (app(\\Illuminate\\Contracts\\Auth\\Access\\Gate::class)->denies(\'delete\', [$post])): ?>
  15. sneeze
  16. <?php endif; ?>';
  17. $this->assertEquals($expected, $this->compiler->compileString($string));
  18. }
  19. }