3471deb3f1
- 修改 AbstractProcessNode 中 ProcessContext 的命名空间引用为 app\flow\context\ProcessContext - 引入 app\flow\vo\CanHandleResult 用于节点处理结果表示 - 更新前置策略执行后对成功状态的判断,改为调用 isSuccess() 方法 - 增加日志记录细节,便于调试策略执行中断时的错误信息 - 优化代码注释,提升代码可读性和维护性
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('清洗')
|
|
->duration(5) // 只有5秒,时间不足
|
|
->batchNo(date('Ymd') . '010001')
|
|
->build();
|
|
|
|
$engine = ProcessEngine::createStandard();
|
|
$result = $engine->execute($context);
|
|
|
|
// 语音应该包含时长不足相关提示
|
|
$voice = $result->getFullVoice();
|
|
$this->assertNotEmpty($voice, '时长不足应有语音提示');
|
|
}
|
|
}
|