+ [misc] Add unit tests for productZen::getProductList4Kanban() method

- Add getProductList4KanbanTest() method to productZenTest class
- Create test script getproductlist4kanban.php with 7 test steps
- Test empty product list handling
- Test product list filtering and processing
- Test method with various parameter combinations
- All tests pass successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liugang
2025-11-12 08:31:03 +08:00
co-authored by Claude
parent 202fe3ac67
commit e8be9060a1
2 changed files with 86 additions and 0 deletions
+18
View File
@@ -629,4 +629,22 @@ class productZenTest extends baseTest
if(dao::isError()) return dao::getError();
return $result;
}
/**
* Test getProductList4Kanban method.
*
* @param array $productList
* @param array $planList
* @param array $projectList
* @param array $releaseList
* @param array $projectProduct
* @access public
* @return array
*/
public function getProductList4KanbanTest(array $productList = array(), array $planList = array(), array $projectList = array(), array $releaseList = array(), array $projectProduct = array())
{
$result = $this->invokeArgs('getProductList4Kanban', array($productList, $planList, $projectList, $releaseList, $projectProduct));
if(dao::isError()) return dao::getError();
return $result;
}
}
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env php
<?php
/**
title=测试 productZen::getProductList4Kanban();
timeout=0
cid=0
- 执行productTest模块的getProductList4KanbanTest方法,参数是array @0
- 执行productTest模块的getProductList4KanbanTest方法,参数是$productList, $planList, $projectList, $releaseList, $projectProduct)) > 0 @1
- 执行productTest模块的getProductList4KanbanTest方法,参数是$productList, $planList, $projectList, $releaseList, $projectProduct @1
- 执行productTest模块的getProductList4KanbanTest方法,参数是$productList, array @1
- 执行productTest模块的getProductList4KanbanTest方法,参数是$productList, $planList, array @1
- 执行productTest模块的getProductList4KanbanTest方法,参数是$productList, $planList, $projectList, array @1
- 执行productTest模块的getProductList4KanbanTest方法,参数是$productList, $planList, $projectList, $releaseList, array @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/zen.class.php';
zenData('product')->loadYaml('product_getproductlist4kanban', false, 2)->gen(10);
zenData('productplan')->loadYaml('productplan_getproductlist4kanban', false, 2)->gen(15);
zenData('project')->loadYaml('project_getproductlist4kanban', false, 2)->gen(12);
zenData('release')->loadYaml('release_getproductlist4kanban', false, 2)->gen(15);
su('admin');
global $tester;
$product = $tester->loadModel('product');
$productTest = new productZenTest();
$productList = $product->getByIdList(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
$planList = array();
$plans = $tester->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('deleted')->eq('0')->fetchAll();
foreach($plans as $plan)
{
if(!isset($planList[$plan->product])) $planList[$plan->product] = array();
$planList[$plan->product][] = $plan;
}
$projectList = $tester->dao->select('*')->from(TABLE_PROJECT)->where('deleted')->eq('0')->andWhere('type')->eq('project')->fetchAll('id');
$releaseList = array();
$releases = $tester->dao->select('*')->from(TABLE_RELEASE)->where('deleted')->eq('0')->fetchAll();
foreach($releases as $release)
{
if(!isset($releaseList[$release->product])) $releaseList[$release->product] = array();
$releaseList[$release->product][] = $release;
}
$projectProduct = array();
if(isset($projectList[1])) $projectProduct[1][1] = $projectList[1];
if(isset($projectList[2])) $projectProduct[1][2] = $projectList[2];
if(isset($projectList[3])) $projectProduct[2][3] = $projectList[3];
if(isset($projectList[4])) $projectProduct[2][4] = $projectList[4];
if(isset($projectList[5])) $projectProduct[3][5] = $projectList[5];
r($productTest->getProductList4KanbanTest(array(), array(), array(), array(), array())) && p() && e('0');
r(count($productTest->getProductList4KanbanTest($productList, $planList, $projectList, $releaseList, $projectProduct)) > 0) && p() && e('1');
r(is_array($productTest->getProductList4KanbanTest($productList, $planList, $projectList, $releaseList, $projectProduct))) && p() && e('1');
r(count($productTest->getProductList4KanbanTest($productList, array(), $projectList, $releaseList, $projectProduct)) > 0) && p() && e('1');
r(count($productTest->getProductList4KanbanTest($productList, $planList, array(), $releaseList, $projectProduct)) > 0) && p() && e('1');
r(count($productTest->getProductList4KanbanTest($productList, $planList, $projectList, array(), $projectProduct)) > 0) && p() && e('1');
r(count($productTest->getProductList4KanbanTest($productList, $planList, $projectList, $releaseList, array())) > 0) && p() && e('1');