add unittest productplan and new productsunplan.yaml
This commit is contained in:
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$plan = new productPlan('admin');
|
||||
|
||||
var_dump($plan->batchChangeStatus(2));die;
|
||||
?>
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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-10-31';
|
||||
$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-10-31';
|
||||
$end2[5] = '2021-10-25';
|
||||
$end2[4] = '2021-10-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
|
||||
?>
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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('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'); //测试不传父级计划的情况
|
||||
?>
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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[1], $branch[1])) && p('1:31') && e('0'); //传入不存在的分支
|
||||
r($plan->getBranchPlanPairs($product[2], $branch[2])) && p('1:31') && e('0'); //传入不存在的产品id
|
||||
?>
|
||||
@@ -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'); //传入一个不存在的值返回布尔值
|
||||
?>
|
||||
|
||||
@@ -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'); //如不存在,返回布尔值
|
||||
?>
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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'); //这里统计不存在的情况
|
||||
?>
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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数组,应为空
|
||||
?>
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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
|
||||
?>
|
||||
@@ -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返回布尔值
|
||||
?>
|
||||
|
||||
@@ -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'); //查询
|
||||
?>
|
||||
|
||||
@@ -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
|
||||
?>
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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情况
|
||||
?>
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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
|
||||
?>
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$plan = new productPlan('admin');
|
||||
|
||||
$planId = array();
|
||||
$planId[0] = 5;
|
||||
$planId[1] = 6;
|
||||
|
||||
$posts = array();
|
||||
$posts['title'] = '测试修改';
|
||||
$posts['status'] = 'doing';
|
||||
$posts['begin'] = '2022-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() && e('0'); //测试传入结束时间小于开始时间的情况
|
||||
?>
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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('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状态
|
||||
?>
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(dirname(dirname(__FILE__))) . '/lib/init.php';
|
||||
include dirname(dirname(dirname(__FILE__))) . '/class/productplan.class.php';
|
||||
|
||||
$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
|
||||
?>
|
||||
Reference in New Issue
Block a user