Files
zyt/server/tests/DiagnosisTaskValidationR37Test.php
T
2026-10-27 14:03:35 +08:00

28 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
require dirname(__DIR__) . '/vendor/autoload.php';
use app\adminapi\validate\tcm\DiagnosisValidate;
$checks = 0;
// Lang::has uses its local dictionary only. No application constructor or bootstrap.
$unbootedApp = (new ReflectionClass(think\App::class))->newInstanceWithoutConstructor();
$tasks = ['summary', 'case_analysis', 'glucose_trend', 'lifestyle_advice', 'tcm_pattern',
'prescription_review', 'prescription_generate', 'medication_review', 'exam_review',
'complication_risk', 'guideline_review', 'custom'];
foreach ($tasks as $task) {
$validator = new DiagnosisValidate();
$validator->setLang(new think\Lang($unbootedApp));
if (!$validator->only(['task'])->check(['task' => $task])) throw new RuntimeException('Expected supported task: ' . $task);
++$checks;
}
foreach (['', 'source_only', 'glucose_trend,custom', 'CUSTOM', '<script>'] as $task) {
$validator = new DiagnosisValidate();
$validator->setLang(new think\Lang($unbootedApp));
if ($validator->only(['task'])->check(['task' => $task])) throw new RuntimeException('Unexpected task accepted');
++$checks;
}
echo json_encode(['passed' => $checks, 'scope' => 'actual task validator only; diagnosis authorization and database not invoked']) . "\n";