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
43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
|
|
use App\Services\Intune\DefaultPolicyNormalizer;
|
|
use App\Services\Intune\PolicyNormalizer;
|
|
use App\Services\Intune\PolicyTypeNormalizer;
|
|
|
|
it('routes to the first matching policy type normalizer', function () {
|
|
$defaultNormalizer = app(DefaultPolicyNormalizer::class);
|
|
|
|
$customNormalizer = new class implements PolicyTypeNormalizer
|
|
{
|
|
public function supports(string $policyType): bool
|
|
{
|
|
return $policyType === 'deviceCompliancePolicy';
|
|
}
|
|
|
|
public function normalize(?array $snapshot, string $policyType, ?string $platform = null): array
|
|
{
|
|
return [
|
|
'status' => 'custom',
|
|
'settings' => [],
|
|
'warnings' => [],
|
|
];
|
|
}
|
|
|
|
public function flattenForDiff(?array $snapshot, string $policyType, ?string $platform = null): array
|
|
{
|
|
return ['custom' => true];
|
|
}
|
|
};
|
|
|
|
$normalizer = new PolicyNormalizer($defaultNormalizer, [$customNormalizer]);
|
|
|
|
$custom = $normalizer->normalize(['id' => 'policy-1'], 'deviceCompliancePolicy', 'windows');
|
|
expect($custom['status'])->toBe('custom');
|
|
|
|
$customDiff = $normalizer->flattenForDiff(['id' => 'policy-1'], 'deviceCompliancePolicy', 'windows');
|
|
expect($customDiff)->toBe(['custom' => true]);
|
|
|
|
$fallback = $normalizer->normalize(['id' => 'policy-1'], 'unknownPolicy', 'windows');
|
|
expect($fallback['status'])->not->toBe('custom');
|
|
});
|