From 21f921ee761402da745d884e4c0614a8881d4b9e Mon Sep 17 00:00:00 2001 From: liyang <“liyang@easycorp.ltd”> Date: Fri, 1 Apr 2022 17:20:59 +0800 Subject: [PATCH 1/2] update data --- test/data/action.yaml | 6 ++--- test/data/execution.yaml | 2 ++ test/data/executionson.yaml | 2 ++ test/data/program.yaml | 14 ++++++++++ test/data/project.yaml | 2 +- test/data/zentao/processor.php | 21 +++++++++++++++ test/data/zt_cron.sql | 22 ++++++++++++++++ test/data/zt_lang.sql | 14 ++++++++++ test/model/my/getactions.php | 21 +++++++++++++++ test/model/my/getcontribute.php | 36 +++++++++++++++++++++++++ test/model/my/getdoingprojects.php | 26 ++++++++++++++++++ test/model/my/getoverview.php | 27 +++++++++++++++++++ test/model/my/getproducts.php | 42 ++++++++++++++++++++++++++++++ test/ztest | 2 ++ 14 files changed, 233 insertions(+), 4 deletions(-) create mode 100644 test/data/zt_cron.sql create mode 100644 test/data/zt_lang.sql create mode 100755 test/model/my/getactions.php create mode 100755 test/model/my/getcontribute.php create mode 100755 test/model/my/getdoingprojects.php create mode 100755 test/model/my/getoverview.php create mode 100755 test/model/my/getproducts.php diff --git a/test/data/action.yaml b/test/data/action.yaml index ee30e86443..6156236d7e 100644 --- a/test/data/action.yaml +++ b/test/data/action.yaml @@ -47,12 +47,12 @@ fields: format: "" - field: date note: "日期" - from: common.date.v1.yaml - use: dateA + range: "(-1M)-(w):1D" + type: timestamp prefix: "" postfix: "" loop: 0 - format: "" + format: "YYYY-MM-DD hh:mm:ss" - field: comment note: "备注" range: 1-100000 diff --git a/test/data/execution.yaml b/test/data/execution.yaml index 0a2ba25a18..94485096bb 100644 --- a/test/data/execution.yaml +++ b/test/data/execution.yaml @@ -17,6 +17,8 @@ fields: range: [] - field: type range: sprint{30},stage{30},kanban{30} + - field: budget + range: 800000-1:100 - field: status range: wait,doing - field: percent diff --git a/test/data/executionson.yaml b/test/data/executionson.yaml index 39a5e92b83..3d0a0abf8b 100644 --- a/test/data/executionson.yaml +++ b/test/data/executionson.yaml @@ -17,6 +17,8 @@ fields: range: [] - field: type range: stage + - field: budget + range: 700000-1:100 - field: status range: wait,doing - field: percent diff --git a/test/data/program.yaml b/test/data/program.yaml index ee09f51582..354ef3f815 100644 --- a/test/data/program.yaml +++ b/test/data/program.yaml @@ -17,6 +17,8 @@ fields: range: 1-10000 - field: type range: program + - field: budget + range: 1000000-1:100 - field: status range: wait - field: parent @@ -42,6 +44,18 @@ fields: prefix: "项目集描述" - field: acl range: open{4},private{4} + - field: PO + range: 1-10 + prefix: "po" + - field: PM + range: 1-10 + prefix: "pm" + - field: QD + range: 1-10 + prefix: "test" + - field: RD + range: 1-10 + prefix: "dev" - field: openedVersion range: "16.5" - field: whitelist diff --git a/test/data/project.yaml b/test/data/project.yaml index b3febc956e..1bfd668804 100644 --- a/test/data/project.yaml +++ b/test/data/project.yaml @@ -22,7 +22,7 @@ fields: - field: lifetime range: - field: budget - range: 0 + range: 900000-1:100 - field: budgetUnit range: CNY,USD - field: attribute diff --git a/test/data/zentao/processor.php b/test/data/zentao/processor.php index e22b9f38e6..a783cd3185 100644 --- a/test/data/zentao/processor.php +++ b/test/data/zentao/processor.php @@ -50,6 +50,7 @@ class Processor $this->initBug(); $this->initTest(); $this->initTodo(); + $this->initBassicSql(); $this->dao->commit(); } @@ -285,6 +286,20 @@ class Processor { } + /** + * init BassicSql. + * + * @access private + * @return void + */ + private function initBassicSql() + { + global $app; + $sqlRoot = $app->getAppRoot(); + $this->dao->exec(file_get_contents($sqlRoot . '/data/zt_lang.sql')); + $this->dao->exec(file_get_contents($sqlRoot . '/data/zt_cron.sql')); + } + /** * Init Stakeholder. * @@ -417,5 +432,11 @@ class Processor $this->dao->query("update zt_kanbancell set `cards` = ',246,' where id = 428"); $this->dao->query("update zt_kanbancell set `cards` = ',184,185,186,' where id = 439"); $this->dao->query("update zt_kanbancell set `cards` = ',62,' where id = 448"); + $this->dao->query("update zt_kanbancell set `cards` = ',247,' where id = 458"); + $this->dao->query("update zt_kanbancell set `cards` = ',187,188,189,' where id = 469"); + $this->dao->query("update zt_kanbancell set `cards` = ',63,' where id = 477"); + $this->dao->query("update zt_kanbancell set `cards` = ',248,' where id = 485"); + $this->dao->query("update zt_kanbancell set `cards` = ',190,191,192,' where id = 496"); + $this->dao->query("update zt_kanbancell set `cards` = ',64,' where id = 504"); } } diff --git a/test/data/zt_cron.sql b/test/data/zt_cron.sql new file mode 100644 index 0000000000..7d85f257b3 --- /dev/null +++ b/test/data/zt_cron.sql @@ -0,0 +1,22 @@ +truncate `zt_cron`; +INSERT INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`, `lastTime`) VALUES +('*', '*', '*', '*', '*', '', '监控定时任务', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('30', '23', '*', '*', '*', 'moduleName=execution&methodName=computeburn', '更新燃尽图', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('0', '8', '*', '*', '*', 'moduleName=report&methodName=remind', '每日任务提醒', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('*/5', '*', '*', '*', '*', 'moduleName=svn&methodName=run', '同步SVN', 'zentao', 1, 'stop', '0000-00-00 00:00:00'), +('*/5', '*', '*', '*', '*', 'moduleName=git&methodName=run', '同步GIT', 'zentao', 1, 'stop', '0000-00-00 00:00:00'), +('30', '0', '*', '*', '*', 'moduleName=backup&methodName=backup', '备份数据和附件', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('*/5', '*', '*', '*', '*', 'moduleName=mail&methodName=asyncSend', '异步发信', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('*/5', '*', '*', '*', '*', 'moduleName=webhook&methodName=asyncSend', '异步发送Webhook', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('*/5', '*', '*', '*', '*', 'moduleName=admin&methodName=deleteLog', '删除过期日志', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('1', '1', '*', '*', '*', 'moduleName=todo&methodName=createCycle', '生成周期性待办', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('1', '0', '*', '*', '*', 'moduleName=ci&methodName=initQueue', '创建周期性任务', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('*/5', '*', '*', '*', '*', 'moduleName=ci&methodName=checkCompileStatus', '同步DevOps构建任务状态', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('*/5', '*', '*', '*', '*', 'moduleName=ci&methodName=exec', '执行DevOps构建任务', 'zentao', 1, 'normal', '0000-00-00 00:00:00'), +('*/5', '*', '*', '*', '*', 'moduleName=mr&methodName=syncMR', '定时同步GitLab合并数据到禅道数据库', 'zentao', 1, 'normal', '0000-00-00 00:00:00'); +INSERT INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`, `lastTime`) VALUES ('30', '23', '*', '*', '*', 'moduleName=execution&methodName=computeTaskEffort', '计算任务剩余工时', 'zentao', '1', 'normal', '0000-00-00 00:00:00'); +INSERT INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`, `lastTime`) VALUES ('30', '7', '*', '*', '*', 'moduleName=effort&methodName=remindNotRecord', '提醒录入日志', 'zentao', '1', 'stop', '0000-00-00 00:00:00'); +REPLACE INTO `zt_cron` (`m`, `h`, `dom`, `mon`, `dow`, `command`, `remark`, `type`, `buildin`, `status`, `lastTime`) VALUES +('1','0','*','*','*','moduleName=weekly&methodName=computeWeekly','更新项目周报','system',0,'normal','2020-08-27 10:07:53'), +('1','0','*','*','*','moduleName=measurement&methodName=initCrontabQueue','初始化度量队列','zentao',0,'normal','2020-07-07 14:51:48'), +('*/5','*','*','*','*','moduleName=measurement&methodName=execCrontabQueue','执行度量队列','zentao',0,'running','2020-07-10 13:10:58'); diff --git a/test/data/zt_lang.sql b/test/data/zt_lang.sql new file mode 100644 index 0000000000..6e4246d6f1 --- /dev/null +++ b/test/data/zt_lang.sql @@ -0,0 +1,14 @@ +truncate `zt_lang`; +REPLACE INTO `zt_lang` (`lang`, `module`, `section`, `key`, `value`, `system`) VALUES +('zh-cn', 'custom', 'URSRList', '1', '{\"SRName\":\"\\u8f6f\\u4ef6\\u9700\\u6c42\",\"URName\":\"\\u7528\\u6237\\u9700\\u6c42\"}', '1'),('zh-cn', 'custom', 'URSRList', '2', '{\"SRName\":\"\\u7814\\u53d1\\u9700\\u6c42\",\"URName\":\"\\u7528\\u6237\\u9700\\u6c42\"}', '1'), +('zh-cn', 'custom', 'URSRList', '3', '{\"SRName\":\"\\u8f6f\\u9700\",\"URName\":\"\\u7528\\u9700\"}', '1'),('zh-cn', 'custom', 'URSRList', '4', '{\"SRName\":\"\\u6545\\u4e8b\",\"URName\":\"\\u53f2\\u8bd7\"}', '1'), +('zh-cn', 'custom', 'URSRList', '5', '{\"SRName\":\"\\u9700\\u6c42\",\"URName\":\"\\u7528\\u6237\\u9700\\u6c42\"}', '1'), +('en', 'custom', 'URSRList', '1', '{\"SRName\":\"Story\",\"URName\":\"Epic\"}', '0'), +('en', 'custom', 'URSRList', '2', '{\"SRName\":\"Software Requirement\",\"URName\":\"User Requirement\"}', '0'), +('all','stage','typeList','request','需求', '1'), +('all','stage','typeList','design','设计', '1'), +('all','stage','typeList','dev','开发', '1'), +('all','stage','typeList','qa','测试', '1'), +('all','stage','typeList','release','发布', '1'), +('all','stage','typeList','review','总结评审','1'), +('all','stage','typeList','other','其他','1'); diff --git a/test/model/my/getactions.php b/test/model/my/getactions.php new file mode 100755 index 0000000000..24979d4067 --- /dev/null +++ b/test/model/my/getactions.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +getActions(); +cid=1 +pid=1 + +正常查询action >> 32,,32,,这是一个系统日志测试备注32 +正常查询action统计 >> 5 + +*/ + +$my = new myTest(); + +r($my->getActionsTest()) && p('0:id,product,comment') && e('32,,32,,这是一个系统日志测试备注32');// 正常查询action +r(count($my->getActionsTest())) && p() && e('5'); // 正常查询action统计 \ No newline at end of file diff --git a/test/model/my/getcontribute.php b/test/model/my/getcontribute.php new file mode 100755 index 0000000000..5b3d727613 --- /dev/null +++ b/test/model/my/getcontribute.php @@ -0,0 +1,36 @@ +#!/usr/bin/env php +getContribute(); +cid=1 +pid=1 + +myTaskTotal数据获取 >> 0 +myStoryTotal数据获取 >> 0 +myBugTotal数据获取 >> 85 +docCreatedTotal数据获取 >> 900 +ownerProductTotal数据获取 >> 0 +involvedProjectTotal数据获取 >> 1 + +*/ + +$my = new myTest(); + +$myTaskTotal = $my->getContributeTest()->myTaskTotal; +$myStoryTotal = $my->getContributeTest()->myStoryTotal; +$myBugTotal = $my->getContributeTest()->myBugTotal; +$docCreatedTotal = $my->getContributeTest()->docCreatedTotal; +$ownerProductTotal = $my->getContributeTest()->ownerProductTotal; +$involvedProjectTotal = $my->getContributeTest()->involvedProjectTotal; + +r($myTaskTotal) && p() && e('0'); //myTaskTotal数据获取 +r($myStoryTotal) && p() && e('0'); //myStoryTotal数据获取 +r($myBugTotal) && p() && e('85'); //myBugTotal数据获取 +r($docCreatedTotal) && p() && e('900');//docCreatedTotal数据获取 +r($ownerProductTotal) && p() && e('0'); //ownerProductTotal数据获取 +r($involvedProjectTotal) && p() && e('1'); //involvedProjectTotal数据获取 \ No newline at end of file diff --git a/test/model/my/getdoingprojects.php b/test/model/my/getdoingprojects.php new file mode 100755 index 0000000000..58b177e372 --- /dev/null +++ b/test/model/my/getdoingprojects.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +getDoingProjects(); +cid=1 +pid=1 + +获取doingcount数据 >> 5 +获取doing状态的项目 >> 项目86,doing +获取doing状态的项目统计 >> 5 + +*/ + +$my = new myTest(); + +$doingCount = $my->getDoingProjectsTest()->doingCount; +$projects = $my->getDoingProjectsTest()->projects; + +r($doingCount) && p() && e('5'); //获取doingcount数据 +r($projects) && p('0:name,status') && e('项目86,doing');//获取doing状态的项目 +r(count($projects)) && p() && e('5'); //获取doing状态的项目统计 \ No newline at end of file diff --git a/test/model/my/getoverview.php b/test/model/my/getoverview.php new file mode 100755 index 0000000000..7f671e60bd --- /dev/null +++ b/test/model/my/getoverview.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +getOverview(); +cid=1 +pid=1 + +projectTotal数据获取 >> 110 +allConsumed数据获取 >> 6750 +thisYearConsumed数据获取 >> 0 + +*/ + +$my = new myTest(); + +$projectTotal = $my->getOverviewTest()->projectTotal; +$allConsumed = $my->getOverviewTest()->allConsumed; +$thisYearConsumed = $my->getOverviewTest()->thisYearConsumed; + +r($projectTotal) && p() && e('110'); //projectTotal数据获取 +r($allConsumed) && p() && e('6750');//allConsumed数据获取 +r($thisYearConsumed) && p() && e('0'); //thisYearConsumed数据获取 \ No newline at end of file diff --git a/test/model/my/getproducts.php b/test/model/my/getproducts.php new file mode 100755 index 0000000000..028b60ccd1 --- /dev/null +++ b/test/model/my/getproducts.php @@ -0,0 +1,42 @@ +#!/usr/bin/env php +getProducts(); +cid=1 +pid=1 + +undone产品allCount查询 >> 80 +undone产品unclosedCount查询 >> 80 +undone产品查询统计 >> 5 +ownbyme产品allCount查询 >> 0 +ownbyme产品unclosedCount查询 >> 0 +ownbyme产品查询 >> 0 +ownbyme产品查询统计 >> 0 +随意输入type产品数量查询 >> 5 +不输入type产品数量查询 >> 5 + +*/ + +$typeList = array('undone', 'ownbyme', 'all'); + +$my = new myTest(); + +$undoneProducts = $my->getProductsTest($typeList[0]); +$ownbymeProducts = $my->getProductsTest($typeList[1]); +$allProducts = $my->getProductsTest($typeList[2]); +$noType = $my->getProductsTest(''); + +r($undoneProducts->allCount) && p() && e('80'); //undone产品allCount查询 +r($undoneProducts->unclosedCount) && p() && e('80'); //undone产品unclosedCount查询 +r(count($undoneProducts->products)) && p() && e('5'); //undone产品查询统计 +r($ownbymeProducts->allCount) && p() && e('0'); //ownbyme产品allCount查询 +r($ownbymeProducts->unclosedCount) && p() && e('0'); //ownbyme产品unclosedCount查询 +r($ownbymeProducts->products) && p() && e('0'); //ownbyme产品查询 +r(count($ownbymeProducts->products)) && p() && e('0'); //ownbyme产品查询统计 +r(count($allProducts->products)) && p() && e('5'); //随意输入type产品数量查询 +r(count($noType->products)) && p() && e('5'); //不输入type产品数量查询 \ No newline at end of file diff --git a/test/ztest b/test/ztest index 0eacb5393e..4ae904ca77 100755 --- a/test/ztest +++ b/test/ztest @@ -57,6 +57,8 @@ switch($argv[1]) break; case 'kanban': ztfRun('model/kanban'); + case 'my': + ztfRun('model/my'); break; case 'model': ztfRun('model'); From 69936fdde5b79fe01a2efe6cfa953ca2eac7cd3b Mon Sep 17 00:00:00 2001 From: liyang <“liyang@easycorp.ltd”> Date: Sat, 2 Apr 2022 09:54:04 +0800 Subject: [PATCH 2/2] add test by my --- test/class/my.class.php | 85 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 test/class/my.class.php diff --git a/test/class/my.class.php b/test/class/my.class.php new file mode 100644 index 0000000000..0a42cf82a3 --- /dev/null +++ b/test/class/my.class.php @@ -0,0 +1,85 @@ +objectModel = $tester->loadModel('my'); + } + + /** + * Function getProducts test by my + * + * @param string $type + * @access public + * @return object + */ + public function getProductsTest($type) + { + $objects = $this->objectModel->getProducts($type); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Function getDoingProjects test by my + * + * @access public + * @return object + */ + public function getDoingProjectsTest() + { + $objects = $this->objectModel->getDoingProjects(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Function getOverview test by my + * + * @access public + * @return object + */ + public function getOverviewTest() + { + $objects = $this->objectModel->getOverview(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Function getContribute test by my + * + * @access public + * @return object + */ + public function getContributeTest() + { + $objects = $this->objectModel->getContribute(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Function getActions test by my + * + * @access public + * @return array + */ + public function getActionsTest() + { + $objects = $this->objectModel->getActions(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } +}