52 lines
2.1 KiB
PHP
52 lines
2.1 KiB
PHP
<?php
|
|
|
|
use App\Services\Graph\GraphContractRegistry;
|
|
use Tests\TestCase;
|
|
|
|
uses(TestCase::class);
|
|
|
|
beforeEach(function () {
|
|
$this->registry = app(GraphContractRegistry::class);
|
|
});
|
|
|
|
it('preserves @odata.type with actual choiceSettingValue data structure', function () {
|
|
$settings = [
|
|
[
|
|
'id' => '0',
|
|
'settingInstance' => [
|
|
'@odata.type' => '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance',
|
|
'choiceSettingValue' => [
|
|
'value' => 'device_vendor_msft_passportforwork_biometrics_usebiometrics_true',
|
|
'children' => [],
|
|
'settingValueTemplateReference' => null,
|
|
],
|
|
'settingDefinitionId' => 'device_vendor_msft_passportforwork_biometrics_usebiometrics',
|
|
'auditRuleInformation' => null,
|
|
'settingInstanceTemplateReference' => null,
|
|
],
|
|
],
|
|
];
|
|
|
|
$sanitized = $this->registry->sanitizeSettingsApplyPayload('settingsCatalogPolicy', $settings);
|
|
|
|
expect($sanitized)->toBeArray();
|
|
expect(count($sanitized))->toBe(1);
|
|
|
|
// Top-level id should be stripped
|
|
expect(array_key_exists('id', $sanitized[0]))->toBeFalse();
|
|
|
|
// settingInstance should exist
|
|
expect(isset($sanitized[0]['settingInstance']))->toBeTrue();
|
|
|
|
// @odata.type should be preserved inside settingInstance
|
|
expect(isset($sanitized[0]['settingInstance']['@odata.type']))->toBeTrue();
|
|
expect($sanitized[0]['settingInstance']['@odata.type'])->toBe('#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance');
|
|
|
|
// choiceSettingValue should still exist
|
|
expect(isset($sanitized[0]['settingInstance']['choiceSettingValue']))->toBeTrue();
|
|
expect($sanitized[0]['settingInstance']['choiceSettingValue']['value'])->toBe('device_vendor_msft_passportforwork_biometrics_usebiometrics_true');
|
|
|
|
// Null values should be preserved (Graph might need them)
|
|
expect(array_key_exists('settingValueTemplateReference', $sanitized[0]['settingInstance']['choiceSettingValue']))->toBeTrue();
|
|
});
|