first commit
This commit is contained in:
34
tests/TestCase.php
Normal file
34
tests/TestCase.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use App\Models\Consultant;
|
||||
use App\Models\User;
|
||||
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
/** Semai peranan & kebenaran untuk ujian. */
|
||||
protected function seedRolesAndPermissions(): void
|
||||
{
|
||||
$this->seed(RolesAndPermissionsSeeder::class);
|
||||
}
|
||||
|
||||
protected function makeUserWithRole(string $role, array $attributes = []): User
|
||||
{
|
||||
$user = User::factory()->create($attributes);
|
||||
$user->assignRole($role);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/** Cipta pengguna perunding + profil perunding yang berkait. */
|
||||
protected function makeConsultantUser(array $consultantAttributes = []): array
|
||||
{
|
||||
$user = $this->makeUserWithRole('Perunding');
|
||||
$consultant = Consultant::factory()->create(array_merge(['user_id' => $user->id], $consultantAttributes));
|
||||
|
||||
return [$user, $consultant];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user