From e55de884367df0cde502b2675d1ce50135dafff7 Mon Sep 17 00:00:00 2001 From: liugang Date: Sat, 13 Sep 2025 21:17:48 +0800 Subject: [PATCH] + [misc] Add unit tests for bugZen::processRepoIssueActions() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- module/bug/test/lib/bug.unittest.class.php | 30 +++++++++++++++ .../bug/test/zen/processrepoissueactions.php | 38 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100755 module/bug/test/zen/processrepoissueactions.php diff --git a/module/bug/test/lib/bug.unittest.class.php b/module/bug/test/lib/bug.unittest.class.php index ce5bba64de..f8dcd0e8b4 100644 --- a/module/bug/test/lib/bug.unittest.class.php +++ b/module/bug/test/lib/bug.unittest.class.php @@ -4423,4 +4423,34 @@ class bugTest return $chartOption; } + + /** + * Test processRepoIssueActions method. + * + * @param int $repoID + * @access public + * @return mixed + */ + public function processRepoIssueActionsTest($repoID = null) + { + try { + // 使用反射调用受保护的方法 + $zenClass = initReference('bug'); + $method = $zenClass->getMethod('processRepoIssueActions'); + $zenInstance = $zenClass->newInstance(); + + $result = $method->invokeArgs($zenInstance, array($repoID)); + + if(dao::isError()) return dao::getError(); + + // 返回相关配置以供断言 + return array( + 'repoID' => $zenInstance->view->repoID ?? null, + 'mainActions' => $zenInstance->config->bug->actions->view['mainActions'] ?? null, + 'suffixActions' => $zenInstance->config->bug->actions->view['suffixActions'] ?? null + ); + } catch (Exception $e) { + return array('error' => $e->getMessage()); + } + } } diff --git a/module/bug/test/zen/processrepoissueactions.php b/module/bug/test/zen/processrepoissueactions.php new file mode 100755 index 0000000000..60637f2f44 --- /dev/null +++ b/module/bug/test/zen/processrepoissueactions.php @@ -0,0 +1,38 @@ +#!/usr/bin/env php +processRepoIssueActionsTest(1)) && p('repoID') && e('1'); // 步骤1:正常仓库ID +r($bugTest->processRepoIssueActionsTest(0)) && p('repoID') && e('0'); // 步骤2:边界值0 +r($bugTest->processRepoIssueActionsTest(-1)) && p('repoID') && e('-1'); // 步骤3:负数ID +r($bugTest->processRepoIssueActionsTest(100)) && p('mainActions:0,1,2,3,4') && e('confirm,assignTo,resolve,close,activate'); // 步骤4:验证主要操作 +r($bugTest->processRepoIssueActionsTest(200)) && p('suffixActions:0') && e('delete'); // 步骤5:验证后缀操作 \ No newline at end of file