From ced51cef650af5741949ec9ba2e88c21f0b3ef17 Mon Sep 17 00:00:00 2001 From: wangxuepeng Date: Mon, 4 Sep 2023 08:49:54 +0000 Subject: [PATCH] * Add New unit testing module, method deletecasebysuiteid. --- module/testsuite/model.php | 2 +- .../test/model/deletecasebysuiteid.php | 24 +++++++++++++++++++ .../testsuite/test/model/deletesuitesbyid.php | 2 +- module/testsuite/test/model/update.php | 12 +++++----- module/testsuite/test/testsuite.class.php | 14 +++++++++++ 5 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 module/testsuite/test/model/deletecasebysuiteid.php diff --git a/module/testsuite/model.php b/module/testsuite/model.php index e96f26b332..3af158e9e0 100644 --- a/module/testsuite/model.php +++ b/module/testsuite/model.php @@ -415,6 +415,6 @@ class testsuiteModel extends model */ public function deleteCaseBySuiteID(array $cases, int $suiteID) { - $this->dao->delete()->from(TABLE_SUITECASE)->where('`case`')->in($cases)->andWhere('`suite`')->eq($suiteID)->exec(); + return $this->dao->delete()->from(TABLE_SUITECASE)->where('`case`')->in($cases)->andWhere('`suite`')->eq($suiteID)->exec(); } } diff --git a/module/testsuite/test/model/deletecasebysuiteid.php b/module/testsuite/test/model/deletecasebysuiteid.php new file mode 100644 index 0000000000..acd0c6fac1 --- /dev/null +++ b/module/testsuite/test/model/deletecasebysuiteid.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +gen(3); +zdTable('testsuite')->gen(1); + +/** + +title=测试 testsuiteModel->deleteCaseBySuiteIDTest(); +cid=1 +pid=1 + +测试suiteID值为1,$cases=array(1, 2) >> 2 + +*/ +$suiteID = 1; +$cases = array(1, 2); + +$testsuite = new testsuiteTest(); + +r($testsuite->deleteCaseBySuiteIDTest($cases, $suiteID)) && p() && e('2'); //测试suiteID值为1 diff --git a/module/testsuite/test/model/deletesuitesbyid.php b/module/testsuite/test/model/deletesuitesbyid.php index 5dc9935081..96ffdf40ba 100755 --- a/module/testsuite/test/model/deletesuitesbyid.php +++ b/module/testsuite/test/model/deletesuitesbyid.php @@ -8,7 +8,7 @@ zdTable('testsuite')->gen(1); /** -title=测试 testsuiteModel->delete(); +title=测试 testsuiteModel->deleteSuiteByID(); cid=1 pid=1 diff --git a/module/testsuite/test/model/update.php b/module/testsuite/test/model/update.php index 4eca33aaf9..5118b6459e 100755 --- a/module/testsuite/test/model/update.php +++ b/module/testsuite/test/model/update.php @@ -12,17 +12,17 @@ cid=1 pid=1 测试productID为1,name正常存在,type为private >> type,public,private -测试productID为1,name为空,type为private >> 『名称』不能为空。 +测试productID为1,name为空,type为private >> 『套件名称』不能为空。 测试productID为1,name正常存在,type为public >> type,private,public -测试productID为1,name为空,type为public >> 『名称』不能为空。 +测试productID为1,name为空,type为public >> 『套件名称』不能为空。 测试productID为1,name正常存在,type为空 >> type,public, -测试productID为1,name为空,type为空 >> 『名称』不能为空。 +测试productID为1,name为空,type为空 >> 『套件名称』不能为空。 测试productID为0,name正常存在,type为private >> 0 -测试productID为0,name为空,type为private >> 『名称』不能为空。 +测试productID为0,name为空,type为private >> 『套件名称』不能为空。 测试productID为0,name正常存在,type为public >> 0 -测试productID为0,name为空,type为public >> 『名称』不能为空。 +测试productID为0,name为空,type为public >> 『套件名称』不能为空。 测试productID为0,name正常存在,type为空 >> 0 -测试productID为0,name为空,type为空 >> 『名称』不能为空。 +测试productID为0,name为空,type为空 >> 『套件名称』不能为空。 */ $productID = array(1, 0); diff --git a/module/testsuite/test/testsuite.class.php b/module/testsuite/test/testsuite.class.php index 0bc68d4181..63cb164882 100644 --- a/module/testsuite/test/testsuite.class.php +++ b/module/testsuite/test/testsuite.class.php @@ -245,4 +245,18 @@ class testsuiteTest if(dao::isError()) return dao::getError(); return $isClickable ? 1 : 0; } + + /** + * 测试根据套件id删除关联的用例。 + * Test delete case by suiteID. + * + * @param int $cases + * @param int $suiteID + * @access public + * @return void + */ + public function deleteCaseBySuiteIDTest($cases, $suiteID) + { + return $this->objectModel->deleteCaseBySuiteID($cases, $suiteID); + } }