feat: add roles seeder with 4 roles and default admin account
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AuthTest extends TestCase
|
||||
@@ -26,4 +27,23 @@ class AuthTest extends TestCase
|
||||
|
||||
$this->assertDatabaseHas('users', ['email' => 'admin@test.com']);
|
||||
}
|
||||
|
||||
public function test_roles_seeder_creates_four_roles(): void
|
||||
{
|
||||
$this->artisan('db:seed', ['--class' => 'RolesAndAdminSeeder']);
|
||||
|
||||
$this->assertDatabaseHas('roles', ['name' => 'administrator']);
|
||||
$this->assertDatabaseHas('roles', ['name' => 'pengurus_ibadah']);
|
||||
$this->assertDatabaseHas('roles', ['name' => 'petugas_pendataan']);
|
||||
$this->assertDatabaseHas('roles', ['name' => 'pemangku_kebijakan']);
|
||||
}
|
||||
|
||||
public function test_roles_seeder_creates_default_admin(): void
|
||||
{
|
||||
$this->artisan('db:seed', ['--class' => 'RolesAndAdminSeeder']);
|
||||
|
||||
$user = User::where('email', 'admin@webgis.local')->first();
|
||||
$this->assertNotNull($user);
|
||||
$this->assertTrue($user->hasRole('administrator'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user