From f3a3974530c016bd73cd5b890abff68955bcde25 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Sat, 25 Nov 2023 09:33:49 +0800 Subject: [PATCH] * Add unit test. --- module/common/model.php | 2 +- .../common/test/model/syncexecutionstatus.php | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100755 module/common/test/model/syncexecutionstatus.php diff --git a/module/common/model.php b/module/common/model.php index b3abe9adcb..e8f36a7a94 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -137,7 +137,7 @@ class commonModel extends model * @access public * @return object|false $parentExecution */ - public function syncExecutionByChild(object $execution) + public function syncExecutionByChild(object $execution): object|false { if($execution->grade == 1) return false; diff --git a/module/common/test/model/syncexecutionstatus.php b/module/common/test/model/syncexecutionstatus.php new file mode 100755 index 0000000000..33775a26bf --- /dev/null +++ b/module/common/test/model/syncexecutionstatus.php @@ -0,0 +1,47 @@ +#!/usr/bin/env php +gen(100); +zdTable('project')->config('execution')->gen(200, false); +zdTable('task')->gen(100); + +/** + +title=测试 commonModel->syncExecutionStatus(); +timeout=0 +cid=1 + +- 执行$execution1属性status @wait +- 执行$execution2属性status @doing +- 执行$execution3属性status @wait +- 任务开始将执行的状态设为doing属性status @doing +- 任务开始将执行的状态设为doing属性status @doing +- 任务开始将执行的状态设为doing属性status @doing + +*/ + +global $tester; +$tester->loadModel('execution'); +$tester->loadModel('common'); + +$execution1 = $tester->execution->getById(101); +$execution2 = $tester->execution->getById(102); +$execution3 = $tester->execution->getById(103); + +r($execution1) && p('status') && e('wait'); +r($execution2) && p('status') && e('doing'); +r($execution3) && p('status') && e('wait'); + +$tester->common->syncExecutionStatus(1); +$tester->common->syncExecutionStatus(2); +$tester->common->syncExecutionStatus(3); + +$execution1 = $tester->execution->getById(101); +$execution2 = $tester->execution->getById(102); +$execution3 = $tester->execution->getById(103); + +r($execution1) && p('status') && e('doing'); // 任务开始将执行的状态设为doing +r($execution2) && p('status') && e('doing'); // 任务开始将执行的状态设为doing +r($execution3) && p('status') && e('doing'); // 任务开始将执行的状态设为doing \ No newline at end of file