@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PlatformAdminTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_command_creates_platform_admin_without_a_tenant(): void
|
||||
{
|
||||
$this->artisan('app:create-platform-admin', [
|
||||
'--name' => 'Platform Administrator',
|
||||
'--email' => 'admin@example.test',
|
||||
])
|
||||
->expectsQuestion('Password (minimum 12 characters)', 'Strong!Password123')
|
||||
->expectsQuestion('Confirm password', 'Strong!Password123')
|
||||
->expectsOutput('Platform Master Admin created successfully.')
|
||||
->assertSuccessful();
|
||||
|
||||
$admin = User::withoutGlobalScope('tenant')->firstOrFail();
|
||||
|
||||
$this->assertNull($admin->tenant_id);
|
||||
$this->assertTrue($admin->is_platform_admin);
|
||||
$this->assertTrue(Gate::forUser($admin)->allows('tenant.access-any'));
|
||||
}
|
||||
|
||||
public function test_normal_tenant_admin_does_not_receive_platform_access(): void
|
||||
{
|
||||
$user = User::factory()->create(['is_platform_admin' => false]);
|
||||
|
||||
$this->assertFalse(Gate::forUser($user)->allows('tenant.access-any'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user