You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
2.7 KiB
PHTML
57 lines
2.7 KiB
PHTML
|
2 weeks ago
|
<?php
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
$root = dirname(__DIR__);
|
||
|
|
$service = file_get_contents(
|
||
|
|
$root . '/app/Services/Cloud/CloudServiceCompensationNotificationService.php'
|
||
|
|
);
|
||
|
|
$projection = file_get_contents(
|
||
|
|
$root . '/app/Services/Cloud/CloudServiceCompensationService.php'
|
||
|
|
);
|
||
|
|
$deletion = file_get_contents(
|
||
|
|
$root . '/app/Services/UserDataDeletionService.php'
|
||
|
|
);
|
||
|
|
$assert = static function (bool $condition, string $message): void {
|
||
|
|
if (!$condition) {
|
||
|
|
throw new RuntimeException($message);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
$assert(str_contains($projection, 'if ($open === 0)')
|
||
|
|
&& str_contains($projection, '->freezeLocked($batch, $now);'),
|
||
|
|
'Terminal batch projection no longer freezes compensation recipients.');
|
||
|
|
$assert(str_contains($service, 'public const LEASE_SECONDS = 300;')
|
||
|
|
&& str_contains(
|
||
|
|
$service,
|
||
|
|
'$recipient->lease_until = $now + self::LEASE_SECONDS;'
|
||
|
|
),
|
||
|
|
'Compensation delivery lost its 300 second lease.');
|
||
|
|
$assert(str_contains($service, "->where('state', 'applied')")
|
||
|
|
&& str_contains($service, '$byUser[(int) $item->user_id][] = $item;')
|
||
|
|
&& str_contains($service, '$recipient->instance_count = count($userItems);'),
|
||
|
|
'Compensation recipients are no longer grouped from applied items only.');
|
||
|
|
$assert(str_contains($service, '$recipient->email_snapshot = $email;')
|
||
|
|
&& str_contains($service, '$recipient->payload_json = $payloadJson;')
|
||
|
|
&& str_contains($service, '$recipient->payload_sha256 = $payloadHash;')
|
||
|
|
&& str_contains($service, "hash('sha256', \$payloadJson)"),
|
||
|
|
'Compensation delivery no longer freezes email, payload and digest.');
|
||
|
|
$assert(str_contains($service, "'delivery_effect_unknown'")
|
||
|
|
&& str_contains($service, "'delivery_lease_expired'")
|
||
|
|
&& str_contains($service, "\$accepted ? 'sent' : 'unknown'"),
|
||
|
|
'Ambiguous mail effects no longer converge to unknown.');
|
||
|
|
foreach (['user_deleted', 'recipient_email_changed',
|
||
|
|
'recipient_blacklisted'] as $code) {
|
||
|
|
$assert(str_contains($service, "'{$code}'"),
|
||
|
|
'Compensation preflight lost skip outcome: ' . $code);
|
||
|
|
}
|
||
|
|
$assert(str_contains($service, 'if (!(bool) $batch->notify_users)')
|
||
|
|
&& str_contains($service, '$batch->recipient_count = 0;')
|
||
|
|
&& str_contains($service, '$batch->recipient_count = CloudServiceCompensationRecipient::where('),
|
||
|
|
'Notification opt-out or recipient-count projection was removed.');
|
||
|
|
$assert(str_contains($deletion, "'cloud_service_compensation_items as compensation_item'")
|
||
|
|
&& str_contains($deletion, "->whereIn('compensation_batch.state', [")
|
||
|
|
&& str_contains($deletion, "'pending', 'applying',"),
|
||
|
|
'Account deletion no longer fences users while compensation is open.');
|
||
|
|
|
||
|
|
echo "Service compensation notification contracts passed.\n";
|