setTimezone( new DateTimeZone(CloudAutomaticBackupService::TIMEZONE) ); $assert($local->format('w H:i') === '1 00:00', 'Weekly schedule did not use the selected Pacific weekday at midnight.'); $routes = file_get_contents(dirname(__DIR__) . '/config/routes_cloud.php'); $controller = file_get_contents( dirname(__DIR__) . '/app/Controllers/CloudApiController.php' ); $middleware = file_get_contents(dirname(__DIR__) . '/app/Middleware/CloudApi.php'); $automaticService = file_get_contents( dirname(__DIR__) . '/app/Services/Cloud/CloudAutomaticBackupService.php' ); $backupService = file_get_contents( dirname(__DIR__) . '/app/Services/Cloud/CloudBackupService.php' ); $assert(str_contains($routes, "'/backups'") && str_contains($routes, "'/vms/{id:[0-9]+}/automatic-backup'") && str_contains($routes, "'/vms/{id:[0-9]+}/automatic-backup/enable'") && str_contains($routes, "'/vms/{id:[0-9]+}/automatic-backup/disable'") && str_contains($routes, "'/vms/{id:[0-9]+}/automatic-backup/{backup_id:[0-9]+}/restore'"), 'Owner backup routes are incomplete.'); $assert(str_contains($controller, 'CloudAutomaticBackupBillingService::enable(') && str_contains($controller, 'CloudAutomaticBackupBillingService::disable(') && str_contains($controller, '$value[\'billing\'] =') && str_contains($controller, "'entitlement_paid_until' =>"), 'Owner backup API does not expose the paid toggle and billing state.'); $assert(str_contains($middleware, "#^/api/v1/vms/[0-9]+/automatic-backup(?:/(?:enable|disable))?$#D") && !str_contains($middleware, 'automatic-backup(?:/|$)'), 'Database-only backup routes are missing or incorrectly include restore.'); $assert(str_contains($automaticService, 'CloudBackupPeriodEntitlement::where(') && str_contains($automaticService, '->where(\'starts_at\', \'<=\', $scheduledFor)') && str_contains($backupService, 'CloudBackupPeriodEntitlement::where(') && str_contains($backupService, '->where(\'ends_at\', \'>\', $scheduledFor)') && !str_contains($backupService, '($spec[\'automatic_backup\'] ?? null) !== true'), 'Automatic backup scheduling is not guarded by paid-period entitlement on both sides of the transaction.'); echo "Automatic backup Pacific schedule and route contract passed.\n";