6c874221ad
- 将 FLOW_USE_CUSTOM_PROCESS 从 true 改为 false,禁用自定义流程 - 在 BlockTest 测试用例中改用 setBlockMode 方法设置阻断模式 - 设置统一的错误处理,将错误转为异常抛出 - 重命名 BlockTest 测试文件路径,优化测试组织结构 - 更新 IDE php include paths,调整依赖包引用顺序 - 删除无用的 tests/flow/Test.php 测试文件 - 微调 start.php、webman、windows.php 配置或代码模块
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, '时长不足应有语音提示');
|
|
}
|
|
}
|