From d0c669d84cae9a6e2e90aa1a7628b52869a4a9ae Mon Sep 17 00:00:00 2001 From: liumengyi Date: Thu, 21 Sep 2023 10:56:58 +0800 Subject: [PATCH] * Add unit test of testcaseModel::getStepGroupByIdList. --- .../test/model/getstepgroupbyidlist.php | 26 +++++++++++++++++++ module/testcase/test/testcase.class.php | 23 +++++++++++++--- module/testcase/test/yaml/normalcase.yaml | 9 +++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 module/testcase/test/model/getstepgroupbyidlist.php create mode 100644 module/testcase/test/yaml/normalcase.yaml diff --git a/module/testcase/test/model/getstepgroupbyidlist.php b/module/testcase/test/model/getstepgroupbyidlist.php new file mode 100644 index 0000000000..1165928728 --- /dev/null +++ b/module/testcase/test/model/getstepgroupbyidlist.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +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 的步骤 diff --git a/module/testcase/test/testcase.class.php b/module/testcase/test/testcase.class.php index abb593f3c5..95e48990b9 100755 --- a/module/testcase/test/testcase.class.php +++ b/module/testcase/test/testcase.class.php @@ -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; + } } diff --git a/module/testcase/test/yaml/normalcase.yaml b/module/testcase/test/yaml/normalcase.yaml new file mode 100644 index 0000000000..5ca52465f1 --- /dev/null +++ b/module/testcase/test/yaml/normalcase.yaml @@ -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}