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 1/2] 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 62a286da2b74dc7a0a1c2482a463fc8b8f0c69c2 Mon Sep 17 00:00:00 2001
From: qateam
Date: Thu, 31 Mar 2022 09:46:12 +0800
Subject: [PATCH 2/2] add productplan unittest
---
test/class/productplan.class.php | 253 +++++++++++++++---
test/model/productplan/batchchangestatus.php | 38 ++-
test/model/productplan/batchupdate.php | 27 +-
test/model/productplan/changeparentfield.php | 25 ++
test/model/productplan/create.php | 35 ++-
test/model/productplan/getbranchplanpairs.php | 16 +-
test/model/productplan/getbyidlist.php | 15 +-
test/model/productplan/getchildren.php | 16 +-
test/model/productplan/getforproducts.php | 19 +-
test/model/productplan/getgroupbyproduct.php | 17 +-
test/model/productplan/getlast.php | 14 +-
test/model/productplan/getlist.php | 15 +-
test/model/productplan/getpairs.php | 20 +-
test/model/productplan/getpairsforstory.php | 17 +-
test/model/productplan/getplansbystories.php | 14 +-
test/model/productplan/isclickable.php | 38 +++
test/model/productplan/linkbug.php | 43 +++
test/model/productplan/linkproject.php | 19 ++
test/model/productplan/linkstory.php | 46 ++++
test/model/productplan/reorderchildren.php | 29 ++
test/model/productplan/unlinkstory.php | 8 +
test/model/productplan/update.php | 18 +-
test/model/productplan/updateparentstatus.php | 17 +-
test/model/productplan/updatestatus.php | 14 +-
24 files changed, 690 insertions(+), 83 deletions(-)
create mode 100755 test/model/productplan/changeparentfield.php
create mode 100755 test/model/productplan/isclickable.php
create mode 100755 test/model/productplan/linkbug.php
create mode 100755 test/model/productplan/linkproject.php
create mode 100755 test/model/productplan/linkstory.php
create mode 100755 test/model/productplan/reorderchildren.php
create mode 100755 test/model/productplan/unlinkstory.php
diff --git a/test/class/productplan.class.php b/test/class/productplan.class.php
index 62dd1ef05f..4b98b90534 100644
--- a/test/class/productplan.class.php
+++ b/test/class/productplan.class.php
@@ -9,49 +9,52 @@ class productPlan
}
/**
- * getByIDPlan
+ * Get by ID plan
*
* @param int mixed $planID
* @param bool mixed $setImgSize
* @access public
- * @return void
+ * @return array
*/
public function getByIDPlan($planID, $setImgSize = false)
{
$productplans = $this->productplan->getByID($planID, $setImgSize = false);
+ if(dao::isError()) return dao::getError();
return $productplans;
}
/**
- * getByIDList
+ * Get by ID list
*
* @param array(int) mixed $planIDList
* @access public
- * @return void
+ * @return array
*/
public function getByIDList($planIDList)
{
$productplans = $this->productplan->getByIDList($planIDList);
+ if(dao::isError()) return dao::getError();
return $productplans;
}
/**
- * getLast
+ * Get last
*
* @param int mixed $productID
* @param int $branch
* @param int $parent
* @access public
- * @return void
+ * @return array
*/
public function getLast($productID, $branch = 0, $parent = 0)
{
- $productplans = $this->productplan->getLast($productID, $branch = 0, $parent = 0);
+ $productplans = $this->productplan->getLast($productID, $parent);
+ if(dao::isError()) return dao::getError();
return $productplans;
}
/**
- * getList
+ * Get list
*
* @param int $product
* @param int $branch
@@ -60,118 +63,130 @@ class productPlan
* @param string $orderBy
* @param string $param
* @access public
- * @return void
+ * @return array
*/
public function getList($product, $branch, $browseType, $pager, $orderBy, $param)
{
$productplans = $this->productplan->getList($product, $branch, $browseType, $pager, $orderBy, $param);
+ if(dao::isError()) return dao::getError();
return $productplans;
}
/**
- * getPairs
+ * Get pairs
*
* @param int $product
* @param string $branch
* @param string $expired
- * @param mixed $skipParent
+ * @param bool mixed $skipParent
* @access public
- * @return void
+ * @return array
*/
public function getPairs($product, $branch = '', $expired = '', $skipParent = false)
{
$productplans = $this->productplan->getPairs($product, $branch = '', $expired = '', $skipParent = false);
+ if(dao::isError()) return dao::getError();
return $productplans;
}
/**
- * getPairsForStory
+ * Get pairs for story
*
* @param mrray|int mixed $product
* @param int mixed $branch
* @param string mixed $param
* @access public
- * @return void
+ * @return count
*/
public function getPairsForStory($product, $branch, $param)
{
$productplans = $this->productplan->getPairsForStory($product, $branch, $param);
+ if(dao::isError()) return dao::getError();
return count($productplans) - 1;
}
/**
- * getForProducts
+ * Get for products
*
* @param array(int) mixed $products
* @access public
- * @return void
+ * @return count
*/
public function getForProducts($products)
{
$productplans = $this->productplan->getForProducts($products);
- return count($productplans) - 1;
+ if(dao::isError()) return dao::getError();
+ return $productplans;
}
/**
- * getGroupByProduct
+ * Get group by product
*
* @param array(int) mixed $products
* @param string mixed $param
* @param string $field
* @param string $orderBy
* @access public
- * @return void
+ * @return count
*/
public function getGroupByProduct($products, $param, $field = 'name', $orderBy = 'id_desc')
{
$productplans = $this->productplan->getGroupByProduct($products, $param, $field, $orderBy);
+ if(dao::isError()) return dao::getError();
return count($productplans);
}
/**
- * getChildren
+ * Get children
*
* @param int mixed $planID
* @access public
- * @return void
+ * @return count
*/
public function getChildren($planID)
{
$productplans = $this->productplan->getChildren($planID);
+ if(dao::isError()) return dao::getError();
return count($productplans);
}
/**
- * getPlansByStories
+ * Get plans by stories
*
* @param array(int) mixed $storyIdList
* @access public
- * @return void
+ * @return count
*/
public function getPlansByStories($storyIdList)
{
$productplans = $this->productplan->getPlansByStories($storyIdList);
+ if(dao::isError()) return dao::getError();
return count($productplans);
}
/**
- * getBranchPlanPairs
+ * Get branch plan pairs
*
* @param int mixed $productID
* @param int mixed $branches
* @access public
- * @return void
+ * @return array
*/
public function getBranchPlanPairs($productID, $branches)
{
$productplans = $this->productplan->getBranchPlanPairs($productID, $branches);
+ if(dao::isError()) return dao::getError();
return $productplans;
}
/**
- * @param array
+ * Create
+ *
+ * @param array mixed $param
+ * @access public
+ * @return array
*/
- public function create($param) //声明一个create方法
+ public function create($param)
{
//初始化传的参数,这里可以设置默认值
$createPlan = array('title' => '', 'begin' => '', 'end' => '', 'delta' => '', 'desc' => '', 'uid' => '', 'product' => '', 'parent' => '');
@@ -182,16 +197,17 @@ class productPlan
//这行代码的作用是调用源码中的方法(参数通过$_POST直接取,具体原理可以不知道)
$productPlans = $this->productplan->create();
//将方法返回内容返回
+ if(dao::isError()) return dao::getError();
return $productPlans;
}
/**
- * update
+ * Update
*
* @param int mixed $planID
* @param array mixed $values
* @access public
- * @return void
+ * @return array
*/
public function update($planID, $values)
{
@@ -201,44 +217,46 @@ class productPlan
foreach($values as $key =>$value) $_POST[$key] = $value;
$productplans = $this->productplan->update($planID);
-
+ if(dao::isError()) return dao::getError();
return $productplans;
}
/**
- * updateStatus
+ * Update status
*
* @param int mixed $planID
* @param string $status
* @param string $action
* @access public
- * @return void
+ * @return array
*/
public function updateStatus($planID, $status = '', $action = '')
{
$productplans = $this->productplan->updateStatus($planID, $status, $action);
+ if(dao::isError()) return dao::getError();
return $productplans;
}
/**
- * updateParentStatus
+ * Update parent status
*
* @param int mixed $parentId
* @access public
- * @return void
+ * @return bool
*/
public function updateParentStatus($parentId)
{
$productplans = $this->productplan->updateParentStatus($parentId);
+ if(dao::isError()) return dao::getError();
return $productplans;
}
/**
- * batchUpdate
+ * Batch update
*
* @param int mixed $productId
* @access public
- * @return void
+ * @return array(array)
*/
public function batchUpdate($productId, $bratch)
{
@@ -248,17 +266,172 @@ class productPlan
foreach($bratch as $key => $value) $_POST[$key] = $value;
$productplans = $this->productplan->batchUpdate($productId);
+ if(dao::isError()) return dao::getError();
return $productplans;
}
- public function batchChangeStatus($status)
+ /**
+ * Batch change status
+ *
+ * @param string mixed $status
+ * @access public
+ * @return array
+ */
+ public function batchChangeStatus($status, $planIDList = array('planIDList' => array(4, 5)))
{
- $posts = array(6, 5, 4);
+ $planID = $planIDList;
- foreach($posts as $field => $defaultvalue) $_POST[$field] = $defaultvalue;
- //foreach($param as $key => $value) $_POST[$key] = $valuep;
+ foreach($planID as $field => $defaultvalue) $_POST[$field] = $defaultvalue;
$productplans = $this->productplan->batchChangeStatus($status);
+ if(dao::isError()) return dao::getError();
+ return $productplans;
+ }
+
+ /**
+ * Change parent field
+ *
+ * @param int mixed $planID
+ * @access public
+ * @return true
+ */
+ public function changeParentField($planID)
+ {
+ $productplans = $this->productplan->changeParentField($planID);
+ if(dao::isError()) return dao::getError();
+ return $productplans;
+ }
+
+ /**
+ * Link story
+ *
+ * @param int mixed $planID
+ * @param array(stories => array())mixed $storyID
+ * @access public
+ * @return void
+ */
+ public function linkStory($planID, $storyID)
+ {
+
+ foreach($storyID as $key => $value) $_POST[$key] = $value;
+
+ $productplans = $this->productplan->linkStory($planID);
+
+ if(dao::isError()) return dao::getError();
+ return $productplans;
+ }
+
+ /**
+ * Unlink story
+ *
+ * @param int mixed $storyID
+ * @param int mixed $planID
+ * @access public
+ * @return void
+ */
+ public function unlinkStory($storyID, $planID)
+ {
+ $productPlans = $this->productplan->unlinkStory($storyID, $planID);
+
+ if(dao::isError()) return dao::getError();
+
+ return $productPlans;
+ }
+
+ /**
+ * Link bug
+ *
+ * @param int mixed $planID
+ * @param array mixed $bugID
+ * @access public
+ * @return void
+ */
+ public function linkBug($planID, $bugID)
+ {
+
+ foreach($bugID as $key => $value) $_POST[$key] = $value;
+
+ $productPlans = $this->productplan->linkBug($planID);
+
+ if(dao::isError()) return dao::getError();
+
+ return $productPlans;
+ }
+
+ /**
+ * Unlink bug
+ *
+ * @param int mixed $bugID
+ * @access public
+ * @return void
+ */
+ public function unlinkBug($bugID)
+ {
+ $productplans = $this->productplan->unlinkBug($bugID);
+
+ if(dao::isError()) return dao::getError();
+
+ return $productplans;
+ }
+
+ /**
+ * Link project
+ *
+ * @param $projectID mixed $projectID
+ * @param $newPlans mixed $newPlans
+ * @access public
+ * @return void
+ */
+ public function linkProject($projectID, $newPlans)
+ {
+ $productplans = $this->productplan->linkProject($projectID, $newPlans);
+
+ if(dao::isError()) return dao::getError();
+
+ return $productplans;
+ }
+
+ /**
+ * Reorder 4 children
+ *
+ * @param array mixed $plans
+ * @access public
+ * @return array
+ */
+ public function reorder4Children($plans)
+ {
+ $plan = $this->productplan->dao->select('*')->from(TABLE_PRODUCTPLAN)
+ ->where('id')->in($plans)
+ ->andWhere('deleted')->eq(0)
+ ->fetchAll('id');
+
+ $productplans = $this->productplan->reorder4Children($plan);
+
+ if(dao::isError()) return dao::getError();
+
+ return $productplans;
+ }
+
+ /**
+ * Is clickable
+ *
+ * @param int mixed $planID
+ * @param string mixed $action
+ * @access public
+ * @return void
+ */
+ public function isClickable($planID, $action)
+ {
+ $plan = $this->productplan->dao->select('*')->from(TABLE_PRODUCTPLAN)
+ ->where('id')->eq($planID)
+ ->andWhere('deleted')->eq(0)
+ ->fetchAll('id');
+
+ $plans = $plan[$planID];
+ $productplans = $this->productplan->isClickable($plans, $action);
+
+ if(dao::isError()) return dao::getError();
+
return $productplans;
}
diff --git a/test/model/productplan/batchchangestatus.php b/test/model/productplan/batchchangestatus.php
index 6061f57b51..3d03dc2808 100755
--- a/test/model/productplan/batchchangestatus.php
+++ b/test/model/productplan/batchchangestatus.php
@@ -3,7 +3,41 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->batchChangeStatus();
+cid=1
+pid=1
+
+将planiID=4,5的计划状态修改为doing,打印4旧状态 >> wait
+将planiID=4, 5的计划状态修改为doing,打印4新状态 >> doing
+将planiID=4, 5的计划状态修改为doing,打印5旧状态 >> wait
+将planiID=4, 5的计划状态修改为doing,打印5新状态 >> doing
+将planiID=4, 5的计划状态修改回wait, 打印4的当前状态 >> doing
+将planiID=4, 5的计划状态修改回wait, 打印4的修改后的状态 >> wait
+将planiID=4, 5的计划状态修改回wait, 打印5的当前状态 >> doing
+将planiID=4, 5的计划状态修改回wait, 打印5的修改后的状态 >> wait
+
+*/
$plan = new productPlan('admin');
-var_dump($plan->batchChangeStatus(2));die;
-?>
+$postID = array('planIDList' => array(4, 5));
+
+$status = $plan->batchChangeStatus('doing', $postID);
+$status4 = $status[4];
+$status5 = $status[5];
+
+$status = $plan->batchChangeStatus('wait', $postID);
+$status6 = $status[4];
+$status7 = $status[5];
+
+r($status4) && p('0:old') && e('wait'); //将planiID=4,5的计划状态修改为doing,打印4旧状态
+r($status4) && p('0:new') && e('doing'); //将planiID=4, 5的计划状态修改为doing,打印4新状态
+r($status5) && p('0:old') && e('wait'); //将planiID=4, 5的计划状态修改为doing,打印5旧状态
+r($status5) && p('0:new') && e('doing'); //将planiID=4, 5的计划状态修改为doing,打印5新状态
+r($status6) && p('0:old') && e('doing'); //将planiID=4, 5的计划状态修改回wait, 打印4的当前状态
+r($status6) && p('0:new') && e('wait'); //将planiID=4, 5的计划状态修改回wait, 打印4的修改后的状态
+r($status7) && p('0:old') && e('doing'); //将planiID=4, 5的计划状态修改回wait, 打印5的当前状态
+r($status6) && p('0:new') && e('wait'); //将planiID=4, 5的计划状态修改回wait, 打印5的修改后的状态
+system("./ztest init");
+?>
\ No newline at end of file
diff --git a/test/model/productplan/batchupdate.php b/test/model/productplan/batchupdate.php
index d58d53da05..a28ede7e26 100755
--- a/test/model/productplan/batchupdate.php
+++ b/test/model/productplan/batchupdate.php
@@ -3,6 +3,20 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->batchUpdate();
+cid=1
+pid=1
+
+当product=1时,传入正常参数批量修改id=1,2,3的计划,打印id=1修改后的名字new >> list-1
+当product=1时,传入正常参数批量修改id=1,2,3的计划,打印id=2修改后的名字new >> list-2
+当product=1时,传入正常参数批量修改id=1,2,3的计划,打印id=3修改后的名字new >> list-3
+当product=2时,传入正常参数批量修改id=4,5,6的计划,打印id=4修改后的名字new >> list-4
+当product=2时,传入正常参数批量修改id=4,5,6的计划,打印id=5修改后的名字new >> list-5
+当product=2时,传入正常参数批量修改id=4,5,6的计划,打印id=6修改后的名字new >> list-6
+
+*/
$plan = new productPlan('admin');
$product = array();
@@ -30,11 +44,10 @@ $begin1[2] = '2021-04-12';
$begin1[3] = '2021-04-01';
$end1 = $end;
-$end1[1] = '2021-10-31';
+$end1[1] = '2021-11-30';
$end1[2] = '2021-10-25';
$end1[3] = '2021-10-23';
-
$id2 = $id;
$id2[4] = 4;
$id2[5] = 5;
@@ -51,9 +64,9 @@ $begin2[5] = '2021-06-12';
$begin2[4] = '2021-06-01';
$end2 = $end;
-$end2[6] = '2021-10-31';
-$end2[5] = '2021-10-25';
-$end2[4] = '2021-10-23';
+$end2[6] = '2021-11-30';
+$end2[5] = '2021-11-28';
+$end2[4] = '2021-11-23';
$branch1 = array();
$branch1['id'] = $id1;
@@ -68,6 +81,7 @@ $branch2['begin'] = $begin2;
$branch2['end'] = $end2;
$batchUpdate = $plan->batchUpdate($product[0], $branch1);
+
$batchUpdate1 = $batchUpdate[1];
$batchUpdate2 = $batchUpdate[2];
$batchUpdate3 = $batchUpdate[3];
@@ -83,4 +97,5 @@ r($batchUpdate3) && p('0:new') && e('list-3'); //当product=1时,传入正常参
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
-?>
+system("./ztest init");
+?>
\ No newline at end of file
diff --git a/test/model/productplan/changeparentfield.php b/test/model/productplan/changeparentfield.php
new file mode 100755
index 0000000000..a73eb55b9e
--- /dev/null
+++ b/test/model/productplan/changeparentfield.php
@@ -0,0 +1,25 @@
+#!/usr/bin/env php
+changeParentField();
+cid=1
+pid=1
+
+传入ID为1的情况,返回true >> 1
+传入ID为5的情况,返回true,如不存在函数会报错 >> 1
+
+*/
+
+$plan = new productPlan('admin');
+
+$planID = array();
+$planID[0] = 1;
+$planID[1] = 5;
+
+r($plan->changeParentField($planID[0])) && p() && e('1'); //传入ID为1的情况,返回true
+r($plan->changeParentField($planID[1])) && p() && e('1'); //传入ID为5的情况,返回true,如不存在函数会报错
+?>
\ No newline at end of file
diff --git a/test/model/productplan/create.php b/test/model/productplan/create.php
index f1ade46873..eeef6ea9f0 100755
--- a/test/model/productplan/create.php
+++ b/test/model/productplan/create.php
@@ -3,6 +3,22 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->create();
+cid=1
+pid=1
+
+测试正常创建 >> 110
+测试不传入名称的情况 >> 『名称』不能为空。
+测试不传开始时间的情况 >> 111
+测试不传结束时间的情况 >> 112
+测试不传开始时间及结束时间的情况 >> 113
+测试不传UID的情况 >> 114
+测试不传关联产品的情况 >> 『产品』应当是数字。
+测试不传父级计划的情况 >> 『父计划』应当是数字。
+
+*/
$plan = new productPlan('admin');
$posts = array();
@@ -34,12 +50,13 @@ $noProduct['product'] = '';
$noParent = $posts;
$noParent['parent'] = '';
-r($plan->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'); //测试不传父级计划的情况
-?>
+r($plan->create($posts)) && p() && e('110'); //测试正常创建
+r($plan->create($noTitle)) && p('title:0') && e('『名称』不能为空。'); //测试不传入名称的情况
+r($plan->create($noBegin)) && p() && e('111'); //测试不传开始时间的情况
+r($plan->create($noEnd)) && p() && e('112'); //测试不传结束时间的情况
+r($plan->create($noBeginEnd)) && p() && e('113'); //测试不传开始时间及结束时间的情况
+r($plan->create($noUid)) && p() && e('114'); //测试不传UID的情况
+r($plan->create($noProduct)) && p('product:0') && e('『产品』应当是数字。'); //测试不传关联产品的情况
+r($plan->create($noParent)) && p('parent:0') && e('『父计划』应当是数字。'); //测试不传父级计划的情况
+system("./ztest init");
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getbranchplanpairs.php b/test/model/productplan/getbranchplanpairs.php
index ae72c7a10b..9a00a71959 100755
--- a/test/model/productplan/getbranchplanpairs.php
+++ b/test/model/productplan/getbranchplanpairs.php
@@ -3,18 +3,30 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->getLast();
+cid=1
+pid=1
+
+传入存在的数据,返回相应信息 >> 1.0 [2021-06-11~2022-04-26]
+传入不存在的分支 >> 0
+传入不存在的产品id >> 0
+
+*/
$plan = new productPlan('admin');
$product = array();
$product[0] = 41;
$product[1] = 1;
$product[2] = 111;
+
$branch = array();
$branch[0] = 1;
$branch[1] = 111;
$branch[2] = 1;
-r($plan->getBranchPlanPairs($product[0], $branch[0])) && p('1:31') && e('1.0 [2021-06-01~2022-04-16]'); //传入存在的数据,返回相应信息
+r($plan->getBranchPlanPairs($product[0], $branch[0])) && p('1:31') && e('1.0 [2021-06-11~2022-04-26]'); //传入存在的数据,返回相应信息
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
-?>
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getbyidlist.php b/test/model/productplan/getbyidlist.php
index 2a1821b1d0..7b94582e2d 100755
--- a/test/model/productplan/getbyidlist.php
+++ b/test/model/productplan/getbyidlist.php
@@ -3,6 +3,19 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=cid=1
+cid=1
+pid=1
+
+传入一个数组,取值id为3的数据 >> 3
+传入一个数组,取值id为1的数据 >> 1
+传入一个数值,正常取值 >> 1
+传入一个不存在的值返回布尔值 >> 0
+
+*/
+
$plan = new productPlan('admin');
$IDlist = array();
@@ -14,4 +27,4 @@ r($plan->getByIDList($IDlist)) && p('3:id') && e('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'); //传入一个不存在的值返回布尔值
-?>
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getchildren.php b/test/model/productplan/getchildren.php
index 38b173a80d..1f630e5a6b 100755
--- a/test/model/productplan/getchildren.php
+++ b/test/model/productplan/getchildren.php
@@ -3,12 +3,22 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->getChildren();
+cid=1
+pid=1
+
+这里统计了取出所有的数量 >> 61
+这里统计不存在的情况 >> 1
+
+*/
$plan = new productPlan('admin');
$planid = array();
$planid[0] = 0;
$planid[1] = 1;
-r($plan->getChildren(0)) && p() && e('70'); //这里统计了取出所有的数量
-r($plan->getChildren(1)) && p() && e('0'); //这里统计不存在的情况
-?>
+r($plan->getChildren(0)) && p() && e('61'); //这里统计了取出所有的数量
+r($plan->getChildren(1)) && p() && e('1'); //这里统计不存在的情况
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getforproducts.php b/test/model/productplan/getforproducts.php
index 2459361734..514d66e573 100755
--- a/test/model/productplan/getforproducts.php
+++ b/test/model/productplan/getforproducts.php
@@ -3,12 +3,25 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->getForProducts();
+cid=1
+pid=1
+
+测试传入一个数组,取出产品名称count >> 1.0
+测试传入一个不存在的product数组,应为空 >> 0
+
+*/
+
$plan = new productPlan('admin');
$products = array();
$products[0] = array(1, 2);
$products[1] = array(1000,1001);
-r($plan->getForProducts($products[0])) && p() && e('3'); //测试传入一个数组,取出产品名称count
-r($plan->getForProducts($products[1])) && p() && e('0'); //测试传入一个不存在的product数组,应为空
-?>
+$noProduct = count($plan->getForProducts(array(1000,1001))) -1;
+
+r($plan->getForProducts($products[0])) && p('1') && e('1.0'); //测试传入一个数组,取出产品名称count
+r($noProduct) && p() && e('0'); //测试传入一个不存在的product数组,应为空
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getgroupbyproduct.php b/test/model/productplan/getgroupbyproduct.php
index 561dc68107..51a243de40 100755
--- a/test/model/productplan/getgroupbyproduct.php
+++ b/test/model/productplan/getgroupbyproduct.php
@@ -3,6 +3,21 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->getGroupByProduct();
+cid=1
+pid=1
+
+传入正常product 1,2; >> 2
+传入部分不存在product; >> 1
+传入不存在product >> 0
+传入正常product 1,2;未过期param >> 0
+传入部分不存在product;未过期param >> 0
+传入不存在product; 未过期param >> 0
+
+*/
+
$plan = new productPlan('admin');
$products = array();
@@ -19,4 +34,4 @@ r($plan->getGroupByProduct($products[2], $param[0])) && p() && e('0'); //传入
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
-?>
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getlast.php b/test/model/productplan/getlast.php
index 5071e07a01..158aa952fb 100755
--- a/test/model/productplan/getlast.php
+++ b/test/model/productplan/getlast.php
@@ -3,6 +3,18 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->getLast();
+cid=1
+pid=1
+
+获取id为1的最后一个产品 >> 3
+获取id为2的最后一个产品 >> 6
+获取不存在的id返回布尔值 >> 0
+
+*/
+
$plan = new productPlan('admin');
$getLast = array();
@@ -13,4 +25,4 @@ $getLast[2] = 200;
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返回布尔值
-?>
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getlist.php b/test/model/productplan/getlist.php
index d0b2e400ff..76bbbd31d9 100755
--- a/test/model/productplan/getlist.php
+++ b/test/model/productplan/getlist.php
@@ -3,6 +3,16 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=cid=1
+cid=1
+pid=1
+
+获取product=1的所有数据 >> 3
+
+*/
+
$productplan = new Productplan('admin');
$List = array();
@@ -13,6 +23,5 @@ $List[3] = null;
$List[4] = 'begin_desc';
$List[5] = 'kipparent';
-//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'); //查询
-?>
+r($productplan->getList(1, 0, 'all', null, 'begin_desc', 'kipparent')) && p('3:id') && e('3'); //获取product=1的所有数据
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getpairs.php b/test/model/productplan/getpairs.php
index 268d6569ef..b69d300d8f 100755
--- a/test/model/productplan/getpairs.php
+++ b/test/model/productplan/getpairs.php
@@ -3,6 +3,18 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->getPairs();
+cid=1
+pid=1
+
+id为41的产品分支32 >> 分支2 / 1.1 [2021-06-18 ~ 2022-05-03]
+id为41的产品分支31 >> 分支1 / 1.0 [2021-06-11 ~ 2022-04-26]
+id为42的产品分支34 >> 分支4 / 1.0 [2021-07-02 ~ 2022-05-17]
+
+*/
+
$plan = new productPlan('admin');
$product = array();
@@ -11,7 +23,7 @@ $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
-?>
+r($plan->getPairs($product[0], $branch, $expired)) && p('32') && e('分支2 / 1.1 [2021-06-18 ~ 2022-05-03]'); //id为41的产品分支32
+r($plan->getPairs($product[0], $branch, $expired)) && p('31') && e('分支1 / 1.0 [2021-06-11 ~ 2022-04-26]'); //id为41的产品分支31
+r($plan->getPairs($product[1], $branch, $expired)) && p('34') && e('分支4 / 1.0 [2021-07-02 ~ 2022-05-17]'); //id为42的产品分支34
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getpairsforstory.php b/test/model/productplan/getpairsforstory.php
index bb7bf1cc43..8de61c3710 100755
--- a/test/model/productplan/getpairsforstory.php
+++ b/test/model/productplan/getpairsforstory.php
@@ -3,6 +3,21 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->getPairsForStory();
+cid=1
+pid=1
+
+测试传入已有数据product=10,branch=0情况,正常返回 >> 3
+测试传入product=41, branch=1的数据 >> 1
+测试传入一个数组 >> 4
+测试传入不存在的product >> 0
+测试传入不同param情况 >> 3
+测试传入不同param情况 >> 3
+
+*/
+
$plan = new productPlan('admin');
$product = array(10, 41, 42, 1000);
@@ -15,4 +30,4 @@ 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情况
-?>
+?>
\ No newline at end of file
diff --git a/test/model/productplan/getplansbystories.php b/test/model/productplan/getplansbystories.php
index e7c282de82..6f451f23fd 100755
--- a/test/model/productplan/getplansbystories.php
+++ b/test/model/productplan/getplansbystories.php
@@ -3,13 +3,25 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->getPlansByStories();
+cid=1
+pid=1
+
+查询存在的id >> 3
+查询部分存在的id >> 1
+查询不存在的id >> 0
+
+*/
$plan = new productPlan('admin');
$storyIdList = array();
$storyIdList[0] = array(5, 6, 7);
$storyIdList[1] = array(5, 1000);
$storyIdList[2] = array(1000, 1001);
+
r($plan->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
-?>
+?>
\ No newline at end of file
diff --git a/test/model/productplan/isclickable.php b/test/model/productplan/isclickable.php
new file mode 100755
index 0000000000..83ccf7ef54
--- /dev/null
+++ b/test/model/productplan/isclickable.php
@@ -0,0 +1,38 @@
+#!/usr/bin/env php
+isClickable();
+cid=1
+pid=1
+
+id=100,无子集计划,可以点击的id=100 >> 1
+id=1,有子集计划,不能点击 >> 0
+id=102,无子集计划,计划关闭,不可点击 >> 0
+id=105,无子集计划,等待状态,不可点击 >> 0
+
+*/
+
+$plan = new productPlan('admin');
+
+$planID = array();
+$planID[0] = 100;
+$planID[1] = 101;
+$planID[2] = 1;
+$planID[3] = 102;
+$planID[4] = 105;
+
+$action = array();
+$action[0] = 'start';
+$action[1] = 'finish';
+$action[2] = 'close';
+$action[3] = 'activate';
+
+r($plan->isClickable($planID[0], $action[0])) && p() && e('1'); //id=100,无子集计划,可以点击的id=100
+r($plan->isClickable($planID[2], $action[1])) && p() && e('0'); //id=1,有子集计划,不能点击
+r($plan->isClickable($planID[3], $action[2])) && p() && e('0'); //id=102,无子集计划,计划关闭,不可点击
+r($plan->isClickable($planID[4], $action[3])) && p() && e('0'); //id=105,无子集计划,等待状态,不可点击
+?>
\ No newline at end of file
diff --git a/test/model/productplan/linkbug.php b/test/model/productplan/linkbug.php
new file mode 100755
index 0000000000..970c839396
--- /dev/null
+++ b/test/model/productplan/linkbug.php
@@ -0,0 +1,43 @@
+#!/usr/bin/env php
+linkBug()
+cid=1
+pid=1
+
+id为100的计划关联id为3的bug >> 0
+id为100的计划关联id为1和2的bug >> 0
+传入不存在的id >> 0
+解除bugid为1的关联关系 >> 0
+解除bugid为2的关联关系 >> 0
+解除不存在的id >> 0
+
+*/
+
+$plan = new productPlan('admin');
+
+$planID = array();
+$planID[0] = 100;
+
+$bugID = array();
+$bugID[0] = array('bugs' => array(3));
+$bugID[1] = array('bugs' => array(1, 2));
+$bugID[2] = array('bugs' => array(10000));
+
+$unbugID = array();
+$unbugID[0] = 1;
+$unbugID[1] = 2;
+$unbugID[2] = 10000;
+
+r($plan->linkBug($planID[0], $bugID[0])) && p() && e('0'); //id为100的计划关联id为3的bug
+r($plan->linkBug($planID[0], $bugID[1])) && p() && e('0'); //id为100的计划关联id为1和2的bug
+r($plan->linkBug($planID[0], $bugID[2])) && p() && e('0'); //传入不存在的id
+r($plan->unlinkBug($planID[0], $unbugID[0])) && p() && e('0'); //解除bugid为1的关联关系
+r($plan->unlinkBug($planID[0], $unbugID[1])) && p() && e('0'); //解除bugid为2的关联关系
+r($plan->unlinkBug($planID[0], $unbugID[2])) && p() && e('0'); //解除不存在的id
+system("./ztest init");
+?>
\ No newline at end of file
diff --git a/test/model/productplan/linkproject.php b/test/model/productplan/linkproject.php
new file mode 100755
index 0000000000..fe0c820096
--- /dev/null
+++ b/test/model/productplan/linkproject.php
@@ -0,0 +1,19 @@
+#!/usr/bin/env php
+linkProject();
+cid=1
+pid=1
+
+项目ID=3关联计划ID为11,12的产品计划 >> 0
+
+*/
+
+$plan = new productPlan('admin');
+
+r($plan->linkProject(13, array(11 ,12))) && p() && e('0'); //项目ID=3关联计划ID为11,12的产品计划
+?>
\ No newline at end of file
diff --git a/test/model/productplan/linkstory.php b/test/model/productplan/linkstory.php
new file mode 100755
index 0000000000..14c05dd0d4
--- /dev/null
+++ b/test/model/productplan/linkstory.php
@@ -0,0 +1,46 @@
+#!/usr/bin/env php
+linkStory();
+cid=1
+pid=1
+
+关联计划id为100的需求4 >> 0
+关联计划id为101的需求8 >> 0
+传入不存在id的情况 >> 0
+解除id为100关联需求4 >> 0
+解除id为101关联需求8 >> 0
+
+*/
+
+$plan = new productPlan('admin');
+
+$planID = array();
+$planID[0] = 100;
+$planID[1] = 101;
+$planID[2] = 10000;
+
+$storyID = array();
+$storyID[0] = array('stories' => array(4));
+$storyID[1] = array('stories' => array(8));
+$storyID[2] = array('stories' => array(1111));
+
+$unstoryID = array();
+$unstoryID[0] = 4;
+$unstoryID[1] = 8;
+$unstoryID[2] = 1111;
+
+#方法没有return返回结果,页面上看关联成功了,成功失败均返回空
+r($plan->linkStory($planID[0], $storyID[0])) && p() && e('0'); //关联计划id为100的需求4
+r($plan->linkStory($planID[1], $storyID[1])) && p() && e('0'); //关联计划id为101的需求8
+r($plan->linkStory($planID[2], $storyID[2])) && p() && e('0'); //传入不存在id的情况
+
+#这里将另一个同类方法unlinkStory放在这里调用
+r($plan->unlinkStory($unstoryID[0], $planID[0])) && p() && e('0'); //解除id为100关联需求4
+r($plan->unlinkStory($unstoryID[1], $planID[1])) && p() && e('0'); //解除id为101关联需求8
+system("./ztest init");
+?>
\ No newline at end of file
diff --git a/test/model/productplan/reorderchildren.php b/test/model/productplan/reorderchildren.php
new file mode 100755
index 0000000000..198e439bef
--- /dev/null
+++ b/test/model/productplan/reorderchildren.php
@@ -0,0 +1,29 @@
+#!/usr/bin/env php
+reorder4Children();
+cid=1
+pid=1
+
+传入三个子计划id100,102,101,排序第一个 >> 100
+第二个 >> 101
+第三个,会输出正序排列的数组100,101,102 >> 102
+传入不存在的id时 >> 0
+
+*/
+
+$plan = new productPlan('admin');
+
+$planID = array();
+$planID[0] = array(100, 102, 101);
+$planID[1] = array(1000, 10000);
+
+r($plan->reorder4Children($planID[0])) && p('100:id') && e('100'); //传入三个子计划id100,102,101,排序第一个
+r($plan->reorder4Children($planID[0])) && p('101:id') && e('101'); //第二个
+r($plan->reorder4Children($planID[0])) && p('102:id') && e('102'); //第三个,会输出正序排列的数组100,101,102
+r($plan->reorder4Children($planID[1])) && p() && e('0'); //传入不存在的id时
+?>
\ No newline at end of file
diff --git a/test/model/productplan/unlinkstory.php b/test/model/productplan/unlinkstory.php
new file mode 100755
index 0000000000..8b86073a4e
--- /dev/null
+++ b/test/model/productplan/unlinkstory.php
@@ -0,0 +1,8 @@
+#!/usr/bin/env php
+
diff --git a/test/model/productplan/update.php b/test/model/productplan/update.php
index 4c4e90c193..82eedba5a1 100755
--- a/test/model/productplan/update.php
+++ b/test/model/productplan/update.php
@@ -3,6 +3,17 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->update();
+cid=1
+pid=1
+
+修改planId=5的数据,打印出旧的名称 >> 1.1
+二次修改旧的数据,由于数据发生变化,理应失败 >> 0
+测试传入结束时间小于开始时间的情况 >> 父计划[5]的完成日期:2021-10-10,不能小于子计划的完成日期: 2021-10-26
+
+*/
$plan = new productPlan('admin');
$planId = array();
@@ -12,7 +23,7 @@ $planId[1] = 6;
$posts = array();
$posts['title'] = '测试修改';
$posts['status'] = 'doing';
-$posts['begin'] = '2022-03-22';
+$posts['begin'] = '2021-03-22';
$posts['end'] = '2022-10-31';
$posts['uid'] = '';
$posts['product'] = '2';
@@ -22,5 +33,6 @@ $late['end'] = '2021-10-10';
r($plan->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'); //测试传入结束时间小于开始时间的情况
-?>
+r($plan->update($planId[0], $late)) && p('end') && e('父计划[5]的完成日期:2021-10-10,不能小于子计划的完成日期: 2021-10-26'); //测试传入结束时间小于开始时间的情况
+system("./ztest init");
+?>
\ No newline at end of file
diff --git a/test/model/productplan/updateparentstatus.php b/test/model/productplan/updateparentstatus.php
index cf71fe9382..c9504744b5 100755
--- a/test/model/productplan/updateparentstatus.php
+++ b/test/model/productplan/updateparentstatus.php
@@ -3,6 +3,18 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->updateParentStatus();
+cid=1
+pid=1
+
+将id为1的计划改为wait状态 >> 0
+将id为2的计划改为doing状态 >> 1
+将id为3的计划改为closed状态 >> 1
+将id为4的计划改为done状态 >> 1
+
+*/
$plan = new productPlan('admin');
$parentId = array();
@@ -12,8 +24,9 @@ $parentid[2] = 3;
$parentid[3] = 4;
#此方法将父级plan状态改为与子plan相同的状态
-r($plan->updateParentStatus($parentid[0])) && p() && e('1'); //将id为1的计划改为wait状态
+r($plan->updateParentStatus($parentid[0])) && p() && e('0'); //将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状态
-?>
+system("./ztest init");
+?>
\ No newline at end of file
diff --git a/test/model/productplan/updatestatus.php b/test/model/productplan/updatestatus.php
index 7bf667ba58..83474ef0b2 100755
--- a/test/model/productplan/updatestatus.php
+++ b/test/model/productplan/updatestatus.php
@@ -3,6 +3,17 @@
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
+/**
+
+title=productpanModel->updateStatus();
+cid=1
+pid=1
+
+修改id=5的状态为doing >> 1
+修改状态为done >> 1
+修改状态为closed >> 1
+
+*/
$plan = new productPlan('admin');
$planId = array();
@@ -18,4 +29,5 @@ $planId[7] = 'activated';
r($plan->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
-?>
+system("./ztest init");
+?>
\ No newline at end of file