BladeCanStatementsTest.php 609 B

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