From e8be9060a12d8fb5b13f4b99dc5fb8df7703c447 Mon Sep 17 00:00:00 2001 From: liugang Date: Tue, 11 Nov 2025 02:04:41 +0800 Subject: [PATCH] + [misc] Add unit tests for productZen::getProductList4Kanban() method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- module/product/test/lib/zen.class.php | 18 +++++ .../test/zen/getproductlist4kanban.php | 68 +++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100755 module/product/test/zen/getproductlist4kanban.php diff --git a/module/product/test/lib/zen.class.php b/module/product/test/lib/zen.class.php index fcc2b7af00..25f091c0fe 100644 --- a/module/product/test/lib/zen.class.php +++ b/module/product/test/lib/zen.class.php @@ -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; + } } diff --git a/module/product/test/zen/getproductlist4kanban.php b/module/product/test/zen/getproductlist4kanban.php new file mode 100755 index 0000000000..a9ef05d4c6 --- /dev/null +++ b/module/product/test/zen/getproductlist4kanban.php @@ -0,0 +1,68 @@ +#!/usr/bin/env php + 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'); \ No newline at end of file