123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace Tests\Feature;
- use App\Models\Permission;
- use App\Models\Role;
- use App\Models\User;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Illuminate\Foundation\Testing\WithFaker;
- use Illuminate\Support\Facades\Artisan;
- use Laravel\Sanctum\Sanctum;
- class TestCase extends \Tests\TestCase
- {
- use RefreshDatabase, WithFaker;
- protected function setUp(): void
- {
- parent::setUp();
- $user = User::factory()->create([
- 'username' => 'lpc',
- 'email' => 'test@lpc.com',
- 'company_id' => 1,
- ]);
- Sanctum::actingAs($user);
- Artisan::call("lpc:initialize-route-permission");
- $role = Role::factory()->create();
- $user->role_id = $role->id;
- $user->save();
- $role->syncPermissions(Permission::query()->pluck('name')->toArray());
- $user->assignRole([$role->id]);
- }
- protected function simplePaginateResponseStructure(array $data): array
- {
- return [
- 'data' => [
- '*' => $data
- ],
- 'links' => [
- 'first',
- 'last',
- 'prev',
- 'next',
- ],
- 'meta' => [
- 'current_page',
- 'from',
- 'path',
- 'per_page',
- 'to',
- ]
- ];
- }
- }
|