1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
<?php
namespace Illuminate\Tests\Integration\Generators;
class PolicyMakeCommandTest extends TestCase
{
protected $files = [
'app/Policies/FooPolicy.php',
];
public function testItCanGeneratePolicyFile()
{
$this->artisan('make:policy', ['name' => 'FooPolicy'])
->assertExitCode(0);
$this->assertFileContains([
'namespace App\Policies;',
'use Illuminate\Foundation\Auth\User;',
'class FooPolicy',
], 'app/Policies/FooPolicy.php');
}
public function testItCanGeneratePolicyFileWithModelOption()
{
$this->artisan('make:policy', ['name' => 'FooPolicy', '--model' => 'Post'])
->assertExitCode(0);
$this->assertFileContains([
'namespace App\Policies;',
'use App\Models\Post;',
'use Illuminate\Foundation\Auth\User;',
'class FooPolicy',
'public function viewAny(User $user)',
'public function view(User $user, Post $post)',
'public function create(User $user)',
'public function update(User $user, Post $post)',
'public function delete(User $user, Post $post)',
'public function restore(User $user, Post $post)',
'public function forceDelete(User $user, Post $post)',
], 'app/Policies/FooPolicy.php');
}
}
|