From a3828149aa6566ced48b7f39c7ce3149b8ecdf21 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Wed, 16 Aug 2023 17:25:18 +0800 Subject: [PATCH] * Add comment for bugModel::isClickable, and modify its unit test. --- module/bug/model.php | 17 +++++- module/bug/test/bug.class.php | 15 ++---- module/bug/test/model/isclickable.php | 74 ++++++++++++++++++--------- 3 files changed, 69 insertions(+), 37 deletions(-) diff --git a/module/bug/model.php b/module/bug/model.php index 3331c052cf..8c57c778b6 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1732,23 +1732,36 @@ class bugModel extends model } /** + * 判断当前动作是否可以点击。 * Adjust the action is clickable. * * @param string $bug * @param string $action * @param string $module * @access public - * @return void + * @return bool */ - public static function isClickable($object, $action, $module = 'bug') + public static function isClickable(object $object, string $action, string $module = 'bug'): bool { $action = strtolower($action); + /* 如果bug状态是激活,没有确认过,这个bug可以被确认。 */ + /* If the status is active, and the confirmed is 0, the bug can be confirm. */ if($module == 'bug' && $action == 'confirm') return $object->status == 'active' && $object->confirmed == 0; + /* 如果bug不是关闭状态,这个bug可以被指派。 */ + /* If the status isn't closed, the bug can be assginTo. */ if($module == 'bug' && $action == 'assignTo') return $object->status != 'closed'; + /* 如果bug是激活状态,这个bug可以被解决。 */ + /* If the status is active, the bug can be resolve. */ if($module == 'bug' && $action == 'resolve') return $object->status == 'active'; + /* 如果bug是解决状态,这个bug可以被关闭。 */ + /* If the status is resolved, the bug can be close. */ if($module == 'bug' && $action == 'close') return $object->status == 'resolved'; + /* 如果bug不是激活状态,这个bug可以被激活。 */ + /* If the status isn't active, the bug can be activate. */ if($module == 'bug' && $action == 'activate') return $object->status != 'active'; + /* 如果bug是激活状态,这个bug可以被转为需求。 */ + /* If the status is active, the bug can be toStory. */ if($module == 'bug' && $action == 'tostory') return $object->status == 'active'; return true; diff --git a/module/bug/test/bug.class.php b/module/bug/test/bug.class.php index b91e7fbadd..eef45146c5 100644 --- a/module/bug/test/bug.class.php +++ b/module/bug/test/bug.class.php @@ -1126,6 +1126,7 @@ class bugTest } /** + * 测试判断当前动作是否可以点击。 * Test adjust the action is clickable. * * @param object $bug @@ -1133,18 +1134,10 @@ class bugTest * @access public * @return int */ - public function isClickableTest($bug, $action) + public function isClickableTest(object $bug, string $action): int { - $object = $this->objectModel->isClickable($bug, $action); - - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object ? 1 : 2; - } + $bool = $this->objectModel->isClickable($bug, $action); + return $bool ? 1 : 2; } /** diff --git a/module/bug/test/model/isclickable.php b/module/bug/test/model/isclickable.php index d93ec14641..c60262e60c 100755 --- a/module/bug/test/model/isclickable.php +++ b/module/bug/test/model/isclickable.php @@ -2,6 +2,9 @@ gen(10); + su('admin'); /** @@ -10,30 +13,53 @@ title=bugModel->isClickable(); cid=1 pid=1 -状态为active confirmed为0的bug能否执行confirm动作 >> 1 -状态为active confirmed为0的bug能否执行resolve动作 >> 1 -状态为active confirmed为0的bug能否执行close动作 >> 2 -状态为active confirmed为0的bug能否执行activate动作 >> 2 -状态为active confirmed为0的bug能否执行tostory动作 >> 1 -状态为active confirmed为0的bug能否执行test动作 >> 1 -状态为active confirmed为1的bug能否执行confirm动作 >> 2 -状态为active confirmed为1的bug能否执行resolve动作 >> 1 -状态为active confirmed为1的bug能否执行close动作 >> 2 -状态为active confirmed为1的bug能否执行activate动作 >> 2 -状态为active confirmed为1的bug能否执行tostory动作 >> 1 -状态为active confirmed为1的bug能否执行test动作 >> 1 -状态为resolved的bug能否执行confirm动作 >> 2 -状态为resolved的bug能否执行resolve动作 >> 2 -状态为resolved的bug能否执行close动作 >> 1 -状态为resolved的bug能否执行activate动作 >> 1 -状态为resolved的bug能否执行tostory动作 >> 2 -状态为resolved的bug能否执行test动作 >> 1 -状态为closed的bug能否执行confirm动作 >> 2 -状态为closed的bug能否执行resolve动作 >> 2 -状态为closed的bug能否执行close动作 >> 2 -状态为closed的bug能否执行activate动作 >> 1 -状态为closed的bug能否执行tostory动作 >> 2 -状态为closed的bug能否执行test动作 >> 1 +- 状态为active confirmed为0的bug能否执行confirm动作 @1 + +- 状态为active confirmed为0的bug能否执行resolve动作 @1 + +- 状态为active confirmed为0的bug能否执行close动作 @2 + +- 状态为active confirmed为0的bug能否执行activate动作 @2 + +- 状态为active confirmed为0的bug能否执行tostory动作 @1 + +- 状态为active confirmed为0的bug能否执行test动作 @1 + +- 状态为active confirmed为1的bug能否执行confirm动作 @2 + +- 状态为active confirmed为1的bug能否执行resolve动作 @1 + +- 状态为active confirmed为1的bug能否执行close动作 @2 + +- 状态为active confirmed为1的bug能否执行activate动作 @2 + +- 状态为active confirmed为1的bug能否执行tostory动作 @1 + +- 状态为active confirmed为1的bug能否执行test动作 @1 + +- 状态为resolved的bug能否执行confirm动作 @2 + +- 状态为resolved的bug能否执行resolve动作 @2 + +- 状态为resolved的bug能否执行close动作 @1 + +- 状态为resolved的bug能否执行activate动作 @1 + +- 状态为resolved的bug能否执行tostory动作 @2 + +- 状态为resolved的bug能否执行test动作 @1 + +- 状态为closed的bug能否执行confirm动作 @2 + +- 状态为closed的bug能否执行resolve动作 @2 + +- 状态为closed的bug能否执行close动作 @2 + +- 状态为closed的bug能否执行activate动作 @1 + +- 状态为closed的bug能否执行tostory动作 @2 + +- 状态为closed的bug能否执行test动作 @1 */