6c874221ad
- 将 FLOW_USE_CUSTOM_PROCESS 从 true 改为 false,禁用自定义流程 - 在 BlockTest 测试用例中改用 setBlockMode 方法设置阻断模式 - 设置统一的错误处理,将错误转为异常抛出 - 重命名 BlockTest 测试文件路径,优化测试组织结构 - 更新 IDE php include paths,调整依赖包引用顺序 - 删除无用的 tests/flow/Test.php 测试文件 - 微调 start.php、webman、windows.php 配置或代码模块
119 lines
3.2 KiB
PHP
119 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace tests\flow\cases;
|
|
|
|
use app\flow\ProcessEngine;
|
|
use tests\flow\TestCase;
|
|
use tests\flow\VirtualityFlowProcessor;
|
|
|
|
/**
|
|
* 错误刷卡流程测试
|
|
*
|
|
* 覆盖场景:
|
|
* 5. 错误刷卡流程
|
|
*/
|
|
class ErrorFlowTest extends TestCase
|
|
{
|
|
private VirtualityFlowProcessor $processor;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->processor = VirtualityFlowProcessor::createStandard();
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
parent::tearDown();
|
|
$this->processor->reset();
|
|
}
|
|
|
|
// ==================== 5. 错误刷卡流程 ====================
|
|
|
|
/**
|
|
* 测试未刷人员卡直接刷内镜卡
|
|
*/
|
|
public function testSwipeEndoscopeWithoutOperator(): void
|
|
{
|
|
// 不刷人员卡,直接刷内镜卡
|
|
$result = $this->processor->swipeEndoscopeCard('胃镜1', '清洗');
|
|
|
|
$this->assertFailure($result, '未刷人员卡应失败');
|
|
$this->assertVoiceContains($result, '请刷人员卡');
|
|
}
|
|
|
|
/**
|
|
* 测试刷卡顺序错误 - 跳过清洗直接漂洗
|
|
*/
|
|
public function testWrongStepOrder(): void
|
|
{
|
|
$operator = '操作员1';
|
|
$endoscope = '胃镜1';
|
|
|
|
// 新流程,直接刷漂洗
|
|
$result = $this->processor->swipe($operator, $endoscope, '漂洗');
|
|
|
|
// 应该提示步骤顺序错误
|
|
// 注意:具体行为取决于流程引擎的实现
|
|
$this->assertNotNull($result);
|
|
}
|
|
|
|
/**
|
|
* 测试重复刷同一步骤的卡
|
|
*/
|
|
public function testDuplicateSwipe(): void
|
|
{
|
|
$operator = '操作员1';
|
|
$endoscope = '胃镜1';
|
|
|
|
// 第一次刷清洗
|
|
$result1 = $this->processor->swipe($operator, $endoscope, '清洗');
|
|
$this->assertSuccess($result1);
|
|
|
|
// 第二次刷清洗(重复刷卡)
|
|
$result2 = $this->processor->swipe($operator, $endoscope, '清洗');
|
|
|
|
// 应该被重复刷卡节点拦截
|
|
$this->assertNotNull($result2);
|
|
}
|
|
|
|
/**
|
|
* 测试读卡器未绑定
|
|
*/
|
|
public function testUnboundReader(): void
|
|
{
|
|
$context = $this->processor->createContextBuilder()
|
|
->endoscope('胃镜1')
|
|
->customReader('R999', '', '') // 未绑定的读卡器
|
|
->operator('操作员1')
|
|
->newProcess()
|
|
->build();
|
|
|
|
$engine = ProcessEngine::createStandard();
|
|
$result = $engine->execute($context);
|
|
|
|
// 读卡器未绑定应该在 FlowProcessor 层处理
|
|
// 这里主要测试 ProcessEngine 的行为
|
|
$this->assertNotNull($result);
|
|
}
|
|
|
|
/**
|
|
* 测试内镜卡未绑定
|
|
*/
|
|
public function testUnboundEndoscope(): void
|
|
{
|
|
$context = $this->processor->createContextBuilder()
|
|
->endoscope('未绑定卡')
|
|
->reader('清洗')
|
|
->operator('操作员1')
|
|
->newProcess()
|
|
->build();
|
|
|
|
$engine = ProcessEngine::createStandard();
|
|
$result = $engine->execute($context);
|
|
|
|
// 内镜未绑定应该触发错误
|
|
$this->assertNotNull($result);
|
|
}
|
|
}
|