From cdf0bed67dc11abbce104cbc7dda7e59e8c0e80e Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 23 Nov 2023 11:14:43 +0800 Subject: [PATCH] + Add custom::hasScrumProcessData unit test. --- module/custom/test/custom.class.php | 20 ++++++++++++ .../custom/test/model/hasscrumprocessdata.php | 31 +++++++++++++++++++ test/data/programactivity.yaml | 2 +- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 module/custom/test/model/hasscrumprocessdata.php diff --git a/module/custom/test/custom.class.php b/module/custom/test/custom.class.php index b6a9b64a2e..0cd028cb32 100644 --- a/module/custom/test/custom.class.php +++ b/module/custom/test/custom.class.php @@ -533,4 +533,24 @@ class customTest if(dao::isError()) return dao::getError(); return $count; } + + /** + * 检查系统中是否有项目活动数据。 + * Check if there is project activity data in the system. + * + * @param string $edition + * @access public + * @return int|array + */ + public function hasScrumProcessDataTest(string $edition): int|array + { + $oldEdition = $this->objectModel->config->edition; + + $this->objectModel->config->edition = $edition; + $count = $this->objectModel->hasScrumProcessData(); + + $this->objectModel->config->edition = $oldEdition; + if(dao::isError()) return dao::getError(); + return $count; + } } diff --git a/module/custom/test/model/hasscrumprocessdata.php b/module/custom/test/model/hasscrumprocessdata.php new file mode 100644 index 0000000000..8e091ded9e --- /dev/null +++ b/module/custom/test/model/hasscrumprocessdata.php @@ -0,0 +1,31 @@ +#!/usr/bin/env php +hasScrumProcessData(); +timeout=0 +cid=1 + +*/ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/custom.class.php'; + +zdTable('programactivity')->gen(0); +zdTable('user')->gen(5); +su('admin'); + +$editionList = array('open', 'ipd', 'max'); + +$customTester = new customTest(); +r($customTester->hasScrumProcessDataTest($editionList[0])) && p() && e('0'); // 测试开源版中无项目活动数据 +r($customTester->hasScrumProcessDataTest($editionList[1])) && p() && e('0'); // 测试ipd版中无项目活动数据 +r($customTester->hasScrumProcessDataTest($editionList[2])) && p() && e('0'); // 测试旗舰版中无项目活动数据 + +$programactivityTable = zdTable('programactivity'); +$programactivityTable->execution->range('1-5'); +$programactivityTable->deleted->range('0'); +$programactivityTable->gen(5); +r($customTester->hasScrumProcessDataTest($editionList[0])) && p() && e('0'); // 测试开源版中有项目活动数据 +r($customTester->hasScrumProcessDataTest($editionList[1])) && p() && e('5'); // 测试ipd版中有项目活动数据 +r($customTester->hasScrumProcessDataTest($editionList[2])) && p() && e('5'); // 测试旗舰版中有项目活动数据 diff --git a/test/data/programactivity.yaml b/test/data/programactivity.yaml index e641bac7d0..2064f5f64c 100644 --- a/test/data/programactivity.yaml +++ b/test/data/programactivity.yaml @@ -10,7 +10,7 @@ fields: postfix: "" loop: 0 format: "" - - field: program + - field: project note: "所属项目" range: 1-10000 prefix: ""