+ Add case for the processProductPlans method.
This commit is contained in:
@@ -4953,7 +4953,7 @@ class executionModel extends model
|
||||
* Get plan data from the ID list of the product.
|
||||
*
|
||||
* @param array $productID
|
||||
* @param string $param withMainPlan|skipParent
|
||||
* @param string $param withMainPlan|skipParent|unexpired|noclosed
|
||||
* @param int $executionID
|
||||
* @return array
|
||||
*/
|
||||
@@ -5002,11 +5002,11 @@ class executionModel extends model
|
||||
* Process product planning data.
|
||||
*
|
||||
* @param array $plans
|
||||
* @param string $param
|
||||
* @param string $param withmainplan|skipparent
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function processProductPlans(array $plans, string $param): array
|
||||
public function processProductPlans(array $plans, string $param = ''): array
|
||||
{
|
||||
if(strpos($param, 'sortedbydate') !== false)
|
||||
{
|
||||
|
||||
@@ -3128,4 +3128,25 @@ class executionTest
|
||||
|
||||
return $this->executionModel->buildExecutionPairs($mode, $allExecutions, $executions, $parents, $projectPairs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理产品计划的数据。
|
||||
* Process product planning data.
|
||||
*
|
||||
* @param array $productIdList
|
||||
* @param string $param
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function processProductPlansTest(array $productIdList, string $param = ''): array
|
||||
{
|
||||
$plans = $this->executionModel->dao->select('t1.id,t1.title,t1.product,t1.parent,t1.begin,t1.end,t1.branch,t2.type as productType')->from(TABLE_PRODUCTPLAN)->alias('t1')
|
||||
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t2.id=t1.product')
|
||||
->where('t1.product')->in($productIdList)
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->orderBy('t1.begin desc, t1.id desc')
|
||||
->fetchAll('id');
|
||||
|
||||
return $this->executionModel->processProductPlans($plans, $param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/execution.class.php';
|
||||
zdTable('user')->gen(5);
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试executionModel->processProductPlans();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
$productIdList = array(1, 2, 3, 4, 5);
|
||||
$paramList = array('', 'withmainplan', 'skipparent');
|
||||
|
||||
$executionTester = new executionTest();
|
||||
r($executionTester->processProductPlansTest($productIdList, $paramList[0])) && p('5:15') && e('计划15 待定'); // 处理产品的计划信息
|
||||
r($executionTester->processProductPlansTest($productIdList, $paramList[1])) && p('4:10') && e('计划10 待定'); // 处理产品的带主干计划信息
|
||||
r($executionTester->processProductPlansTest($productIdList, $paramList[2])) && p('2:5') && e('计划5 待定'); // 处理产品的非父计划信息
|
||||
r(count($executionTester->processProductPlansTest($productIdList, $paramList[0]))) && p() && e('5'); // 处理产品的计划数量
|
||||
r(count($executionTester->processProductPlansTest($productIdList, $paramList[1]))) && p() && e('5'); // 处理产品的带主干计划数量
|
||||
r(count($executionTester->processProductPlansTest($productIdList, $paramList[2]))) && p() && e('5'); // 处理产品的非父计划数量
|
||||
Reference in New Issue
Block a user