TenantAtlas/tests/Feature/Filament/ScriptPoliciesNormalizedDisplayTest.php
2026-01-01 12:50:37 +01:00

52 lines
1.6 KiB
PHP

<?php
use App\Models\Policy;
use App\Models\PolicyVersion;
use App\Models\Tenant;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('renders policy version normalized settings for script policies', function (string $policyType, string $odataType) {
$originalEnv = getenv('INTUNE_TENANT_ID');
putenv('INTUNE_TENANT_ID=');
$this->actingAs(User::factory()->create());
$tenant = Tenant::factory()->create();
putenv('INTUNE_TENANT_ID='.$tenant->tenant_id);
$tenant->makeCurrent();
$policy = Policy::factory()->create([
'tenant_id' => $tenant->id,
'policy_type' => $policyType,
'platform' => 'all',
'display_name' => 'Script policy',
'external_id' => 'policy-1',
]);
PolicyVersion::factory()->create([
'policy_id' => $policy->id,
'tenant_id' => $tenant->id,
'policy_type' => $policyType,
'snapshot' => [
'@odata.type' => $odataType,
'displayName' => 'Script policy',
'description' => 'desc',
'scriptContent' => str_repeat('X', 20),
],
]);
$this->get(\App\Filament\Resources\PolicyVersionResource::getUrl('index'))
->assertSuccessful();
$originalEnv !== false
? putenv("INTUNE_TENANT_ID={$originalEnv}")
: putenv('INTUNE_TENANT_ID');
})->with([
['deviceManagementScript', '#microsoft.graph.deviceManagementScript'],
['deviceShellScript', '#microsoft.graph.deviceShellScript'],
['deviceHealthScript', '#microsoft.graph.deviceHealthScript'],
]);