Initial commit device-management
tests / ci (push) Has been cancelled

This commit is contained in:
Wian Drs
2026-08-25 09:42:00 +07:00
commit 1e80be180e
1159 changed files with 149545 additions and 0 deletions
+38
View File
@@ -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'));
}
}