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); } }