6c874221ad
- 将 FLOW_USE_CUSTOM_PROCESS 从 true 改为 false,禁用自定义流程 - 在 BlockTest 测试用例中改用 setBlockMode 方法设置阻断模式 - 设置统一的错误处理,将错误转为异常抛出 - 重命名 BlockTest 测试文件路径,优化测试组织结构 - 更新 IDE php include paths,调整依赖包引用顺序 - 删除无用的 tests/flow/Test.php 测试文件 - 微调 start.php、webman、windows.php 配置或代码模块
80 lines
2.1 KiB
PHP
80 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace tests\flow\cases;
|
|
|
|
use tests\flow\TestCase;
|
|
use tests\flow\VirtualContextBuilder;
|
|
use tests\flow\VirtualityFlowProcessor;
|
|
|
|
/**
|
|
* 辅助工具测试
|
|
*
|
|
* 测试 VirtualityFlowProcessor 和 VirtualContextBuilder 等测试工具
|
|
*/
|
|
class HelperTest extends TestCase
|
|
{
|
|
private VirtualityFlowProcessor $processor;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->processor = VirtualityFlowProcessor::createStandard();
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
parent::tearDown();
|
|
$this->processor->reset();
|
|
}
|
|
|
|
/**
|
|
* 测试 VirtualityFlowProcessor 状态重置
|
|
*/
|
|
public function testProcessorReset(): void
|
|
{
|
|
// 执行一些操作
|
|
$this->processor->swipe('操作员1', '胃镜1', '清洗');
|
|
|
|
// 重置
|
|
$this->processor->reset();
|
|
|
|
// 重置后应该是新流程
|
|
$history = $this->processor->getHistory();
|
|
$this->assertEmpty($history, '重置后历史应为空');
|
|
}
|
|
|
|
/**
|
|
* 测试 VirtualContextBuilder 功能
|
|
*/
|
|
public function testVirtualContextBuilder(): void
|
|
{
|
|
$builder = VirtualContextBuilder::create();
|
|
|
|
$context = $builder
|
|
->endoscope('胃镜1')
|
|
->reader('清洗')
|
|
->operator('操作员1')
|
|
->currentStep('清洗')
|
|
->batchNo('20260310010001')
|
|
->build();
|
|
|
|
$this->assertEquals('清洗', $context->getCurrentStep());
|
|
$this->assertEquals('20260310010001', $context->getBatchNo());
|
|
$this->assertEquals('张三', $context->getOperator()->name);
|
|
$this->assertEquals('胃镜1号', $context->getEndoscope()->name);
|
|
}
|
|
|
|
/**
|
|
* 测试环境配置加载
|
|
*/
|
|
public function testEnvironmentConfig(): void
|
|
{
|
|
$env = $this->processor->getEnvironment();
|
|
|
|
$this->assertArrayHasKey('readers', $env);
|
|
$this->assertArrayHasKey('endoscopes', $env);
|
|
$this->assertArrayHasKey('operators', $env);
|
|
$this->assertArrayHasKey('config', $env);
|
|
}
|
|
}
|