+ [misc] Add unit tests for tutorialModel::getBranchPairs() method

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-09-15 15:06:27 +08:00
co-authored by Claude
parent b63f783ea2
commit 591e5d648c
2 changed files with 48 additions and 0 deletions
@@ -1034,4 +1034,19 @@ class tutorialTest
return $result;
}
/**
* 测试获取新手模式分支键值对。
* Test get branch pairs.
*
* @access public
* @return array
*/
public function getBranchPairsTest(): array
{
$result = $this->objectModel->getBranchPairs();
if(dao::isError()) return dao::getError();
return $result;
}
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env php
<?php
/**
title=测试 tutorialModel::getBranchPairs();
timeout=0
cid=0
- 步骤1:验证主分支名称(ID=0) @主干
- 步骤2:验证测试分支名称(ID=1)属性1 @Test branch
- 步骤3:验证返回数组长度 @2
- 步骤4:验证第一个键为0 @0
- 步骤5:验证返回类型为数组 @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/tutorial.unittest.class.php';
// 2. zendata数据准备(根据需要配置)
su('admin');
// 3. 创建测试实例(变量名与模块名一致)
$tutorialTest = new tutorialTest();
// 4. 强制要求:必须包含至少5个测试步骤
r($tutorialTest->getBranchPairsTest()) && p('0') && e('主干'); // 步骤1:验证主分支名称(ID=0)
r($tutorialTest->getBranchPairsTest()) && p('1') && e('Test branch'); // 步骤2:验证测试分支名称(ID=1)
r(count($tutorialTest->getBranchPairsTest())) && p() && e('2'); // 步骤3:验证返回数组长度
r(array_keys($tutorialTest->getBranchPairsTest())) && p('0') && e('0'); // 步骤4:验证第一个键为0
r(is_array($tutorialTest->getBranchPairsTest())) && p() && e('1'); // 步骤5:验证返回类型为数组