From 0a9a6c7388644f38f4757a8312e4fa04e476ba99 Mon Sep 17 00:00:00 2001 From: denghongtao <[denghongtao@easycorp.ltd]> Date: Fri, 25 Mar 2022 14:25:07 +0800 Subject: [PATCH 01/26] add unittest productplan and new productsunplan.yaml --- test/class/productplan.class.php | 199 +++++++++++++++++- test/data/productsunplan.yaml | 48 +++++ test/model/productplan/batchchangestatus.php | 9 + test/model/productplan/batchupdate.php | 86 ++++++++ test/model/productplan/create.php | 45 ++++ test/model/productplan/getbranchplanpairs.php | 20 ++ test/model/productplan/getbyidlist.php | 10 +- test/model/productplan/getbyidplan.php | 10 +- test/model/productplan/getchildren.php | 14 ++ test/model/productplan/getforproducts.php | 14 ++ test/model/productplan/getgroupbyproduct.php | 22 ++ test/model/productplan/getlast.php | 8 +- test/model/productplan/getlist.php | 10 +- test/model/productplan/getpairs.php | 11 +- test/model/productplan/getpairsforstory.php | 18 ++ test/model/productplan/getplansbystories.php | 15 ++ test/model/productplan/update.php | 26 +++ test/model/productplan/updateparentstatus.php | 19 ++ test/model/productplan/updatestatus.php | 21 ++ 19 files changed, 582 insertions(+), 23 deletions(-) create mode 100644 test/data/productsunplan.yaml create mode 100755 test/model/productplan/batchchangestatus.php create mode 100755 test/model/productplan/batchupdate.php create mode 100755 test/model/productplan/create.php create mode 100755 test/model/productplan/getbranchplanpairs.php create mode 100755 test/model/productplan/getchildren.php create mode 100755 test/model/productplan/getforproducts.php create mode 100755 test/model/productplan/getgroupbyproduct.php create mode 100755 test/model/productplan/getpairsforstory.php create mode 100755 test/model/productplan/getplansbystories.php create mode 100755 test/model/productplan/update.php create mode 100755 test/model/productplan/updateparentstatus.php create mode 100755 test/model/productplan/updatestatus.php diff --git a/test/class/productplan.class.php b/test/class/productplan.class.php index dbc5f8cbd0..62dd1ef05f 100644 --- a/test/class/productplan.class.php +++ b/test/class/productplan.class.php @@ -1,5 +1,5 @@ productplan->getList($product = 0, $branch = 0, $browseType = 'doing', $pager = null, $orderBy = 'begin_desc', $param = ''); + $productplans = $this->productplan->getList($product, $branch, $browseType, $pager, $orderBy, $param); return $productplans; } - public function getPairs($product = 0, $branch = '', $expired = '', $skipParent = false) + /** + * getPairs + * + * @param int $product + * @param string $branch + * @param string $expired + * @param mixed $skipParent + * @access public + * @return void + */ + public function getPairs($product, $branch = '', $expired = '', $skipParent = false) { - $productplans = $this->productplan->getPairs($product = 0, $branch = '', $expired = '', $skipParent = false); + $productplans = $this->productplan->getPairs($product, $branch = '', $expired = '', $skipParent = false); + return $productplans; + } + + /** + * getPairsForStory + * + * @param mrray|int mixed $product + * @param int mixed $branch + * @param string mixed $param + * @access public + * @return void + */ + public function getPairsForStory($product, $branch, $param) + { + $productplans = $this->productplan->getPairsForStory($product, $branch, $param); + return count($productplans) - 1; + } + + /** + * getForProducts + * + * @param array(int) mixed $products + * @access public + * @return void + */ + public function getForProducts($products) + { + $productplans = $this->productplan->getForProducts($products); + return count($productplans) - 1; + } + + /** + * getGroupByProduct + * + * @param array(int) mixed $products + * @param string mixed $param + * @param string $field + * @param string $orderBy + * @access public + * @return void + */ + public function getGroupByProduct($products, $param, $field = 'name', $orderBy = 'id_desc') + { + $productplans = $this->productplan->getGroupByProduct($products, $param, $field, $orderBy); + return count($productplans); + } + + /** + * getChildren + * + * @param int mixed $planID + * @access public + * @return void + */ + public function getChildren($planID) + { + $productplans = $this->productplan->getChildren($planID); + return count($productplans); + } + + /** + * getPlansByStories + * + * @param array(int) mixed $storyIdList + * @access public + * @return void + */ + public function getPlansByStories($storyIdList) + { + $productplans = $this->productplan->getPlansByStories($storyIdList); + return count($productplans); + } + + /** + * getBranchPlanPairs + * + * @param int mixed $productID + * @param int mixed $branches + * @access public + * @return void + */ + public function getBranchPlanPairs($productID, $branches) + { + $productplans = $this->productplan->getBranchPlanPairs($productID, $branches); + return $productplans; + } + + /** + * @param array + */ + public function create($param) //声明一个create方法 + { + //初始化传的参数,这里可以设置默认值 + $createPlan = array('title' => '', 'begin' => '', 'end' => '', 'delta' => '', 'desc' => '', 'uid' => '', 'product' => '', 'parent' => ''); + //设置foreach循环,将初始化参数传给全局变量$_POST中,通过此方式将传的参数提供给源码create方法 + foreach($createPlan as $field => $defaultvalue) $_POST[$field] = $defaultvalue; + //二次遍历数组将此方法的形参传入$_POST中,这行可以替换掉初始化参数,做到以传入参数为最终结果的目的。同时不传参数的话取默认值 + foreach($param as $key => $value) $_POST[$key] = $value; + //这行代码的作用是调用源码中的方法(参数通过$_POST直接取,具体原理可以不知道) + $productPlans = $this->productplan->create(); + //将方法返回内容返回 + return $productPlans; + } + + /** + * update + * + * @param int mixed $planID + * @param array mixed $values + * @access public + * @return void + */ + public function update($planID, $values) + { + $updatePlan = array('title' => '', 'status' => '', 'begin' => '', 'end' => '', 'desc' => '', 'uid' => '', 'product' => ''); + + foreach($updatePlan as $field => $defaultvalue) $_POST[$field] = $defaultvalue; + foreach($values as $key =>$value) $_POST[$key] = $value; + + $productplans = $this->productplan->update($planID); + + return $productplans; + } + + /** + * updateStatus + * + * @param int mixed $planID + * @param string $status + * @param string $action + * @access public + * @return void + */ + public function updateStatus($planID, $status = '', $action = '') + { + $productplans = $this->productplan->updateStatus($planID, $status, $action); + return $productplans; + } + + /** + * updateParentStatus + * + * @param int mixed $parentId + * @access public + * @return void + */ + public function updateParentStatus($parentId) + { + $productplans = $this->productplan->updateParentStatus($parentId); + return $productplans; + } + + /** + * batchUpdate + * + * @param int mixed $productId + * @access public + * @return void + */ + public function batchUpdate($productId, $bratch) + { + $batch = array('id' => array(), 'title' => array(), 'begin' => array(), 'end' => array()); + + foreach($batch as $field => $defaultvalue) $_POST[$field] = $defaultvalue; + foreach($bratch as $key => $value) $_POST[$key] = $value; + + $productplans = $this->productplan->batchUpdate($productId); + return $productplans; + } + + public function batchChangeStatus($status) + { + $posts = array(6, 5, 4); + + foreach($posts as $field => $defaultvalue) $_POST[$field] = $defaultvalue; + //foreach($param as $key => $value) $_POST[$key] = $valuep; + + $productplans = $this->productplan->batchChangeStatus($status); return $productplans; } } - ?> diff --git a/test/data/productsunplan.yaml b/test/data/productsunplan.yaml new file mode 100644 index 0000000000..eb229e0995 --- /dev/null +++ b/test/data/productsunplan.yaml @@ -0,0 +1,48 @@ +title: table zt_productplan +desc: "产品子计划" +author: sgm +version: "1.0" +fields: + - field: id + note: "ID" + range: 100-10000 + - field: product + note: "所属产品" + range: 1-10 + - field: branch + note: "所属分支" + range: 41-50 + - field: parent + note: "父计划" + range: 1-10 + - field: title + note: "名称" + range: [1.0,1.1,长名称好长好长好长好长好长好长好长好长好长好长好长好好长好长好长好长好长好好长好长好长好长好长好好长好长好长好长好长好的名字啊!@ase!!@#%@^&#!] + - field: status + note: "状态" + range: wait,doing,closed,done + - field: desc + note: "描述" + range:
+

asdxxxfa阿萨德开机as家世界发卡机发设计费啥登记卡设计费卡加斯加附件阿峰

+

123a阿士大夫姐姐姐经历过反对派呸呸呸史蒂夫接收到付款纪委第三方乐山大佛量减少地方

+

IU风格就叫阿萨德奥斯丁哦IG是DAU发加速度快哦哦阿萨德几年内发,,,奥斯丁,,,切,,,请问加十多年你

+

IUIG是DAU发加速度快哦哦阿萨德几年内发,,,奥斯丁,,,切,,,请问加十多年你

+

IU风格就叫阿萨德奥斯丁哦IG是DAU,,,奥斯丁,,,切,,,请问加十多年你

+
+ - field: begin + note: "开始日期" + range: "(-10M)-(-7M):7D" + type: timestamp + format: "YYYY-MM-DD" + - field: end + note: "结束日期" + range: "(-6M)-(+6M):7D" + type: timestamp + format: "YYYY-MM-DD" + - field: order + note: "排序" + value: "$id * 5" + - field: deleted + note: "是否删除" + range: 0{359},1 diff --git a/test/model/productplan/batchchangestatus.php b/test/model/productplan/batchchangestatus.php new file mode 100755 index 0000000000..6061f57b51 --- /dev/null +++ b/test/model/productplan/batchchangestatus.php @@ -0,0 +1,9 @@ +#!/usr/bin/env php +batchChangeStatus(2));die; +?> diff --git a/test/model/productplan/batchupdate.php b/test/model/productplan/batchupdate.php new file mode 100755 index 0000000000..d58d53da05 --- /dev/null +++ b/test/model/productplan/batchupdate.php @@ -0,0 +1,86 @@ +#!/usr/bin/env php +batchUpdate($product[0], $branch1); +$batchUpdate1 = $batchUpdate[1]; +$batchUpdate2 = $batchUpdate[2]; +$batchUpdate3 = $batchUpdate[3]; + +$newBatchUpdate = $plan->batchUpdate($product[1], $branch2); +$batchUpdate4 = $newBatchUpdate[4]; +$batchUpdate5 = $newBatchUpdate[5]; +$batchUpdate6 = $newBatchUpdate[6]; + +r($batchUpdate1) && p('0:new') && e('list-1'); //当product=1时,传入正常参数批量修改id=1,2,3的计划,打印id=1修改后的名字new +r($batchUpdate2) && p('0:new') && e('list-2'); //当product=1时,传入正常参数批量修改id=1,2,3的计划,打印id=2修改后的名字new +r($batchUpdate3) && p('0:new') && e('list-3'); //当product=1时,传入正常参数批量修改id=1,2,3的计划,打印id=3修改后的名字new +r($batchUpdate4) && p('0:new') && e('list-4'); //当product=2时,传入正常参数批量修改id=4,5,6的计划,打印id=4修改后的名字new +r($batchUpdate5) && p('0:new') && e('list-5'); //当product=2时,传入正常参数批量修改id=4,5,6的计划,打印id=5修改后的名字new +r($batchUpdate6) && p('0:new') && e('list-6'); //当product=2时,传入正常参数批量修改id=4,5,6的计划,打印id=6修改后的名字new +?> diff --git a/test/model/productplan/create.php b/test/model/productplan/create.php new file mode 100755 index 0000000000..f1ade46873 --- /dev/null +++ b/test/model/productplan/create.php @@ -0,0 +1,45 @@ +#!/usr/bin/env php +create($posts)) && p() && e('71'); //测试正常创建 +r($plan->create($noTitle)) && p() && e('0'); //测试不传入名称的情况 +r($plan->create($noBegin)) && p() && e('0'); //测试不传开始时间的情况 +r($plan->create($noEnd)) && p() && e('0'); //测试不传结束时间的情况 +r($plan->create($noBeginEnd)) && p() && e('0'); //测试不传开始时间及结束时间的情况 +r($plan->create($noUid)) && p() && e('0'); //测试不传UID的情况 +r($plan->create($noProduct)) && p() && e('0'); //测试不传关联产品的情况 +r($plan->create($noParent)) && p() && e('0'); //测试不传父级计划的情况 +?> diff --git a/test/model/productplan/getbranchplanpairs.php b/test/model/productplan/getbranchplanpairs.php new file mode 100755 index 0000000000..ae72c7a10b --- /dev/null +++ b/test/model/productplan/getbranchplanpairs.php @@ -0,0 +1,20 @@ +#!/usr/bin/env php +getBranchPlanPairs($product[0], $branch[0])) && p('1:31') && e('1.0 [2021-06-01~2022-04-16]'); //传入存在的数据,返回相应信息 +r($plan->getBranchPlanPairs($product[1], $branch[1])) && p('1:31') && e('0'); //传入不存在的分支 +r($plan->getBranchPlanPairs($product[2], $branch[2])) && p('1:31') && e('0'); //传入不存在的产品id +?> diff --git a/test/model/productplan/getbyidlist.php b/test/model/productplan/getbyidlist.php index 41047865e6..2a1821b1d0 100755 --- a/test/model/productplan/getbyidlist.php +++ b/test/model/productplan/getbyidlist.php @@ -3,15 +3,15 @@ include dirname(dirname(dirname(__FILE__))) . '/lib/init.php'; include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php'; -$productplan = new Productplan('admin'); +$plan = new productPlan('admin'); $IDlist = array(); $IDlist[0] = 1; $IDlist[1] = 1000; $IDlist[2] = 3; -r($productplan->getByIDList($IDlist)) && p('3:id') && e('3'); //传入一个数组,取值id为3的数据 -r($productplan->getByIDList($IDlist)) && p('1:id') && e('1'); //传入一个数组,取值id为1的数据 -r($productplan->getByIDList($IDlist[0])) && p('1:id') && e('1'); //传入一个数值,正常取值 -r($productplan->getByIDList($IDlist[1])) && p() && e('0'); //传入一个不存在的值返回布尔值 +r($plan->getByIDList($IDlist)) && p('3:id') && e('3'); //传入一个数组,取值id为3的数据 +r($plan->getByIDList($IDlist)) && p('1:id') && e('1'); //传入一个数组,取值id为1的数据 +r($plan->getByIDList($IDlist[0])) && p('1:id') && e('1'); //传入一个数值,正常取值 +r($plan->getByIDList($IDlist[1])) && p() && e('0'); //传入一个不存在的值返回布尔值 ?> diff --git a/test/model/productplan/getbyidplan.php b/test/model/productplan/getbyidplan.php index 3303c95f2b..b9b934da41 100755 --- a/test/model/productplan/getbyidplan.php +++ b/test/model/productplan/getbyidplan.php @@ -3,14 +3,14 @@ include dirname(dirname(dirname(__FILE__))) . '/lib/init.php'; include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php'; -$productplan = new Productplan('admin'); +$plan = new productPlan('admin'); $planID = array(); $planID[0] = 5; $planID[1] = 1000; -r($productplan->getByIDPlan($planID[0])) && p('status') && e('wait'); //如果存在,返回数组类型数据 -r($productplan->getByIDPlan($planID[0])) && p('begin') && e('2021-06-13'); //取出开始时间 -r($productplan->getByIDPlan($planID[0])) && p('end') && e('2021-10-14'); //取出结束时间 -r($productplan->getByIDPlan($planID[1])) && p() && e('0'); //如不存在,返回布尔值 +r($plan->getByIDPlan($planID[0])) && p('status') && e('wait'); //如果存在,返回数组类型数据 +r($plan->getByIDPlan($planID[0])) && p('begin') && e('2021-06-13'); //取出开始时间 +r($plan->getByIDPlan($planID[0])) && p('end') && e('2021-10-14'); //取出结束时间 +r($plan->getByIDPlan($planID[1])) && p() && e('0'); //如不存在,返回布尔值 ?> diff --git a/test/model/productplan/getchildren.php b/test/model/productplan/getchildren.php new file mode 100755 index 0000000000..38b173a80d --- /dev/null +++ b/test/model/productplan/getchildren.php @@ -0,0 +1,14 @@ +#!/usr/bin/env php +getChildren(0)) && p() && e('70'); //这里统计了取出所有的数量 +r($plan->getChildren(1)) && p() && e('0'); //这里统计不存在的情况 +?> diff --git a/test/model/productplan/getforproducts.php b/test/model/productplan/getforproducts.php new file mode 100755 index 0000000000..2459361734 --- /dev/null +++ b/test/model/productplan/getforproducts.php @@ -0,0 +1,14 @@ +#!/usr/bin/env php +getForProducts($products[0])) && p() && e('3'); //测试传入一个数组,取出产品名称count +r($plan->getForProducts($products[1])) && p() && e('0'); //测试传入一个不存在的product数组,应为空 +?> diff --git a/test/model/productplan/getgroupbyproduct.php b/test/model/productplan/getgroupbyproduct.php new file mode 100755 index 0000000000..561dc68107 --- /dev/null +++ b/test/model/productplan/getgroupbyproduct.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +getGroupByProduct($products[0], $param[0])) && p() && e('2'); //传入正常product 1,2; +r($plan->getGroupByProduct($products[1], $param[0])) && p() && e('1'); //传入部分不存在product; +r($plan->getGroupByProduct($products[2], $param[0])) && p() && e('0'); //传入不存在product +r($plan->getGroupByProduct($products[0], $param[1])) && p() && e('0'); //传入正常product 1,2;未过期param +r($plan->getGroupByProduct($products[1], $param[1])) && p() && e('0'); //传入部分不存在product;未过期param +r($plan->getGroupByProduct($products[2], $param[1])) && p() && e('0'); //传入不存在product; 未过期param +?> diff --git a/test/model/productplan/getlast.php b/test/model/productplan/getlast.php index ce1970c467..5071e07a01 100755 --- a/test/model/productplan/getlast.php +++ b/test/model/productplan/getlast.php @@ -3,14 +3,14 @@ include dirname(dirname(dirname(__FILE__))) . '/lib/init.php'; include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php'; -$productplan = new Productplan('admin'); +$plan = new productPlan('admin'); $getLast = array(); $getLast[0] = 1; $getLast[1] = 2; $getLast[2] = 200; -r($productplan->getLast($getLast[0])) && p('id') && e('3'); //获取id为1的最后一个产品 -r($productplan->getLast($getLast[1])) && p('id') && e('6'); //获取id为2的最后一个产品 -r($productplan->getLast($getLast[2])) && p('id') && e('0'); //获取不存在的id返回布尔值 +r($plan->getLast($getLast[0])) && p('id') && e('3'); //获取id为1的最后一个产品 +r($plan->getLast($getLast[1])) && p('id') && e('6'); //获取id为2的最后一个产品 +r($plan->getLast($getLast[2])) && p('id') && e('0'); //获取不存在的id返回布尔值 ?> diff --git a/test/model/productplan/getlist.php b/test/model/productplan/getlist.php index 321dd8833b..d0b2e400ff 100755 --- a/test/model/productplan/getlist.php +++ b/test/model/productplan/getlist.php @@ -6,7 +6,13 @@ include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php'; $productplan = new Productplan('admin'); $List = array(); -$List[0] = 0; +$List[0] = 1; +$List[1] = 0; +$List[2] = 'all'; +$List[3] = null; +$List[4] = 'begin_desc'; +$List[5] = 'kipparent'; -r($productplan->getList(1, 0, 'all', null, 'begin_desc', 'kipparent')) && p('') && e('0'); //返回空数组 +//var_dump($productplan->getList(1, 0, 'all', null, 'begin_desc', 'kipparent'));die; +r($productplan->getList(1, 0, 'all', null, 'begin_desc', 'kipparent')) && p('3:id') && e('3'); //查询 ?> diff --git a/test/model/productplan/getpairs.php b/test/model/productplan/getpairs.php index 98952f86e4..268d6569ef 100755 --- a/test/model/productplan/getpairs.php +++ b/test/model/productplan/getpairs.php @@ -3,6 +3,15 @@ include dirname(dirname(dirname(__FILE__))) . '/lib/init.php'; include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php'; -$productplan = new Productplan('admin'); +$plan = new productPlan('admin'); +$product = array(); +$product[0] = 41; +$product[1] = 42; +$branch = 1; +$expired = 'unexpired'; + +r($plan->getPairs($product[0], $branch, $expired)) && p('32') && e('分支2 / 1.1 [2021-06-08 ~ 2022-04-23]'); //id为41的产品分支32 +r($plan->getPairs($product[0], $branch, $expired)) && p('31') && e('分支1 / 1.0 [2021-06-01 ~ 2022-04-16]'); //id为41的产品分支31 +r($plan->getPairs($product[1], $branch, $expired)) && p('34') && e('分支4 / 1.0 [2021-06-22 ~ 2022-05-07]'); //id为42的产品分支34 ?> diff --git a/test/model/productplan/getpairsforstory.php b/test/model/productplan/getpairsforstory.php new file mode 100755 index 0000000000..bb7bf1cc43 --- /dev/null +++ b/test/model/productplan/getpairsforstory.php @@ -0,0 +1,18 @@ +#!/usr/bin/env php +getPairsForStory($product[0], $branch[0], $param[1])) && p('') && e('3'); //测试传入已有数据product=10,branch=0情况,正常返回 +r($plan->getPairsForStory($product[1], $branch[1], $param[1])) && p('') && e('1'); //测试传入product=41, branch=1的数据 +r($plan->getPairsForStory($product, $branch[1], $param[1])) && p('') && e('4'); //测试传入一个数组 +r($plan->getPairsForStory($product[3], $branch[1], $param[1])) && p('') && e('0'); //测试传入不存在的product +r($plan->getPairsForStory($product[0], $branch[0], $param[0])) && p('') && e('3'); //测试传入不同param情况 +r($plan->getPairsForStory($product[0], $branch[0], $param[2])) && p('') && e('3'); //测试传入不同param情况 +?> diff --git a/test/model/productplan/getplansbystories.php b/test/model/productplan/getplansbystories.php new file mode 100755 index 0000000000..e7c282de82 --- /dev/null +++ b/test/model/productplan/getplansbystories.php @@ -0,0 +1,15 @@ +#!/usr/bin/env php +getPlansByStories($storyIdList[0])) && p() && e('3'); //查询存在的id +r($plan->getPlansByStories($storyIdList[1])) && p() && e('1'); //查询部分存在的id +r($plan->getPlansByStories($storyIdList[2])) && p() && e('0'); //查询不存在的id +?> diff --git a/test/model/productplan/update.php b/test/model/productplan/update.php new file mode 100755 index 0000000000..4c4e90c193 --- /dev/null +++ b/test/model/productplan/update.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +update($planId[0], $posts)) && p('0:old') && e('1.1'); //修改planId=5的数据,打印出旧的名称 +r($plan->update($planId[0], $posts)) && p('0:old') && e('0'); //二次修改旧的数据,由于数据发生变化,理应失败 +r($plan->update($planId[0], $late)) && p() && e('0'); //测试传入结束时间小于开始时间的情况 +?> diff --git a/test/model/productplan/updateparentstatus.php b/test/model/productplan/updateparentstatus.php new file mode 100755 index 0000000000..cf71fe9382 --- /dev/null +++ b/test/model/productplan/updateparentstatus.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +updateParentStatus($parentid[0])) && p() && e('1'); //将id为1的计划改为wait状态 +r($plan->updateParentStatus($parentid[1])) && p() && e('1'); //将id为2的计划改为doing状态 +r($plan->updateParentStatus($parentid[2])) && p() && e('1'); //将id为3的计划改为closed状态 +r($plan->updateParentStatus($parentid[3])) && p() && e('1'); //将id为4的计划改为done状态 +?> diff --git a/test/model/productplan/updatestatus.php b/test/model/productplan/updatestatus.php new file mode 100755 index 0000000000..7bf667ba58 --- /dev/null +++ b/test/model/productplan/updatestatus.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +updateStatus($planId[0], $planId[1], $planId[4])) && p() && e('1'); //修改id=5的状态为doing +r($plan->updateStatus($planId[0], $planId[2], $planId[5])) && p() && e('1'); //修改状态为done +r($plan->updateStatus($planId[0], $planId[3], $planId[6])) && p() && e('1'); //修改状态为closed +?> From a7f9fdca861d31a4065f344598e2be4a21991ac1 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Tue, 29 Mar 2022 14:03:53 +0800 Subject: [PATCH 02/26] * Fix bug #18083. --- module/task/lang/en.php | 1 + module/task/lang/zh-cn.php | 1 + module/task/model.php | 7 ++++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/module/task/lang/en.php b/module/task/lang/en.php index c0cf60ed5b..2af706c5a5 100644 --- a/module/task/lang/en.php +++ b/module/task/lang/en.php @@ -246,6 +246,7 @@ $lang->task->error->finishedDateEmpty = '"Finished Date" should not be empty.'; $lang->task->error->finishedDateSmall = '"Finished Date" should be > "Real Started"'; $lang->task->error->alreadyConsumed = 'The currently selected parent task has been consumed.'; $lang->task->error->date = 'The date should be >= today.'; +$lang->task->error->statusLeft = 'When the task status is %s, "Hours Left" cannot be 0'; /* Report. */ $lang->task->report = new stdclass(); diff --git a/module/task/lang/zh-cn.php b/module/task/lang/zh-cn.php index 8f7f05cecd..1c1c1e027a 100644 --- a/module/task/lang/zh-cn.php +++ b/module/task/lang/zh-cn.php @@ -246,6 +246,7 @@ $lang->task->error->finishedDateEmpty = '实际完成不能为空'; $lang->task->error->finishedDateSmall = '实际完成不能小于实际开始'; $lang->task->error->alreadyConsumed = '当前选中的父任务已有消耗。'; $lang->task->error->date = '日期不能大于今天'; +$lang->task->error->statusLeft = '任务状态为%s时,预计剩余不能为0'; /* Report. */ $lang->task->report = new stdclass(); diff --git a/module/task/model.php b/module/task/model.php index f524c69262..8ab54e3e4d 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -998,6 +998,12 @@ class taskModel extends model $requiredFields = str_replace(',estimate,', ',', $requiredFields); } + if(strpos(',done,wait,cancel,closed,', $task->status) === false && empty($teams) && $task->left == 0) + { + dao::$errors[] = sprintf($this->lang->task->error->statusLeft, $this->lang->task->statusList[$task->status]); + return false; + } + $requiredFields = trim($requiredFields, ','); $this->dao->update(TABLE_TASK)->data($task) @@ -1008,7 +1014,6 @@ class taskModel extends model ->checkIF($task->estimate != false, 'estimate', 'float') ->checkIF($task->left != false, 'left', 'float') ->checkIF($task->consumed != false, 'consumed', 'float') - ->checkIF($task->status != 'wait' and empty($teams) and $task->left == 0 and $task->status != 'cancel' and $task->status != 'closed', 'status', 'equal', 'done') ->batchCheckIF($task->status == 'wait' or $task->status == 'doing', 'finishedBy, finishedDate,canceledBy, canceledDate, closedBy, closedDate, closedReason', 'empty') From 3e70b882104a049062b9d77dddd2acc7392f5f57 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Tue, 29 Mar 2022 14:49:01 +0800 Subject: [PATCH 03/26] * Fix bug #18270. --- module/execution/model.php | 8 -------- module/execution/view/create.html.php | 4 ++-- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index cd6c878de0..6c94f5653f 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -305,14 +305,6 @@ class executionModel extends model $type = 'sprint'; if($project) $type = zget($this->config->execution->modelList, $project->model, 'sprint'); - /* If the execution model is a stage, determine whether the product is linked. */ - $products = array_filter($this->post->products); - if(empty($products)) - { - dao::$errors['message'][] = $this->lang->execution->noLinkProduct; - return false; - } - $this->config->execution->create->requiredFields .= ',project'; } diff --git a/module/execution/view/create.html.php b/module/execution/view/create.html.php index fef68cc881..cce35666a4 100644 --- a/module/execution/view/create.html.php +++ b/module/execution/view/create.html.php @@ -144,8 +144,8 @@
-
- +
+
From ecf749b7da013b61afa0566314cde170e2069b31 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Tue, 29 Mar 2022 16:59:33 +0800 Subject: [PATCH 04/26] * Fix bug #18002. --- module/execution/control.php | 12 +++++++++++- module/execution/view/task.html.php | 12 +++++++----- module/execution/view/taskkanban.html.php | 22 +++++++++++++++++----- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index d4ef2cbb54..83d8747b15 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2131,6 +2131,7 @@ class execution extends control */ public function taskKanban($executionID, $browseType = '', $orderBy = 'order_asc', $groupBy = '') { + $execution = $this->loadModel('execution')->getById($executionID); if(empty($browseType)) $browseType = $this->session->kanbanType ? $this->session->kanbanType : 'all'; if(empty($groupBy)) $groupBy = 'default'; @@ -2148,7 +2149,16 @@ class execution extends control /* Compatibility IE8. */ if(strpos($this->server->http_user_agent, 'MSIE 8.0') !== false) header("X-UA-Compatible: IE=EmulateIE7"); - $kanbanGroup = $this->loadModel('kanban')->getExecutionKanban($executionID, $browseType, $groupBy); + if($execution->lifetime == 'ops') + { + unset($this->lang->kanban->type['story']); + unset($this->lang->kanban->type['bug']); + $kanbanGroup = $this->loadModel('kanban')->getExecutionKanban($executionID, 'task', $groupBy); + } + else + { + $kanbanGroup = $this->loadModel('kanban')->getExecutionKanban($executionID, $browseType, $groupBy); + } if(empty($kanbanGroup)) { $this->kanban->createExecutionLane($executionID, $browseType, $groupBy); diff --git a/module/execution/view/task.html.php b/module/execution/view/task.html.php index 1681e153bc..bf0aa62c49 100644 --- a/module/execution/view/task.html.php +++ b/module/execution/view/task.html.php @@ -132,11 +132,13 @@ body {margin-bottom: 25px;} $misc = common::hasPriv('execution', 'importTask') ? "class='import'" : "class=disabled"; $link = common::hasPriv('execution', 'importTask') ? $this->createLink('execution', 'importTask', "execution=$execution->id") : '#'; echo "
  • " . html::a($link, $lang->execution->importTask, '', $misc) . "
  • "; - - $class = common::hasPriv('execution', 'importBug') ? '' : "class=disabled"; - $misc = common::hasPriv('execution', 'importBug') ? "class='import'" : "class=disabled"; - $link = common::hasPriv('execution', 'importBug') ? $this->createLink('execution', 'importBug', "execution=$execution->id") : '#'; - echo "
  • " . html::a($link, $lang->execution->importBug, '', $misc) . "
  • "; + if($execution->lifetime != 'ops') + { + $class = common::hasPriv('execution', 'importBug') ? '' : "class=disabled"; + $misc = common::hasPriv('execution', 'importBug') ? "class='import'" : "class=disabled"; + $link = common::hasPriv('execution', 'importBug') ? $this->createLink('execution', 'importBug', "execution=$execution->id") : '#'; + echo "
  • " . html::a($link, $lang->execution->importBug, '', $misc) . "
  • "; + } ?>
    diff --git a/module/execution/view/taskkanban.html.php b/module/execution/view/taskkanban.html.php index 0c16c7506e..86e9009b3e 100644 --- a/module/execution/view/taskkanban.html.php +++ b/module/execution/view/taskkanban.html.php @@ -13,7 +13,14 @@