* [misc] Enhance unit tests for actionTao::getReviewRelated() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2044,4 +2044,20 @@ class actionTest
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getReviewRelated method.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getReviewRelatedTest(string $objectType, int $objectID): array
|
||||
{
|
||||
$result = $this->objectTao->getReviewRelated($objectType, $objectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,22 +4,51 @@ declare(strict_types=1);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 actionTao->getReviewRelated().
|
||||
title=测试 actionTao::getReviewRelated();
|
||||
timeout=0
|
||||
cid=1
|
||||
cid=0
|
||||
|
||||
- 测试当objectType为review,objectID为15时,返回的数据是否正确
|
||||
- 第0条的5属性 @5
|
||||
- 属性1 @15
|
||||
- 步骤1:正常review查询project 1,返回第一个和第二个product以及project ID
|
||||
- 第0条的1属性 @1
|
||||
- 第0条的2属性 @2
|
||||
- 属性1 @1
|
||||
- 步骤2:不存在的review对象,返回默认值
|
||||
- 第0条的0属性 @0
|
||||
- 属性1 @0
|
||||
- 步骤3:review存在但project为0,返回默认值
|
||||
- 第0条的0属性 @0
|
||||
- 属性1 @0
|
||||
- 步骤4:review关联project 4,返回products和project ID
|
||||
- 第0条的1属性 @1
|
||||
- 第0条的2属性 @2
|
||||
- 属性1 @4
|
||||
- 步骤5:边界值测试ID为0,返回默认值
|
||||
- 第0条的0属性 @0
|
||||
- 属性1 @0
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/action.unittest.class.php';
|
||||
|
||||
$reviewTable = zenData('review');
|
||||
$reviewTable->id->range('1-20');
|
||||
$reviewTable->title->range('评审1,评审2,评审3{5},评审4{10}');
|
||||
$reviewTable->project->range('1,2,3{3},4{5},0{9}');
|
||||
$reviewTable->status->range('wait,doing,done{18}');
|
||||
$reviewTable->gen(20);
|
||||
|
||||
$projectproductTable = zenData('projectproduct');
|
||||
$projectproductTable->project->range('1{3},2{2},3{4},4{3}');
|
||||
$projectproductTable->product->range('1,2,3,1,2,1,2,3,4,1,2,3');
|
||||
$projectproductTable->gen(12);
|
||||
|
||||
su('admin');
|
||||
|
||||
$actionTest = new actionTest();
|
||||
|
||||
zenData('review')->gen(15);
|
||||
zenData('projectproduct')->gen(20);
|
||||
|
||||
r($actionTest->getReviewRelated('review', 15)) && p('0:5;1') && e('5,15'); //测试当objectType为review,objectID为15时,返回的数据是否正确
|
||||
r($actionTest->getReviewRelatedTest('review', 1)) && p('0:1;0:2;1') && e('1;2;1'); // 步骤1:正常review查询project 1,返回第一个和第二个product以及project ID
|
||||
r($actionTest->getReviewRelatedTest('review', 999)) && p('0:0;1') && e('0;0'); // 步骤2:不存在的review对象,返回默认值
|
||||
r($actionTest->getReviewRelatedTest('review', 16)) && p('0:0;1') && e('0;0'); // 步骤3:review存在但project为0,返回默认值
|
||||
r($actionTest->getReviewRelatedTest('review', 6)) && p('0:1;0:2;1') && e('1;2;4'); // 步骤4:review关联project 4,返回products和project ID
|
||||
r($actionTest->getReviewRelatedTest('review', 0)) && p('0:0;1') && e('0;0'); // 步骤5:边界值测试ID为0,返回默认值
|
||||
Reference in New Issue
Block a user