9ddec3dfb9
- 在测试代码中统一使用 setPreviousAction 与 setDuration 方法,规范方法调用 - VirtualContextBuilder 允许 setDuration 接收 null,增强灵活性 - VirtualityFlowProcessor 计算步骤持续时间时改进判断逻辑,避免错误持续时间值 - 增加日志记录上一步骤开始时间,方便调试流程状态 - 自定义流程配置文件大幅重构,新增多种晨洗模式配置 - 新增机洗单步骤流程、无晨洗流程、每日首次晨洗、存储超时晨洗等多种流程样例 - 自定义流程支持 override_steps 为 true/false 的不同合并策略说明与示例 - 详细补充配置节点说明,增强配置文档准确性和用户理解 - 自定义语音模板扩展,支持多种语音播报及错误提示文本 - 更新时间验证配置,统一各流程中各步骤时间要求 - 补充“配置自定义节点流程指南”文档,详细说明配置原则、合并策略与使用建议
111 lines
3.0 KiB
PHP
111 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace tests\flow\cases;
|
|
|
|
use app\flow\ProcessEngine;
|
|
use tests\flow\TestCase;
|
|
use tests\flow\VirtualityFlowProcessor;
|
|
|
|
/**
|
|
* 语音输出测试
|
|
*
|
|
* 覆盖场景:
|
|
* 6. 语音输出正确性验证
|
|
*/
|
|
class VoiceTest extends TestCase
|
|
{
|
|
private VirtualityFlowProcessor $processor;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->processor = VirtualityFlowProcessor::createStandard();
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
parent::tearDown();
|
|
$this->processor->reset();
|
|
}
|
|
|
|
// ==================== 6. 语音输出正确性验证 ====================
|
|
|
|
/**
|
|
* 测试清洗步骤语音输出
|
|
*/
|
|
public function testWashStepVoice(): void
|
|
{
|
|
$result = $this->processor->swipe('操作员1', '胃镜1', '清洗');
|
|
|
|
$this->assertSuccess($result);
|
|
// 语音应该包含步骤相关信息
|
|
$voice = $result->getFullVoice();
|
|
$this->assertNotEmpty($voice, '应有语音输出');
|
|
}
|
|
|
|
/**
|
|
* 测试消毒步骤语音输出
|
|
*/
|
|
public function testDisinfectStepVoice(): void
|
|
{
|
|
// 先完成前置步骤
|
|
$this->processor->swipe('操作员1', '胃镜1', '清洗');
|
|
$this->processor->swipe('操作员1', '胃镜1', '漂洗');
|
|
|
|
// 消毒步骤
|
|
$result = $this->processor->swipe('操作员1', '胃镜1', '消毒');
|
|
|
|
$this->assertSuccess($result);
|
|
$voice = $result->getFullVoice();
|
|
$this->assertNotEmpty($voice, '应有语音输出');
|
|
}
|
|
|
|
/**
|
|
* 测试人员卡刷卡语音
|
|
*/
|
|
public function testOperatorCardVoice(): void
|
|
{
|
|
$result = $this->processor->swipeOperatorCard('操作员1', '清洗');
|
|
|
|
// 人员卡应提示"请刷内镜卡"
|
|
$this->assertVoiceContains($result, '请刷内镜卡');
|
|
}
|
|
|
|
/**
|
|
* 测试错误情况语音
|
|
*/
|
|
public function testErrorVoice(): void
|
|
{
|
|
// 未刷人员卡
|
|
$result = $this->processor->swipeEndoscopeCard('胃镜1', '清洗');
|
|
|
|
$voice = $result->getFullVoice();
|
|
$this->assertNotEmpty($voice, '错误情况应有语音提示');
|
|
}
|
|
|
|
/**
|
|
* 测试清洗时长不足时的语音模板参数替换
|
|
*
|
|
* 语音应包含具体的时长不足提示
|
|
*/
|
|
public function testWashDurationInsufficientVoice(): void
|
|
{
|
|
// 创建清洗时长不足的场景(只有5秒)
|
|
$context = $this->processor->createContextBuilder()
|
|
->endoscope('胃镜1')
|
|
->reader('漂洗')
|
|
->operator('操作员1')
|
|
->currentStep('清洗')
|
|
->setDuration(5) // 只有5秒,时间不足
|
|
->batchNo(date('Ymd') . '010001')
|
|
->build();
|
|
|
|
$engine = ProcessEngine::createStandard();
|
|
$result = $engine->execute($context);
|
|
|
|
// 语音应该包含时长不足相关提示
|
|
$voice = $result->getFullVoice();
|
|
$this->assertNotEmpty($voice, '时长不足应有语音提示');
|
|
}
|
|
}
|