diff --git a/module/bug/test/lib/bug.unittest.class.php b/module/bug/test/lib/bug.unittest.class.php index 7af6cdfb70..0ecd2048b6 100644 --- a/module/bug/test/lib/bug.unittest.class.php +++ b/module/bug/test/lib/bug.unittest.class.php @@ -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; + } + } diff --git a/module/bug/test/zen/seteditmenu.php b/module/bug/test/zen/seteditmenu.php new file mode 100755 index 0000000000..75586adfa6 --- /dev/null +++ b/module/bug/test/zen/seteditmenu.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +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情况 \ No newline at end of file