手动添加域名

This commit is contained in:
root
2026-07-06 10:34:34 +08:00
parent c3c58198ab
commit 7efb3e6eb5
11 changed files with 728 additions and 141 deletions
+23
View File
@@ -108,6 +108,29 @@ try {
$del = DomainProvisioningService::deleteWithCloudflare($pdo, $domainId);
$tests['delete_calls_zone'] = ($del['ok'] ?? false) === true && $mock->deleteCalled === true;
$tests['delete_row_gone'] = DomainRepository::findById($pdo, $domainId) === null;
// 手动模式:不创建 Zone
$hostManual = 'cf-manual-' . substr(md5((string) microtime(true)), 0, 8) . '.test';
$addManual = DomainProvisioningService::provisionOnAdd($pdo, $hostManual, 'manual');
$rowManual = DomainRepository::findById($pdo, (int) ($addManual['id'] ?? 0));
$tests['add_manual_cf_status'] = ($addManual['ok'] ?? false) === true
&& ($addManual['cf_status'] ?? '') === 'manual'
&& ($rowManual['cf_status'] ?? '') === 'manual'
&& trim((string) ($rowManual['cf_zone_id'] ?? '')) === '';
$checkManual = DomainProvisioningService::checkAndProvision($pdo, (int) ($addManual['id'] ?? 0));
$tests['check_manual_skipped'] = ($checkManual['ok'] ?? false) === false;
DomainRepository::deleteById($pdo, (int) ($addManual['id'] ?? 0));
// 批量添加
$batchText = "batch-a.test\nbatch-b.test, batch-c.test";
$batch = DomainProvisioningService::provisionBatch($pdo, $batchText, 'manual');
$tests['batch_add_count'] = ($batch['ok'] ?? false) === true && count($batch['added'] ?? []) === 3;
foreach ($batch['added'] ?? [] as $item) {
DomainRepository::deleteById($pdo, (int) ($item['id'] ?? 0));
}
$parsed = DomainRepository::parseHostnameBatch("a.test\nb.test\nc.test,d.test");
$tests['parse_hostname_batch'] = $parsed === ['a.test', 'b.test', 'c.test', 'd.test'];
} catch (Throwable $e) {
$tests['exception'] = false;
$tests['error'] = $e->getMessage();