+ [misc] Add unit tests for bugZen::setEditMenu() 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:09:49 +08:00
co-authored by Claude
parent e0a1f48467
commit 2b56df8218
2 changed files with 70 additions and 0 deletions
@@ -1958,4 +1958,35 @@ class bugTest
return $result;
}
/**
* Test setEditMenu method.
*
* @param int $bugID
* @param string $tab
* @access public
* @return int
*/
public function setEditMenuTest(int $bugID, string $tab): int
{
global $tester, $app;
// 获取bug对象
$bug = $this->objectModel->getById($bugID);
if(!$bug) return 0;
// 设置app tab
$app->tab = $tab;
$zen = initReference('bug');
$method = $zen->getMethod('setEditMenu');
$zenInstance = $zen->newInstance();
$result = $method->invokeArgs($zenInstance, array($bug));
if(dao::isError()) return 0;
return $result ? 1 : 0;
}
}
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env php
<?php
/**
title=测试 bugZen::setEditMenu();
timeout=0
cid=0
- 步骤1:project tab情况 @1
- 步骤2:execution tab情况 @1
- 步骤3:qa tab情况 @1
- 步骤4:devops tab情况 @1
- 步骤5:无效tab情况 @1
*/
// 1. 导入依赖(路径固定,不可修改)
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/bug.unittest.class.php';
// 2. zendata数据准备(根据需要配置)
zendata('bug')->loadYaml('bug_seteditmenu', false, 2)->gen(10);
zendata('product')->loadYaml('product_seteditmenu', false, 2)->gen(3);
zendata('project')->loadYaml('project_seteditmenu', false, 2)->gen(15);
zendata('repo')->loadYaml('repo_seteditmenu', false, 2)->gen(3);
// 3. 用户登录(选择合适角色)
su('admin');
// 4. 创建测试实例(变量名与模块名一致)
$bugTest = new bugTest();
// 5. 🔴 强制要求:必须包含至少5个测试步骤
r($bugTest->setEditMenuTest(1, 'project')) && p() && e('1'); // 步骤1:project tab情况
r($bugTest->setEditMenuTest(2, 'execution')) && p() && e('1'); // 步骤2:execution tab情况
r($bugTest->setEditMenuTest(3, 'qa')) && p() && e('1'); // 步骤3:qa tab情况
r($bugTest->setEditMenuTest(1, 'devops')) && p() && e('1'); // 步骤4:devops tab情况
r($bugTest->setEditMenuTest(2, 'invalid')) && p() && e('1'); // 步骤5:无效tab情况