* Add unit test of testcaseModel::getStepGroupByIdList.

This commit is contained in:
liumengyi
2023-09-21 10:56:58 +08:00
parent 3e935cfeef
commit d0c669d84c
3 changed files with 55 additions and 3 deletions
@@ -0,0 +1,26 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/testcase.class.php';
zdTable('case')->config('normalcase')->gen('10');
zdTable('casestep')->config('casestep')->gen('30');
zdTable('user')->gen('1');
su('admin');
/**
title=测试 testcaseModel->getStepGroupByIdList();
cid=1
pid=1
*/
$caseIdList = array('1,2,3', '4,5,6', '7,8,9');
$testcase = new testcaseTest();
r($testcase->getStepGroupByIdListTest($caseIdList[0])) && p() && e('1:4,5,6,7,8,9,10,11,12; 2:13; 3:14;'); // 获取用例 1 2 3 的步骤
r($testcase->getStepGroupByIdListTest($caseIdList[1])) && p() && e('4:15; 5:16; 6:17;'); // 获取用例 4 5 6 的步骤
r($testcase->getStepGroupByIdListTest($caseIdList[2])) && p() && e('7:18; 8:19; 9:20;'); // 获取用例 7 8 9 的步骤
+20 -3
View File
@@ -1674,10 +1674,10 @@ class testcaseTest
* Test get scene menu.
*
* @param int $productID
* @param int $moduleID
* @param int $moduleID
* @param int $startScene
* @param int $branch
* @param int $currentScene
* @param int $branch
* @param int $currentScene
* @param bool $emptyMenu
* @access public
* @return array|string
@@ -1688,4 +1688,21 @@ class testcaseTest
if(dao::isError()) return dao::getError();
return implode(',', $scenes);
}
/**
* 测试分组获取用例的步骤信息。
* Test get steps grouped by case id.
*
* @param string $caseIdList
* @access public
* @return array|string
*/
public function getStepGroupByIdListTest(string $caseIdList): array|string
{
$caseSteps = $this->objectModel->getStepGroupByIdList(explode(',', $caseIdList));
if(dao::isError()) return dao::getError();
$return = '';
foreach($caseSteps as $caseID => $steps) $return .= $caseID . ':' . implode(',', array_keys($steps)) . '; ';
return $return;
}
}
@@ -0,0 +1,9 @@
title: table zt_case
desc: "用例"
author: Mengyi Liu
version: "1.0"
fields:
- field: status
range: 'normal'
- field: version
range: 2,1{1000}