Files
device-management/tests/Feature/LicensingArchitectureTest.php
T
Wian Drs 1e80be180e
tests / ci (push) Has been cancelled
Initial commit device-management
2026-08-25 09:42:00 +07:00

53 lines
1.7 KiB
PHP

<?php
namespace Tests\Feature;
use App\Enums\DeploymentMode;
use App\Enums\LicenseStatus;
use App\Models\DeploymentInstallation;
use App\Models\License;
use App\Models\Tenant;
use App\Support\TenantContext;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class LicensingArchitectureTest extends TestCase
{
use RefreshDatabase;
public function test_license_and_installation_are_tenant_scoped(): void
{
$tenantA = Tenant::factory()->create();
$tenantB = Tenant::factory()->create();
$installation = DeploymentInstallation::create([
'tenant_id' => $tenantA->id,
'name' => 'ISP A Server',
'deployment_type' => DeploymentMode::SelfHosted,
'instance_key_hash' => hash('sha256', 'instance-secret'),
]);
License::create([
'tenant_id' => $tenantA->id,
'deployment_installation_id' => $installation->id,
'license_key_hash' => hash('sha256', 'RNDM-RAW-KEY'),
'plan' => 'professional',
'status' => LicenseStatus::Active,
'starts_at' => now(),
'expires_at' => now()->addYear(),
]);
app(TenantContext::class)->set($tenantB->id);
$this->assertCount(0, License::all());
$this->assertCount(0, DeploymentInstallation::all());
}
public function test_self_hosted_installation_cannot_create_platform_admin(): void
{
config()->set('deployment.mode', DeploymentMode::SelfHosted->value);
$this->artisan('app:create-platform-admin')
->expectsOutput('Platform Super Admin hanya dibuat pada RADIQ control plane atau managed cloud.')
->assertFailed();
}
}