add unittest productplan and new productsunplan.yaml
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
class Productplan
|
||||
class productPlan
|
||||
{
|
||||
public function __construct($user)
|
||||
{
|
||||
@@ -62,18 +62,205 @@ class Productplan
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -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: <div>
|
||||
<p>asdxxxfa阿萨德开机as家世界发卡机发设计费啥登记卡设计费卡加斯加附件阿峰</p>
|
||||
<p>123a阿士大夫姐姐姐经历过反对派呸呸呸史蒂夫接收到付款纪委第三方乐山大佛量减少地方</p>
|
||||
<p>IU风格就叫阿萨德奥斯丁哦IG是DAU发加速度快哦哦阿萨德几年内发,,,奥斯丁,,,切,,,请问加十多年你</p>
|
||||
<p>IUIG是DAU发加速度快哦哦阿萨德几年内发,,,奥斯丁,,,切,,,请问加十多年你</p>
|
||||
<p>IU风格就叫阿萨德奥斯丁哦IG是DAU,,,奥斯丁,,,切,,,请问加十多年你</p>
|
||||
</div>
|
||||
- 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
|
||||
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