+ Add case for getProjectProductList method.

This commit is contained in:
tianshujie
2023-09-20 14:48:29 +08:00
parent 23f881d35a
commit 770bbff792
2 changed files with 41 additions and 0 deletions
+15
View File
@@ -1121,4 +1121,19 @@ class productTest
return str_replace('%', '%%', $this->objectModel->summary($stories, $type));
}
/**
* 获取产品与项目关联的项目集数据列表。
* Get the progam info of the releated project and product by product list.
*
* @param array $productIdList
* @access public
* @return array
*/
public function getProjectProductListTest(array $productIdList): array
{
$productList = $this->objectModel->getByIdList($productIdList);
return $this->objectModel->getProjectProductList($productList);
}
}
@@ -0,0 +1,26 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/product.class.php';
zdTable('user')->gen(5);
zdTable('project')->config('program')->gen(30);
zdTable('projectproduct')->config('projectproduct')->gen(30);
su('admin');
/**
title=productTao->getProjectCountPairs();
timeout=0
cid=1
*/
$productIdList[0] = array();
$productIdList[1] = range(1, 10);
$productIdList[2] = range(11, 20);
$productTester = new productTest();
r($productTester->getProjectProductListTest($productIdList[0])) && p() && e('0'); // 测试传入空的产品ID列表
r($productTester->getProjectProductListTest($productIdList[1])) && p('1:name') && e('~~'); // 测试传入产品ID列表
r($productTester->getProjectProductListTest($productIdList[2])) && p() && e('0'); // 测试传入不存在的产品ID列表