tick() === true && $order === ['maintenance', 'compensation', 'abuse'] && $maintenanceCalls === 1 && $compensationCalls === 1 && $abuseCalls === 1 && $service->observationErrors() === [], 'First notification pass was not bounded or did not report work.'); $order = []; $assert($service->tick() === true && $order === ['compensation', 'abuse', 'maintenance'] && $maintenanceCalls === 2 && $compensationCalls === 2 && $abuseCalls === 2, 'Notification channel priority did not alternate fairly.'); $order = []; $assert($service->tick() === true && $order === ['abuse', 'maintenance', 'compensation'] && $maintenanceCalls === 3 && $compensationCalls === 3 && $abuseCalls === 3, 'Third notification channel did not receive fair first priority.'); $order = []; $isolated = new CloudNotificationDeliveryService( static function () use (&$order): bool { $order[] = 'maintenance'; throw new RuntimeException('expected maintenance failure'); }, static function () use (&$order): bool { $order[] = 'compensation'; return true; }, static function () use (&$order): bool { $order[] = 'abuse'; return true; } ); $assert($isolated->tick() === true && $order === ['maintenance', 'compensation', 'abuse'] && $isolated->observationErrors() === [ 'maintenance_notification_failed', ], 'A maintenance failure blocked compensation delivery or was hidden.'); $abuseUnavailable = new CloudNotificationDeliveryService( static fn (): bool => false, static fn (): bool => false, static function (): bool { throw new RuntimeException('expected local Telegram failure'); } ); $assert($abuseUnavailable->tick() === false && $abuseUnavailable->observationErrors() === [ 'abuse_alert_notification_failed', ], 'A local Telegram failure was reported as a healthy idle pass.'); $bothFailed = new CloudNotificationDeliveryService( static function (): bool { throw new RuntimeException('expected maintenance failure'); }, static function (): bool { throw new RuntimeException('expected compensation failure'); }, static function (): bool { throw new RuntimeException('expected abuse alert failure'); } ); $assert($bothFailed->tick() === false && $bothFailed->observationErrors() === [ 'maintenance_notification_failed', 'notification_failed', 'abuse_alert_notification_failed', ], 'Multiple notification channel failures were not retained.'); echo "Cloud notification delivery service test passed.\n";