From 4b6487269d3bce17bd28b96754dc358e321a2139 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 30 Aug 2023 13:57:35 +0800 Subject: [PATCH] * Refactor isClickable method. --- module/execution/model.php | 14 ++--- module/execution/test/execution.class.php | 9 +-- module/execution/test/model/isclickable.php | 69 +++++++-------------- 3 files changed, 34 insertions(+), 58 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index 6c4e32a922..951069f966 100755 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -4336,6 +4336,7 @@ class executionModel extends model } /** + * 判断操作按钮是否可以点击。 * Judge an action is clickable or not. * * @param object $execution @@ -4343,17 +4344,16 @@ class executionModel extends model * @access public * @return bool */ - public static function isClickable($execution, $action) + public static function isClickable(object $execution, string $action): bool { - $action = strtolower($action); - $clickable = commonModel::hasPriv('execution', $action); - if(!$clickable) return false; + if(!commonModel::hasPriv('execution', $action)) return false; + $action = strtolower($action); if($action == 'start') return $execution->status == 'wait'; if($action == 'close') return $execution->status != 'closed'; - if($action == 'suspend') return $execution->status == 'wait' or $execution->status == 'doing'; - if($action == 'putoff') return $execution->status == 'wait' or $execution->status == 'doing'; - if($action == 'activate') return $execution->status == 'suspended' or $execution->status == 'closed'; + if($action == 'suspend') return $execution->status == 'wait' || $execution->status == 'doing'; + if($action == 'putoff') return $execution->status == 'wait' || $execution->status == 'doing'; + if($action == 'activate') return $execution->status == 'suspended' || $execution->status == 'closed'; return true; } diff --git a/module/execution/test/execution.class.php b/module/execution/test/execution.class.php index 165414e1bb..112b3a8b3f 100644 --- a/module/execution/test/execution.class.php +++ b/module/execution/test/execution.class.php @@ -2027,14 +2027,15 @@ class executionTest } /** - * function isClickable test by execution + * 判断操作按钮是否可以点击。 + * Judge an action is clickable or not. * - * @param string $execution + * @param object $execution * @param string $action * @access public - * @return array + * @return string */ - public function isClickableTest($execution, $action) + public function isClickableTest(object $execution, string $action): string { $object = $this->executionModel->isClickable($execution, $action); diff --git a/module/execution/test/model/isclickable.php b/module/execution/test/model/isclickable.php index b7882a6013..4815fd5b30 100755 --- a/module/execution/test/model/isclickable.php +++ b/module/execution/test/model/isclickable.php @@ -7,33 +7,8 @@ su('admin'); /** title=测试executionModel->isClickableTest(); +timeout=0 cid=1 -pid=1 - -wait状态执行start按钮检查 >> 检查通过 -wait状态执行close按钮检查 >> 检查通过 -wait状态执行suspend按钮检查 >> 检查通过 -wait状态执行putoff按钮检查 >> 检查通过 -wait状态执行activate按钮检查 >> 检查不通过 -wait状态执行delete按钮检查 >> 检查通过 -doing状态执行start按钮检查 >> 检查不通过 -doing状态执行close按钮检查 >> 检查通过 -doing状态执行suspend按钮检查 >> 检查通过 -doing状态执行putoff按钮检查 >> 检查通过 -doing状态执行activate按钮检查 >> 检查不通过 -doing状态执行delete按钮检查 >> 检查通过 -suspended状态执行start按钮检查 >> 检查不通过 -suspended状态执行close按钮检查 >> 检查通过 -suspended状态执行suspend按钮检查 >> 检查不通过 -suspended状态执行putoff按钮检查 >> 检查不通过 -suspended状态执行activate按钮检查 >> 检查通过 -suspended状态执行delete按钮检查 >> 检查通过 -closed状态执行start按钮检查 >> 检查不通过 -closed状态执行close按钮检查 >> 检查不通过 -closed状态执行suspend按钮检查 >> 检查不通过 -closed状态执行putoff按钮检查 >> 检查不通过 -closed状态执行activate按钮检查 >> 检查通过 -closed状态执行delete按钮检查 >> 检查通过 */ @@ -42,35 +17,35 @@ $doingExecution = new stdclass(); $suspendedExecution = new stdclass(); $closedExecution = new stdclass(); -$waitExecution->status = 'wait'; -$doingExecution->status = 'doing'; +$waitExecution->status = 'wait'; +$doingExecution->status = 'doing'; $suspendedExecution->status = 'suspended'; -$closedExecution->status = 'closed'; +$closedExecution->status = 'closed'; $actionList = array('start', 'close', 'suspend', 'putoff', 'activate', 'delete'); $execution = new executionTest(); -r($execution->isClickableTest($waitExecution, $actionList[0])) && p() && e('检查通过'); // wait状态执行start按钮检查 -r($execution->isClickableTest($waitExecution, $actionList[1])) && p() && e('检查通过'); // wait状态执行close按钮检查 -r($execution->isClickableTest($waitExecution, $actionList[2])) && p() && e('检查通过'); // wait状态执行suspend按钮检查 -r($execution->isClickableTest($waitExecution, $actionList[3])) && p() && e('检查通过'); // wait状态执行putoff按钮检查 -r($execution->isClickableTest($waitExecution, $actionList[4])) && p() && e('检查不通过'); // wait状态执行activate按钮检查 -r($execution->isClickableTest($waitExecution, $actionList[5])) && p() && e('检查通过'); // wait状态执行delete按钮检查 -r($execution->isClickableTest($doingExecution, $actionList[0])) && p() && e('检查不通过'); // doing状态执行start按钮检查 -r($execution->isClickableTest($doingExecution, $actionList[1])) && p() && e('检查通过'); // doing状态执行close按钮检查 -r($execution->isClickableTest($doingExecution, $actionList[2])) && p() && e('检查通过'); // doing状态执行suspend按钮检查 -r($execution->isClickableTest($doingExecution, $actionList[3])) && p() && e('检查通过'); // doing状态执行putoff按钮检查 -r($execution->isClickableTest($doingExecution, $actionList[4])) && p() && e('检查不通过'); // doing状态执行activate按钮检查 -r($execution->isClickableTest($doingExecution, $actionList[5])) && p() && e('检查通过'); // doing状态执行delete按钮检查 +r($execution->isClickableTest($waitExecution, $actionList[0])) && p() && e('检查通过'); // wait状态执行start按钮检查 +r($execution->isClickableTest($waitExecution, $actionList[1])) && p() && e('检查通过'); // wait状态执行close按钮检查 +r($execution->isClickableTest($waitExecution, $actionList[2])) && p() && e('检查通过'); // wait状态执行suspend按钮检查 +r($execution->isClickableTest($waitExecution, $actionList[3])) && p() && e('检查通过'); // wait状态执行putoff按钮检查 +r($execution->isClickableTest($waitExecution, $actionList[4])) && p() && e('检查不通过'); // wait状态执行activate按钮检查 +r($execution->isClickableTest($waitExecution, $actionList[5])) && p() && e('检查通过'); // wait状态执行delete按钮检查 +r($execution->isClickableTest($doingExecution, $actionList[0])) && p() && e('检查不通过'); // doing状态执行start按钮检查 +r($execution->isClickableTest($doingExecution, $actionList[1])) && p() && e('检查通过'); // doing状态执行close按钮检查 +r($execution->isClickableTest($doingExecution, $actionList[2])) && p() && e('检查通过'); // doing状态执行suspend按钮检查 +r($execution->isClickableTest($doingExecution, $actionList[3])) && p() && e('检查通过'); // doing状态执行putoff按钮检查 +r($execution->isClickableTest($doingExecution, $actionList[4])) && p() && e('检查不通过'); // doing状态执行activate按钮检查 +r($execution->isClickableTest($doingExecution, $actionList[5])) && p() && e('检查通过'); // doing状态执行delete按钮检查 r($execution->isClickableTest($suspendedExecution, $actionList[0])) && p() && e('检查不通过'); // suspended状态执行start按钮检查 r($execution->isClickableTest($suspendedExecution, $actionList[1])) && p() && e('检查通过'); // suspended状态执行close按钮检查 r($execution->isClickableTest($suspendedExecution, $actionList[2])) && p() && e('检查不通过'); // suspended状态执行suspend按钮检查 r($execution->isClickableTest($suspendedExecution, $actionList[3])) && p() && e('检查不通过'); // suspended状态执行putoff按钮检查 r($execution->isClickableTest($suspendedExecution, $actionList[4])) && p() && e('检查通过'); // suspended状态执行activate按钮检查 r($execution->isClickableTest($suspendedExecution, $actionList[5])) && p() && e('检查通过'); // suspended状态执行delete按钮检查 -r($execution->isClickableTest($closedExecution, $actionList[0])) && p() && e('检查不通过'); // closed状态执行start按钮检查 -r($execution->isClickableTest($closedExecution, $actionList[1])) && p() && e('检查不通过'); // closed状态执行close按钮检查 -r($execution->isClickableTest($closedExecution, $actionList[2])) && p() && e('检查不通过'); // closed状态执行suspend按钮检查 -r($execution->isClickableTest($closedExecution, $actionList[3])) && p() && e('检查通过'); // closed状态执行putoff按钮检查 -r($execution->isClickableTest($closedExecution, $actionList[4])) && p() && e('检查通过'); // closed状态执行activate按钮检查 -r($execution->isClickableTest($closedExecution, $actionList[5])) && p() && e('检查不通过'); // closed状态执行delete按钮检查 +r($execution->isClickableTest($closedExecution, $actionList[0])) && p() && e('检查不通过'); // closed状态执行start按钮检查 +r($execution->isClickableTest($closedExecution, $actionList[1])) && p() && e('检查不通过'); // closed状态执行close按钮检查 +r($execution->isClickableTest($closedExecution, $actionList[2])) && p() && e('检查不通过'); // closed状态执行suspend按钮检查 +r($execution->isClickableTest($closedExecution, $actionList[3])) && p() && e('检查不通过'); // closed状态执行putoff按钮检查 +r($execution->isClickableTest($closedExecution, $actionList[4])) && p() && e('检查通过'); // closed状态执行activate按钮检查 +r($execution->isClickableTest($closedExecution, $actionList[5])) && p() && e('检查通过'); // closed状态执行delete按钮检查