From 82cf537cdab2da77f3ab08401fb7dbf2df3f73f7 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Tue, 17 Dec 2024 09:29:13 +0800 Subject: [PATCH] + [task#134153,doing,0.5h] add testcaseTao::doCreateSpec. --- module/testcase/tao.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/module/testcase/tao.php b/module/testcase/tao.php index 1770e0eb1c..0bc6d27a3f 100644 --- a/module/testcase/tao.php +++ b/module/testcase/tao.php @@ -360,6 +360,30 @@ class testcaseTao extends testcaseModel return !dao::isError(); } + /** + * 创建一个测试用例名称和前置条件。 + * Create a test case spec. + * + * @param int $caseID + * @param object $case + * @param array|string $files + * @access protected + * @return void + */ + protected function doCreateSpec(int $caseID, object $case, array|string $files = array()): void + { + if(empty($caseID)) return; + + $spec = new stdclass(); + $spec->case = $caseID; + $spec->version = zget($case, 'version', 1); + $spec->title = $case->title; + $spec->precondition = $case->precondition; + $spec->files = is_string($files) ? $files : implode(',', array_keys($files)); + + $this->dao->insert(TABLE_CASESPEC)->data($spec)->exec(); + } + /** * 更新一个测试用例。 * Update a test case.