TenantAtlas/tests/Unit/ManagedDeviceAppConfigurationNormalizerTest.php

46 lines
1.6 KiB
PHP

<?php
use App\Services\Intune\PolicyNormalizer;
use Tests\TestCase;
uses(TestCase::class);
test('managed device app configuration normalizer shows app config keys and values', function () {
$normalizer = app(PolicyNormalizer::class);
$snapshot = [
'id' => 'policy-1',
'displayName' => 'MAMDevice',
'@odata.type' => '#microsoft.graph.iosMobileAppConfiguration',
'settings' => [
[
'appConfigKey' => 'com.microsoft.outlook.EmailProfile.AccountType',
'appConfigKeyType' => 'stringType',
'appConfigKeyValue' => 'ModernAuth',
],
[
'appConfigKey' => 'com.microsoft.outlook.Mail.FocusedInbox',
'appConfigKeyType' => 'booleanType',
'appConfigKeyValue' => 'true',
],
],
];
$normalized = $normalizer->normalize($snapshot, 'managedDeviceAppConfiguration', 'mobile');
$blocks = collect($normalized['settings'] ?? []);
$appConfig = $blocks->firstWhere('title', 'App configuration settings');
expect($appConfig)->not->toBeNull();
expect($appConfig['type'] ?? null)->toBe('table');
$rows = collect($appConfig['rows'] ?? []);
$row = $rows->firstWhere('label', 'com.microsoft.outlook.EmailProfile.AccountType');
expect($row)->not->toBeNull();
expect($row['value'] ?? null)->toBe('ModernAuth');
$boolRow = $rows->firstWhere('label', 'com.microsoft.outlook.Mail.FocusedInbox');
expect($boolRow)->not->toBeNull();
expect($boolRow['value'] ?? null)->toBeTrue();
});