TenantAtlas/tests/Unit/TenantResourceConsentUrlTest.php
ahmido 93dbd3b13d fix(tests): remove per-file TestCase uses (#45)
What Changed

Removed per-file uses(TestCase::class ...) bindings in Unit tests to avoid Pest v4 “folder already uses the test case” discovery failure (kept RefreshDatabase where needed).
Updated the backup scheduling job test to pass the newly required BulkOperationService when manually calling RunBackupScheduleJob::handle().
Where

Unit (bulk cleanup across 56 files)
RunBackupScheduleJobTest.php
Verification

./vendor/bin/sail test → 443 passed, 5 skipped

Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local>
Reviewed-on: #45
2026-01-08 00:41:46 +00:00

30 lines
1.1 KiB
PHP

<?php
use App\Filament\Resources\TenantResource;
use App\Models\Tenant;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('includes scope parameter in admin consent url', function () {
// The adminConsentUrl builds scopes from intune_permissions config, not graph.scope
$tenant = Tenant::create([
'tenant_id' => 'b0091e5d-944f-4a34-bcd9-12cbfb7b75cf',
'name' => 'Test Tenant',
'app_client_id' => 'client-id',
]);
$url = TenantResource::adminConsentUrl($tenant);
expect($url)->toContain('scope=');
// Should contain permissions from intune_permissions config
$requiredPermissions = config('intune_permissions.permissions', []);
if (! empty($requiredPermissions)) {
$firstPermission = $requiredPermissions[0]['key'];
expect($url)->toContain(urlencode("https://graph.microsoft.com/{$firstPermission}"));
} else {
// Fallback to .default if no permissions configured
expect($url)->toContain(urlencode('https://graph.microsoft.com/.default'));
}
});