更新bug
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
use app\adminapi\logic\tcm\DiagnosisLogic;
|
||||
|
||||
function callRecordIdentityExpect(bool $condition, string $message): void
|
||||
{
|
||||
if (!$condition) {
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
}
|
||||
|
||||
function callRecordIdentityMethodSource(ReflectionMethod $method): string
|
||||
{
|
||||
$lines = file($method->getFileName());
|
||||
if (!is_array($lines)) {
|
||||
throw new RuntimeException('call-record lifecycle source is readable');
|
||||
}
|
||||
|
||||
return implode('', array_slice(
|
||||
$lines,
|
||||
$method->getStartLine() - 1,
|
||||
$method->getEndLine() - $method->getStartLine() + 1
|
||||
));
|
||||
}
|
||||
|
||||
$logic = new ReflectionClass(DiagnosisLogic::class);
|
||||
$endCall = callRecordIdentityMethodSource($logic->getMethod('endCall'));
|
||||
$bindCallRoom = callRecordIdentityMethodSource($logic->getMethod('bindCallRoom'));
|
||||
$startCloudRecording = callRecordIdentityMethodSource($logic->getMethod('startCloudRecording'));
|
||||
|
||||
foreach (
|
||||
[
|
||||
'endCall' => $endCall,
|
||||
'bindCallRoom' => $bindCallRoom,
|
||||
'startCloudRecording' => $startCloudRecording,
|
||||
] as $methodName => $source
|
||||
) {
|
||||
callRecordIdentityExpect(
|
||||
str_contains($source, "\$callRecordId = (int)(\$params['call_record_id'] ?? 0)")
|
||||
&& str_contains($source, 'if ($callRecordId > 0)')
|
||||
&& str_contains($source, "CallRecord::where('id', \$callRecordId)")
|
||||
&& str_contains($source, "->where('diagnosis_id', \$diagnosisId)")
|
||||
&& str_contains($source, "->where('caller_id', \$adminId)")
|
||||
&& str_contains($source, "->where('caller_type', 'doctor')"),
|
||||
$methodName . ' uses the exact doctor-owned call record when its id is supplied'
|
||||
);
|
||||
}
|
||||
|
||||
callRecordIdentityExpect(
|
||||
str_contains($bindCallRoom, "'call_record_id' => (int)\$record['id']")
|
||||
&& str_contains($bindCallRoom, 'startCloudRecording(['),
|
||||
'room binding forwards the exact saved record to cloud recording'
|
||||
);
|
||||
callRecordIdentityExpect(
|
||||
str_contains($endCall, "(int)(\$record['status'] ?? 0) === 2")
|
||||
&& str_contains($endCall, 'return true;'),
|
||||
'ending the same exact call remains idempotent'
|
||||
);
|
||||
|
||||
$workspace = dirname(__DIR__, 2);
|
||||
$repository = (string) file_get_contents(
|
||||
$workspace . '/app/src/doctor_workstation/services/repository.py'
|
||||
);
|
||||
$lifecycle = (string) file_get_contents(
|
||||
$workspace . '/app/src/doctor_workstation/video/lifecycle.py'
|
||||
);
|
||||
callRecordIdentityExpect(
|
||||
substr_count($repository, 'body["call_record_id"] = normalized_id') >= 2,
|
||||
'desktop repository sends call_record_id for bind and end requests'
|
||||
);
|
||||
callRecordIdentityExpect(
|
||||
substr_count($lifecycle, '"call_record_id": record_id') >= 2,
|
||||
'desktop lifecycle keeps the created call record identity through later phases'
|
||||
);
|
||||
|
||||
echo "Call-record lifecycle identity contract: OK\n";
|
||||
Reference in New Issue
Block a user