diff --git a/test/class/productplan.class.php b/test/class/productplan.class.php index dbc5f8cbd0..4b98b90534 100644 --- a/test/class/productplan.class.php +++ b/test/class/productplan.class.php @@ -1,5 +1,5 @@ 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,20 +63,377 @@ class Productplan * @param string $orderBy * @param string $param * @access public - * @return void + * @return array */ - public function getList($product = 0, $branch = 0, $browseType = 'doing', $pager = null, $orderBy = 'begin_desc', $param = '') + public function getList($product, $branch, $browseType, $pager, $orderBy, $param) { - $productplans = $this->productplan->getList($product = 0, $branch = 0, $browseType = 'doing', $pager = null, $orderBy = 'begin_desc', $param = ''); + $productplans = $this->productplan->getList($product, $branch, $browseType, $pager, $orderBy, $param); + if(dao::isError()) return dao::getError(); return $productplans; } - public function getPairs($product = 0, $branch = '', $expired = '', $skipParent = false) + /** + * Get pairs + * + * @param int $product + * @param string $branch + * @param string $expired + * @param bool mixed $skipParent + * @access public + * @return array + */ + 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); + if(dao::isError()) return dao::getError(); + return $productplans; + } + + /** + * Get pairs for story + * + * @param mrray|int mixed $product + * @param int mixed $branch + * @param string mixed $param + * @access public + * @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; + } + + /** + * Get for products + * + * @param array(int) mixed $products + * @access public + * @return count + */ + public function getForProducts($products) + { + $productplans = $this->productplan->getForProducts($products); + if(dao::isError()) return dao::getError(); + return $productplans; + } + + /** + * Get group by product + * + * @param array(int) mixed $products + * @param string mixed $param + * @param string $field + * @param string $orderBy + * @access public + * @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); + } + + /** + * Get children + * + * @param int mixed $planID + * @access public + * @return count + */ + public function getChildren($planID) + { + $productplans = $this->productplan->getChildren($planID); + if(dao::isError()) return dao::getError(); + return count($productplans); + } + + /** + * Get plans by stories + * + * @param array(int) mixed $storyIdList + * @access public + * @return count + */ + public function getPlansByStories($storyIdList) + { + $productplans = $this->productplan->getPlansByStories($storyIdList); + if(dao::isError()) return dao::getError(); + return count($productplans); + } + + /** + * Get branch plan pairs + * + * @param int mixed $productID + * @param int mixed $branches + * @access public + * @return array + */ + public function getBranchPlanPairs($productID, $branches) + { + $productplans = $this->productplan->getBranchPlanPairs($productID, $branches); + if(dao::isError()) return dao::getError(); + return $productplans; + } + + /** + * Create + * + * @param array mixed $param + * @access public + * @return array + */ + public function create($param) + { + //初始化传的参数,这里可以设置默认值 + $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(); + //将方法返回内容返回 + if(dao::isError()) return dao::getError(); + return $productPlans; + } + + /** + * Update + * + * @param int mixed $planID + * @param array mixed $values + * @access public + * @return array + */ + 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); + if(dao::isError()) return dao::getError(); + return $productplans; + } + + /** + * Update status + * + * @param int mixed $planID + * @param string $status + * @param string $action + * @access public + * @return array + */ + public function updateStatus($planID, $status = '', $action = '') + { + $productplans = $this->productplan->updateStatus($planID, $status, $action); + if(dao::isError()) return dao::getError(); + return $productplans; + } + + /** + * Update parent status + * + * @param int mixed $parentId + * @access public + * @return bool + */ + public function updateParentStatus($parentId) + { + $productplans = $this->productplan->updateParentStatus($parentId); + if(dao::isError()) return dao::getError(); + return $productplans; + } + + /** + * Batch update + * + * @param int mixed $productId + * @access public + * @return array(array) + */ + 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); + if(dao::isError()) return dao::getError(); + return $productplans; + } + + /** + * Batch change status + * + * @param string mixed $status + * @access public + * @return array + */ + public function batchChangeStatus($status, $planIDList = array('planIDList' => array(4, 5))) + { + $planID = $planIDList; + + 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/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..3d03dc2808 --- /dev/null +++ b/test/model/productplan/batchchangestatus.php @@ -0,0 +1,43 @@ +#!/usr/bin/env php +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'); + +$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 new file mode 100755 index 0000000000..a28ede7e26 --- /dev/null +++ b/test/model/productplan/batchupdate.php @@ -0,0 +1,101 @@ +#!/usr/bin/env php +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(); +$product[0] = 1; +$product[1] = 2; + +$id = array(); +$title = array(); +$begin = array(); +$end = array(); + +$id1 = $id; +$id1[1] = 1; +$id1[2] = 2; +$id1[3] = 3; + +$title1 = $title; +$title1[1] = 'list-1'; +$title1[2] = 'list-2'; +$title1[3] = 'list-3'; + +$begin1 = $begin; +$begin1[1] = '2021-05-10'; +$begin1[2] = '2021-04-12'; +$begin1[3] = '2021-04-01'; + +$end1 = $end; +$end1[1] = '2021-11-30'; +$end1[2] = '2021-10-25'; +$end1[3] = '2021-10-23'; + +$id2 = $id; +$id2[4] = 4; +$id2[5] = 5; +$id2[6] = 6; + +$title2 = $title; +$title2[6] = 'list-6'; +$title2[5] = 'list-5'; +$title2[4] = 'list-4'; + +$begin2 = $begin; +$begin2[6] = '2021-05-10'; +$begin2[5] = '2021-06-12'; +$begin2[4] = '2021-06-01'; + +$end2 = $end; +$end2[6] = '2021-11-30'; +$end2[5] = '2021-11-28'; +$end2[4] = '2021-11-23'; + +$branch1 = array(); +$branch1['id'] = $id1; +$branch1['title'] = $title1; +$branch1['begin'] = $begin1; +$branch1['end'] = $end1; + +$branch2 = array(); +$branch2['id'] = $id2; +$branch2['title'] = $title2; +$branch2['begin'] = $begin2; +$branch2['end'] = $end2; + +$batchUpdate = $plan->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 +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 new file mode 100755 index 0000000000..eeef6ea9f0 --- /dev/null +++ b/test/model/productplan/create.php @@ -0,0 +1,62 @@ +#!/usr/bin/env php +create(); +cid=1 +pid=1 + +测试正常创建 >> 110 +测试不传入名称的情况 >> 『名称』不能为空。 +测试不传开始时间的情况 >> 111 +测试不传结束时间的情况 >> 112 +测试不传开始时间及结束时间的情况 >> 113 +测试不传UID的情况 >> 114 +测试不传关联产品的情况 >> 『产品』应当是数字。 +测试不传父级计划的情况 >> 『父计划』应当是数字。 + +*/ +$plan = new productPlan('admin'); + +$posts = array(); +$posts['title'] = '测试创建1'; +$posts['begin'] = '2021-10-25'; +$posts['end'] = '2021-10-29'; +$posts['uid'] = '623927843dd9b'; +$posts['product'] = '2'; +$posts['parent'] = '0'; + +$noTitle = $posts; +$noTitle['title'] = ''; + +$noBegin = $posts; +$noBegin['begin'] = ''; + +$noEnd = $posts; +$noEnd['end'] = ''; + +$noBeginEnd = $noBegin; +$noBeginEnd['end'] = ''; + +$noUid = $posts; +$noUid['uid'] = ''; + +$noProduct = $posts; +$noProduct['product'] = ''; + +$noParent = $posts; +$noParent['parent'] = ''; + +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 new file mode 100755 index 0000000000..9a00a71959 --- /dev/null +++ b/test/model/productplan/getbranchplanpairs.php @@ -0,0 +1,32 @@ +#!/usr/bin/env php +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-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 41047865e6..7b94582e2d 100755 --- a/test/model/productplan/getbyidlist.php +++ b/test/model/productplan/getbyidlist.php @@ -3,15 +3,28 @@ include dirname(dirname(dirname(__FILE__))) . '/lib/init.php'; include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php'; -$productplan = new Productplan('admin'); +/** + +title=cid=1 +cid=1 +pid=1 + +传入一个数组,取值id为3的数据 >> 3 +传入一个数组,取值id为1的数据 >> 1 +传入一个数值,正常取值 >> 1 +传入一个不存在的值返回布尔值 >> 0 + +*/ + +$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'); //传入一个不存在的值返回布尔值 +?> \ No newline at end of file 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..1f630e5a6b --- /dev/null +++ b/test/model/productplan/getchildren.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +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('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 new file mode 100755 index 0000000000..514d66e573 --- /dev/null +++ b/test/model/productplan/getforproducts.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +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); + +$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 new file mode 100755 index 0000000000..51a243de40 --- /dev/null +++ b/test/model/productplan/getgroupbyproduct.php @@ -0,0 +1,37 @@ +#!/usr/bin/env php +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(); +$products[0] = array(1, 2); +$products[1] = array(2, 10000); +$products[2] = array(9999, 10000); +$param = array(); +$param[0] = 'skipParent'; +$param[1] = 'unexpired'; + +r($plan->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 +?> \ No newline at end of file diff --git a/test/model/productplan/getlast.php b/test/model/productplan/getlast.php index ce1970c467..158aa952fb 100755 --- a/test/model/productplan/getlast.php +++ b/test/model/productplan/getlast.php @@ -3,14 +3,26 @@ include dirname(dirname(dirname(__FILE__))) . '/lib/init.php'; include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php'; -$productplan = new Productplan('admin'); +/** + +title=productpanModel->getLast(); +cid=1 +pid=1 + +获取id为1的最后一个产品 >> 3 +获取id为2的最后一个产品 >> 6 +获取不存在的id返回布尔值 >> 0 + +*/ + +$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返回布尔值 +?> \ No newline at end of file diff --git a/test/model/productplan/getlist.php b/test/model/productplan/getlist.php index 321dd8833b..76bbbd31d9 100755 --- a/test/model/productplan/getlist.php +++ b/test/model/productplan/getlist.php @@ -3,10 +3,25 @@ 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(); -$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'); //返回空数组 -?> +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 98952f86e4..b69d300d8f 100755 --- a/test/model/productplan/getpairs.php +++ b/test/model/productplan/getpairs.php @@ -3,6 +3,27 @@ include dirname(dirname(dirname(__FILE__))) . '/lib/init.php'; include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php'; -$productplan = new Productplan('admin'); +/** -?> +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(); +$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-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 new file mode 100755 index 0000000000..8de61c3710 --- /dev/null +++ b/test/model/productplan/getpairsforstory.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +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); +$branch = array(0, 1); +$param = array('skipParent', 'withMainPlan', 'unexpired'); + +r($plan->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情况 +?> \ No newline at end of file diff --git a/test/model/productplan/getplansbystories.php b/test/model/productplan/getplansbystories.php new file mode 100755 index 0000000000..6f451f23fd --- /dev/null +++ b/test/model/productplan/getplansbystories.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +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 new file mode 100755 index 0000000000..82eedba5a1 --- /dev/null +++ b/test/model/productplan/update.php @@ -0,0 +1,38 @@ +#!/usr/bin/env php +update(); +cid=1 +pid=1 + +修改planId=5的数据,打印出旧的名称 >> 1.1 +二次修改旧的数据,由于数据发生变化,理应失败 >> 0 +测试传入结束时间小于开始时间的情况 >> 父计划[5]的完成日期:2021-10-10,不能小于子计划的完成日期: 2021-10-26 + +*/ +$plan = new productPlan('admin'); + +$planId = array(); +$planId[0] = 5; +$planId[1] = 6; + +$posts = array(); +$posts['title'] = '测试修改'; +$posts['status'] = 'doing'; +$posts['begin'] = '2021-03-22'; +$posts['end'] = '2022-10-31'; +$posts['uid'] = ''; +$posts['product'] = '2'; + +$late = $posts; +$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('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 new file mode 100755 index 0000000000..c9504744b5 --- /dev/null +++ b/test/model/productplan/updateparentstatus.php @@ -0,0 +1,32 @@ +#!/usr/bin/env php +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(); +$parentid[0] = 1; +$parentid[1] = 2; +$parentid[2] = 3; +$parentid[3] = 4; + +#此方法将父级plan状态改为与子plan相同的状态 +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 new file mode 100755 index 0000000000..83474ef0b2 --- /dev/null +++ b/test/model/productplan/updatestatus.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +updateStatus(); +cid=1 +pid=1 + +修改id=5的状态为doing >> 1 +修改状态为done >> 1 +修改状态为closed >> 1 + +*/ +$plan = new productPlan('admin'); + +$planId = array(); +$planId[0] = 5; +$planId[1] = 'doing'; +$planId[2] = 'done'; +$planId[3] = 'closed'; +$planId[4] = 'started'; +$planId[5] = 'finished'; +$planId[6] = 'closed'; +$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