From c78a782027bbdb9ef22bd5556e331c9e438d9c6c Mon Sep 17 00:00:00 2001 From: liugang Date: Mon, 8 Sep 2025 10:16:17 +0800 Subject: [PATCH] + [misc] Add unit tests for epicModel::isClickable() 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/epic/test/lib/epic.unittest.class.php | 35 ++++++++++++++++ module/epic/test/model/isclickable.php | 42 ++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 module/epic/test/lib/epic.unittest.class.php create mode 100755 module/epic/test/model/isclickable.php diff --git a/module/epic/test/lib/epic.unittest.class.php b/module/epic/test/lib/epic.unittest.class.php new file mode 100644 index 0000000000..28f5cca9a8 --- /dev/null +++ b/module/epic/test/lib/epic.unittest.class.php @@ -0,0 +1,35 @@ +objectModel = $tester->loadModel('epic'); + $this->objectTao = $tester->loadTao('epic'); + } + + /** + * Test isClickable method. + * + * @param object $data + * @param string $action + * @access public + * @return mixed + */ + public function isClickableTest($data = null, $action = '') + { + global $app, $tester; + + // 确保$app->control存在并能加载story模型 + if(!isset($app->control)) + { + $app->control = $tester; + } + + $result = $this->objectModel->isClickable($data, $action); + if(dao::isError()) return dao::getError(); + + return $result; + } +} \ No newline at end of file diff --git a/module/epic/test/model/isclickable.php b/module/epic/test/model/isclickable.php new file mode 100755 index 0000000000..0edd674a68 --- /dev/null +++ b/module/epic/test/model/isclickable.php @@ -0,0 +1,42 @@ +#!/usr/bin/env php +id->range('1-10'); +$table->title->range('Epic1,Epic2,Epic3,Epic4,Epic5,Epic6,Epic7,Epic8,Epic9,Epic10'); +$table->type->range('epic'); +$table->status->range('active{3},closed{2},reviewing{2},changing{1},draft{2}'); +$table->assignedTo->range('admin,user1,user2'); +$table->gen(10); + +// 3. 用户登录(选择合适角色) +su('admin'); + +// 4. 创建测试实例(变量名与模块名一致) +$epicTest = new epicTest(); + +// 5. 🔴 强制要求:必须包含至少5个测试步骤 +r($epicTest->isClickableTest((object)array('status' => 'active', 'type' => 'epic'), 'close')) && p() && e('1'); // 步骤1:正常story状态下close动作 +r($epicTest->isClickableTest((object)array('status' => 'closed', 'type' => 'epic'), 'close')) && p() && e('0'); // 步骤2:closed状态下close动作 +r($epicTest->isClickableTest((object)array('status' => 'closed', 'type' => 'epic'), 'activate')) && p() && e('1'); // 步骤3:closed状态下activate动作 +r($epicTest->isClickableTest((object)array('status' => 'active', 'type' => 'epic'), 'activate')) && p() && e('0'); // 步骤4:active状态下activate动作 +r($epicTest->isClickableTest((object)array('status' => 'reviewing', 'type' => 'epic'), 'recall')) && p() && e('1'); // 步骤5:reviewing状态下recall动作 \ No newline at end of file