57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Support\RestoreSafety\RestoreScopeFingerprint;
|
|
|
|
it('normalizes selected item and group mapping order into a stable fingerprint', function (): void {
|
|
$first = RestoreScopeFingerprint::fromInputs(
|
|
backupSetId: 10,
|
|
scopeMode: 'selected',
|
|
selectedItemIds: [9, 3, '3', 1],
|
|
groupMapping: [
|
|
'group-b' => 'target-b',
|
|
'group-a' => 'target-a',
|
|
],
|
|
);
|
|
|
|
$second = RestoreScopeFingerprint::fromInputs(
|
|
backupSetId: 10,
|
|
scopeMode: 'selected',
|
|
selectedItemIds: ['1', 3, 9],
|
|
groupMapping: [
|
|
'group-a' => 'target-a',
|
|
'group-b' => 'target-b',
|
|
],
|
|
);
|
|
|
|
expect($first->selectedItemIds)->toBe([1, 3, 9])
|
|
->and($first->fingerprint)->toBe($second->fingerprint);
|
|
});
|
|
|
|
it('changes fingerprint when scope-affecting values change', function (): void {
|
|
$base = RestoreScopeFingerprint::fromInputs(
|
|
backupSetId: 10,
|
|
scopeMode: 'selected',
|
|
selectedItemIds: [1, 2],
|
|
groupMapping: ['group-a' => 'target-a'],
|
|
);
|
|
|
|
$changedSelection = RestoreScopeFingerprint::fromInputs(
|
|
backupSetId: 10,
|
|
scopeMode: 'selected',
|
|
selectedItemIds: [1, 3],
|
|
groupMapping: ['group-a' => 'target-a'],
|
|
);
|
|
|
|
$changedMapping = RestoreScopeFingerprint::fromInputs(
|
|
backupSetId: 10,
|
|
scopeMode: 'selected',
|
|
selectedItemIds: [1, 2],
|
|
groupMapping: ['group-a' => 'SKIP'],
|
|
);
|
|
|
|
expect($base->fingerprint)->not->toBe($changedSelection->fingerprint)
|
|
->and($base->fingerprint)->not->toBe($changedMapping->fingerprint);
|
|
});
|