40 lines
1.0 KiB
PHP
40 lines
1.0 KiB
PHP
<?php
|
|
|
|
use App\Services\Drift\DriftHasher;
|
|
|
|
test('normalized hashing ignores volatile timestamps', function () {
|
|
$hasher = app(DriftHasher::class);
|
|
|
|
$a = [
|
|
'id' => 'abc',
|
|
'createdDateTime' => '2020-01-01T00:00:00Z',
|
|
'lastModifiedDateTime' => '2020-01-02T00:00:00Z',
|
|
'target' => ['groupId' => 'group-a'],
|
|
];
|
|
|
|
$b = [
|
|
'id' => 'abc',
|
|
'createdDateTime' => '2025-01-01T00:00:00Z',
|
|
'lastModifiedDateTime' => '2026-01-02T00:00:00Z',
|
|
'target' => ['groupId' => 'group-a'],
|
|
];
|
|
|
|
expect($hasher->hashNormalized($a))->toBe($hasher->hashNormalized($b));
|
|
});
|
|
|
|
test('normalized hashing is order-insensitive for lists', function () {
|
|
$hasher = app(DriftHasher::class);
|
|
|
|
$listA = [
|
|
['target' => ['groupId' => 'group-a']],
|
|
['target' => ['groupId' => 'group-b']],
|
|
];
|
|
|
|
$listB = [
|
|
['target' => ['groupId' => 'group-b']],
|
|
['target' => ['groupId' => 'group-a']],
|
|
];
|
|
|
|
expect($hasher->hashNormalized($listA))->toBe($hasher->hashNormalized($listB));
|
|
});
|