TenantAtlas/tests/Unit/Baselines/BaselineSnapshotItemNormalizerTest.php
ahmido e7c9b4b853 feat: implement governance artifact truth semantics (#188)
## Summary
- add shared governance artifact truth presentation and badge taxonomy
- integrate artifact-truth messaging across baseline, evidence, tenant review, review pack, and operation run surfaces
- add focused regression coverage and spec artifacts for artifact truth semantics

## Testing
- not run in this step

Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de>
Reviewed-on: #188
2026-03-23 00:13:57 +00:00

60 lines
1.9 KiB
PHP

<?php
declare(strict_types=1);
use App\Services\Baselines\BaselineSnapshotItemNormalizer;
it('deduplicates snapshot items by subject reference and keeps the stronger evidence', function (): void {
$normalizer = new BaselineSnapshotItemNormalizer;
$result = $normalizer->deduplicate([
[
'subject_type' => 'policy',
'subject_external_id' => 'subject-1',
'subject_key' => 'standard',
'policy_type' => 'deviceConfiguration',
'baseline_hash' => 'hash-meta',
'meta_jsonb' => [
'evidence' => [
'fidelity' => 'meta',
'observed_at' => '2026-03-22T23:18:29+00:00',
],
],
],
[
'subject_type' => 'policy',
'subject_external_id' => 'subject-1',
'subject_key' => 'standard',
'policy_type' => 'deviceConfiguration',
'baseline_hash' => 'hash-content',
'meta_jsonb' => [
'evidence' => [
'fidelity' => 'content',
'observed_at' => '2026-03-22T23:18:30+00:00',
],
],
],
[
'subject_type' => 'policy',
'subject_external_id' => 'subject-2',
'subject_key' => 'unique',
'policy_type' => 'deviceConfiguration',
'baseline_hash' => 'hash-unique',
'meta_jsonb' => [
'evidence' => [
'fidelity' => 'content',
'observed_at' => '2026-03-22T23:18:31+00:00',
],
],
],
]);
expect($result['duplicates'])->toBe(1)
->and($result['items'])->toHaveCount(2)
->and(collect($result['items'])->firstWhere('subject_external_id', 'subject-1'))
->toMatchArray([
'baseline_hash' => 'hash-content',
'subject_key' => 'standard',
]);
});