From 717aad17981d4ae095f35be9eef9dba9ffc71f12 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 6 May 2022 14:29:23 +0800 Subject: [PATCH 01/41] * Finish pipeline test. --- test/class/pipeline.class.php | 124 +++++++++++++++++++++++++++++++ test/model/pipeline/create.php | 39 ++++++++++ test/model/pipeline/delete.php | 19 +++++ test/model/pipeline/getbyid.php | 20 +++++ test/model/pipeline/getlist.php | 26 +++++++ test/model/pipeline/getpairs.php | 23 ++++++ test/model/pipeline/update.php | 34 +++++++++ test/ztest | 4 + 8 files changed, 289 insertions(+) create mode 100644 test/class/pipeline.class.php create mode 100644 test/model/pipeline/create.php create mode 100644 test/model/pipeline/delete.php create mode 100644 test/model/pipeline/getbyid.php create mode 100644 test/model/pipeline/getlist.php create mode 100644 test/model/pipeline/getpairs.php create mode 100644 test/model/pipeline/update.php diff --git a/test/class/pipeline.class.php b/test/class/pipeline.class.php new file mode 100644 index 0000000000..55177da77a --- /dev/null +++ b/test/class/pipeline.class.php @@ -0,0 +1,124 @@ +objectModel = $tester->loadModel('pipeline'); + } + + /** + * Get a pipeline by id. + * + * @param int $id + * @access public + * @return object + */ + public function getByIDTest($id) + { + $objects = $this->objectModel->getByID($id); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Get pipeline list. + * + * @param string $type jenkins|gitlab + * @param string $orderBy + * @param object $pager + * @access public + * @return array + */ + public function getListTest($type = 'jenkins', $orderBy = 'id_desc', $pager = null) + { + $objects = $this->objectModel->getList($type, $orderBy, $pager); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Get pipeline pairs + * + * @return array + */ + public function getPairs($data) + { + $objects = $this->objectModel->getPairs($data['type']); + + if(empty($objects)) return '没有获取到数据'; + if(isset($data['id'])) return $objects[$data['id']]; + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Create a pipeline. + * + * @access public + * @return bool + */ + public function createTest($type, $param) + { + foreach($param as $k => $v) $_POST[$k] = $v; + $objects = $this->objectModel->create($type); + unset($_POST); + + if(dao::isError()) return dao::getError(); + + $objects = $this->objectModel->getById($objects); + + return $objects; + } + + /** + * Update a pipeline. + * + * @param int $id + * @access public + * @return bool + */ + public function updateTest($id) + { + $objects = $this->objectModel->update($id); + + if(dao::isError()) return dao::getError(); + + $objects = $this->objectModel->getByID($id); + + return $objects; + } + + /** + * Delete one record. + * + * @param string $id the id to be deleted + * @param string $object the action object + * @access public + * @return int + */ + public function deleteTest($id, $object = 'gitlab') + { + $objects = $this->objectModel->delete($id, $object = 'gitlab'); + + if(dao::isError()) return dao::getError(); + + $objects = $this->objectModel->getById($id); + + return $objects; + } +} diff --git a/test/model/pipeline/create.php b/test/model/pipeline/create.php new file mode 100644 index 0000000000..110eefd069 --- /dev/null +++ b/test/model/pipeline/create.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +create(); +cid=1 +pid=1 + +*/ + +$pipeline = new pipelineTest(); + +$data = new stdClass(); +$data->name = 'Jenkins'; +$data->url = 'http://www.zentaopms.com/'; +$data->account = 'JenkinsAccount'; +$data->token = 'Jenkins'; +$data->password = 'Jenkins'; + +$result1 = $pipeline->createTest('Jenkins', $data); //获取添加的name +$result2 = $pipeline->createTest('Jenkins', $data); //获取添加的account + +$data->url = 'error url'; +$result3 = $pipeline->createTest('Jenkins', $data); //添加错误的url信息 + +$data->url = 'http://www.zentaopms.com/'; +$data->name = ''; +$result4 = $pipeline->createTest('Jenkins', $data); //添加名称为空时 + +r($result1) && p('type') && e('Jenkins'); //获取添加的type +r($result2) && p('account') && e('JenkinsAccount'); //获取添加的account +r($result3) && p('url:0') && e('『服务地址』应当为合法的URL。'); //添加错误的url信息 +r($result4) && p('name:0') && e('『名称』不能为空'); //添加名称为空时 + +system('./ztest init'); diff --git a/test/model/pipeline/delete.php b/test/model/pipeline/delete.php new file mode 100644 index 0000000000..39f07ef34d --- /dev/null +++ b/test/model/pipeline/delete.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +delete(); +cid=1 +pid=1 + +*/ + +$pipeline = new pipelineTest(); + +r($pipeline->deleteTest(1)) && p('deleted') && e('1'); //测试删除之后deleted值是否为1 + +system('./ztest init'); diff --git a/test/model/pipeline/getbyid.php b/test/model/pipeline/getbyid.php new file mode 100644 index 0000000000..06d1cc2de7 --- /dev/null +++ b/test/model/pipeline/getbyid.php @@ -0,0 +1,20 @@ +#!/usr/bin/env php +getByID(); +cid=1 +pid=1 + +*/ + +$IDList = array('1','0'); + +$pipeline = new pipelineTest(); + +r($pipeline->getByIDTest($IDList[0])) && p('name') && e('gitlab服务器'); //获取id为1的name字段值 +r($pipeline->getByIDTest($IDList[1])) && p() && e(); //获取id为不存在的数据 diff --git a/test/model/pipeline/getlist.php b/test/model/pipeline/getlist.php new file mode 100644 index 0000000000..d2c06bc3a7 --- /dev/null +++ b/test/model/pipeline/getlist.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +getList(); +cid=1 +pid=1 + +*/ + +global $tester; +$pipeline = new pipelineTest(); +$tester->app->loadClass('pager', $static = true); + +$pager = new pager(0, 10, 1); + +$gitlabList = $pipeline->getListTest('gitlab', 'id_desc', $pager); +$sonarqubeList = $pipeline->getListTest('sonarqube ', 'id_desc', $pager); + +r($gitlabList) && p('1:name') && e('gitlab服务器'); //获取第一页第一条数据的name +r(count($gitlabList)) && p() && e('1'); //统计所有type为gitlab的数量 +r(count($sonarqubeList)) && p() && e('1'); //统计所有type为sonarqube的数据量 diff --git a/test/model/pipeline/getpairs.php b/test/model/pipeline/getpairs.php new file mode 100644 index 0000000000..8b67e1040a --- /dev/null +++ b/test/model/pipeline/getpairs.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +getPairs(); +cid=1 +pid=1 + +*/ + +$pipeline = new pipelineTest(); + +$data[0] = array('type' => 'gitlab', 'id' => 1); +$data[1] = array('type' => 'sonarqube', 'id' => 2); +$data[2] = array('type' => 'testType'); + +r($pipeline->getPairs($data[0])) && p() && e('gitlab服务器'); //id为1且type为gitlab的pipeline名称 +r($pipeline->getPairs($data[1])) && p() && e('sonarqube服务器'); //id为2且type为sonarqube的pipeline名称 +r($pipeline->getPairs($data[2])) && p() && e('没有获取到数据'); //获取不存在的type diff --git a/test/model/pipeline/update.php b/test/model/pipeline/update.php new file mode 100644 index 0000000000..5524297701 --- /dev/null +++ b/test/model/pipeline/update.php @@ -0,0 +1,34 @@ +#!/usr/bin/env php +update(); +cid=1 +pid=1 + +*/ + +$pipeline = new pipelineTest(); + +$_POST['name'] = '测试修改gitlab服务器名称'; +$_POST['url'] = 'http://www.zentaopms.com/upgrade.php'; +$result1 = $pipeline->updateTest(1); + +$_POST['name'] = ''; +$result2 = $pipeline->updateTest(1); + +$_POST['name'] = '测试修改gitlab服务器名称'; +$_POST['url'] = ''; +$result3 = $pipeline->updateTest(1); + +unset($_POST); + +r($result1) && p('name') && e('测试修改gitlab服务器名称'); //获取修改后的name值 +r($result2) && p('name:0') && e('『名称』不能为空。'); //当名称为空时 +r($result3) && p('url:0') && e('『服务地址』不能为空。'); //url为空时 + +system('./ztest init'); diff --git a/test/ztest b/test/ztest index 61374a132c..d94f20d70c 100755 --- a/test/ztest +++ b/test/ztest @@ -85,6 +85,9 @@ switch($argv[1]) case 'project': ztfRun('model/project'); break; + case 'pipeline': + ztfRun('model/pipeline'); + break; case 'report': ztfRun('model/report'); break; @@ -113,6 +116,7 @@ switch($argv[1]) ztfRun('model/user'); break; + default: ztfExtract($argv[1]); system("php " . $argv[1]); From 7877570cf549792b0d1f78f1334b0ecdb933f1bf Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 6 May 2022 14:32:25 +0800 Subject: [PATCH 02/41] * Fix pipeline format. --- test/class/pipeline.class.php | 8 +++----- test/ztest | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/test/class/pipeline.class.php b/test/class/pipeline.class.php index 55177da77a..2bb604620e 100644 --- a/test/class/pipeline.class.php +++ b/test/class/pipeline.class.php @@ -1,7 +1,6 @@ objectModel = $tester->loadModel('pipeline'); + global $tester; + + $this->objectModel = $tester->loadModel('pipeline'); } /** diff --git a/test/ztest b/test/ztest index d94f20d70c..be138795ab 100755 --- a/test/ztest +++ b/test/ztest @@ -116,7 +116,6 @@ switch($argv[1]) ztfRun('model/user'); break; - default: ztfExtract($argv[1]); system("php " . $argv[1]); From d1ebd380160d097d3ac52aa2784faa26b185a828 Mon Sep 17 00:00:00 2001 From: zhouxin Date: Fri, 6 May 2022 09:19:37 +0000 Subject: [PATCH 03/41] * Add tsetcase for holiday. --- module/holiday/model.php | 4 +- test/class/holiday.class.php | 280 ++++++++++++++++++++ test/model/holiday/create.php | 31 +++ test/model/holiday/getactualworkingdays.php | 23 ++ test/model/holiday/getbyid.php | 21 ++ test/model/holiday/getdaysbetween.php | 21 ++ test/model/holiday/getyearpairs.php | 17 ++ test/model/holiday/isholiday.php | 22 ++ test/model/holiday/update.php | 35 +++ 9 files changed, 453 insertions(+), 1 deletion(-) create mode 100644 test/class/holiday.class.php create mode 100755 test/model/holiday/create.php create mode 100755 test/model/holiday/getactualworkingdays.php create mode 100755 test/model/holiday/getbyid.php create mode 100755 test/model/holiday/getdaysbetween.php create mode 100755 test/model/holiday/getyearpairs.php create mode 100755 test/model/holiday/isholiday.php create mode 100755 test/model/holiday/update.php diff --git a/module/holiday/model.php b/module/holiday/model.php index 943110a11e..f106024f6f 100644 --- a/module/holiday/model.php +++ b/module/holiday/model.php @@ -74,6 +74,8 @@ class holidayModel extends model ->batchCheck($this->config->holiday->require->create, 'notempty') ->check('end', 'ge', $holiday->begin) ->exec(); + $lastInsertID = $this->dao->lastInsertID(); + if(dao::isError()) return false; $beginDate = $this->post->begin; @@ -87,7 +89,7 @@ class holidayModel extends model $this->updateTaskPlanDuration($beginDate, $endDate); $this->updateTaskRealDuration($beginDate, $endDate); - return $this->dao->lastInsertID(); + return $lastInsertID; } /** diff --git a/test/class/holiday.class.php b/test/class/holiday.class.php new file mode 100644 index 0000000000..d3c59768ae --- /dev/null +++ b/test/class/holiday.class.php @@ -0,0 +1,280 @@ +objectModel = $tester->loadModel('holiday'); + } + + /** + * Test getById method. + * + * @param string $id + * @access public + * @return object + */ + public function getByIdTest($id) + { + $objects = $this->objectModel->getById($id); + + if($objects === false) return 'Object not found'; + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test getList method. + * + * @param string $year + * @param string $type + * @access public + * @return object + */ + public function getListTest($year = '', $type = 'all') + { + $objects = $this->objectModel->getList($year = '', $type = 'all'); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test getYearPairs method. + * + * @access public + * @return int + */ + public function getYearPairsTest() + { + $objects = $this->objectModel->getYearPairs(); + + if(dao::isError()) return dao::getError(); + + return count($objects); + } + + /** + * Test create method. + * + * @param array $param + * @access public + * @return object + */ + public function createTest($param = array()) + { + $defaultParam['type'] = 'holiday'; + $defaultParam['begin'] = '2022-01-01'; + $defaultParam['end'] = '2022-02-01'; + $defaultParam['name'] = '测试创建holiday'; + $defaultParam['desc'] = '默认的holiday'; + + foreach($defaultParam as $field => $defaultValue) $_POST[$field] = $defaultValue; + + foreach($param as $key => $value) $_POST[$key] = $value; + $lastInsertID = $this->objectModel->create(); + unset($_POST); + + if(dao::isError()) + { + return dao::getError(); + } + else + { + $object = $this->objectModel->getByID($lastInsertID); + return $object; + } + } + + /** + * Test update method. + * + * @param int $holidayID + * @param array $param + * @access public + * @return object + */ + public function updateTest($holidayID, $param = array()) + { + global $tester; + $object = $tester->dbh->query("SELECT * FROM " . TABLE_HOLIDAY ." WHERE id = $holidayID")->fetch(); + + foreach($object as $field => $value) + { + if(in_array($field, array_keys($param))) + { + $_POST[$field] = $param[$field]; + } + else + { + $_POST[$field] = $value; + } + } + + $noError = $this->objectModel->update($bugID); + unset($_POST); + + if(dao::isError()) + { + return dao::getError(); + } + else + { + return 'true'; + } + } + + /** + * Test getHolidays method. + * + * @param string $begin + * @param string $end + * @access public + * @return object + */ + public function getHolidaysTest($begin, $end) + { + $objects = $this->objectModel->getHolidays($begin, $end); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getWorkingDaysTest($begin, $end) + { + $objects = $this->objectModel->getWorkingDays($begin, $end); + + if(dao::isError()) return dao::getError(); + + return count($objects); + } + + public function getActualWorkingDaysTest($begin, $end) + { + $objects = $this->objectModel->getActualWorkingDays($begin, $end); + + if(dao::isError()) return dao::getError(); + + return count($objects); + } + + /** + * Test getDaysBetweenTest method. + * + * @param string $begin + * @param string $end + * @access public + * @return int + */ + public function getDaysBetweenTest($begin, $end) + { + $objects = $this->objectModel->getDaysBetween($begin, $end); + + if(dao::isError()) return dao::getError(); + + return count($objects); + } + + /** + * Test isHoliday method. + * + * @param string $date + * @access public + * @return object + */ + public function isHolidayTest($date) + { + $objects = $this->objectModel->isHoliday($date); + + if(dao::isError()) return dao::getError(); + + return $objects === true ? "It is a holiday" : "It is not a holiday"; + } + + /** + * Test isWorkingDay method. + * + * @param string $date + * @access public + * @return object + */ + public function isWorkingDayTest($date) + { + $objects = $this->objectModel->isWorkingDay($date); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test updateProgramPlanDuration method. + * + * @param string $beginDate + * @param string $endDate + * @access public + * @return object + */ + public function updateProgramPlanDurationTest($beginDate, $endDate) + { + $objects = $this->objectModel->updateProgramPlanDuration($beginDate, $endDate); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test updateProjectRealDuration method. + * + * @param string $beginDate + * @param string $endDate + * @access public + * @return object + */ + public function updateProjectRealDurationTest($beginDate, $endDate) + { + $objects = $this->objectModel->updateProjectRealDuration($beginDate, $endDate); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test updateTaskPlanDuration method. + * + * @param string $beginDate + * @param string $endDate + * @access public + * @return object + */ + public function updateTaskPlanDurationTest($beginDate, $endDate) + { + $objects = $this->objectModel->updateTaskPlanDuration($beginDate, $endDate); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Test updateTaskRealDuration method. + * + * @param string $beginDate + * @param string $endDate + * @access public + * @return object + */ + public function updateTaskRealDurationTest($beginDate, $endDate) + { + $objects = $this->objectModel->updateTaskRealDuration($beginDate, $endDate); + + if(dao::isError()) return dao::getError(); + + return $objects; + } +} diff --git a/test/model/holiday/create.php b/test/model/holiday/create.php new file mode 100755 index 0000000000..39ad938808 --- /dev/null +++ b/test/model/holiday/create.php @@ -0,0 +1,31 @@ +#!/usr/bin/env php +create(); +cid=1 +pid=1 + +*/ + +$holiday = new holidayTest(); + +$createHoliday = array('name' => '测试创建holiday', 'type' => 'holiday'); +$createWorking = array('name' => '测试创建working', 'type' => 'working'); +$createNoBegin = array('name' => '不传入开始日期', 'type' => 'holiday', 'begin' => ''); +$createNoEnd = array('name' => '不传入结束日期', 'type' => 'holiday', 'end' => '' ); +$createNoName = array('name' => '', 'type' => 'holiday'); +$createErrorDate = array('begin' => '2022-01-10', 'end' => '2022-01-01'); + +r($holiday->createTest($createHoliday)) && p('id,name,type') && e('101,测试创建holiday,holiday'); //测试创建holiday +r($holiday->createTest($createWorking)) && p('id,name,type') && e('102,测试创建working,working'); //测试创建working +r($holiday->createTest($createNoBegin)) && p('begin:0') && e('『开始日期』不能为空。'); //测试不传入必填项开始日期 +r($holiday->createTest($createNoEnd)) && p('end:0') && e('『结束日期』不能为空。'); //测试不传入必填项结束日期 +r($holiday->createTest($createNoName)) && p('name:0') && e('『名称』不能为空。'); //测试不传入必填项名称 +r($holiday->createTest($createErrorDate)) && p('end:0') && e('『结束日期』应当不小于『2022-01-10』。'); //测试传入小于开始日期的结束日期 + +system("./ztest init"); diff --git a/test/model/holiday/getactualworkingdays.php b/test/model/holiday/getactualworkingdays.php new file mode 100755 index 0000000000..755c053a9a --- /dev/null +++ b/test/model/holiday/getactualworkingdays.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +getActualWorkingDays(); +cid=1 +pid=1 + +*/ + +$holiday = new holidayTest(); + +r($holiday->getActualWorkingDaysTest('2022-04-01', '2022-04-10')) && p() && e('8'); //查询2022-04-01到2022-04-10的实际工作日 +r($holiday->getActualWorkingDaysTest('2022-04-06', '2022-04-12')) && p() && e('7'); //查询2022-04-06到2022-04-12的实际工作日 +r($holiday->getActualWorkingDaysTest('2022-05-10', '2022-05-20')) && p() && e('9'); //查询2022-05-10到2022-05-10的实际工作日 +r($holiday->getActualWorkingDaysTest('2022-04-06', '2022-04-06')) && p() && e('1'); //查询2022-05-10到2022-05-10的实际工作日 +r($holiday->getActualWorkingDaysTest('2022-05-13', '2022-05-13')) && p() && e('1'); //查询2022-05-13到2022-05-13的实际工作日 +r($holiday->getActualWorkingDaysTest('2022-05-14', '2022-05-14')) && p() && e('0'); //查询2022-05-14到2022-05-14的实际工作日 +r($holiday->getActualWorkingDaysTest('0000-00-00', '0000-00-00')) && p() && e('0'); //测试传入0000-00-00的情况 diff --git a/test/model/holiday/getbyid.php b/test/model/holiday/getbyid.php new file mode 100755 index 0000000000..3ede973c12 --- /dev/null +++ b/test/model/holiday/getbyid.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +getById(); +cid=1 +pid=1 + +*/ +$holidayIDList = array('1', '5', '10', '1001'); + +$holiday = new holidayTest(); + +r($holiday->getByIdTest($holidayIDList[0])) && p('name,type,desc') && e('这是一个节假日1,holiday,这个是节假日的描述1'); //查询id为1的holiday +r($holiday->getByIdTest($holidayIDList[1])) && p('name,type,desc') && e('这是一个节假日5,holiday,这个是节假日的描述5'); //查询id为5的holiday +r($holiday->getByIdTest($holidayIDList[2])) && p('name,type,desc') && e('这是一个节假日10,working,这个是节假日的描述10'); //查询id为10的holiday +r($holiday->getByIdTest($holidayIDList[3])) && p() && e('Object not found'); //查询不存在的holiday diff --git a/test/model/holiday/getdaysbetween.php b/test/model/holiday/getdaysbetween.php new file mode 100755 index 0000000000..ceda79bf95 --- /dev/null +++ b/test/model/holiday/getdaysbetween.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +getDaysBetween(); +cid=1 +pid=1 + +*/ + +$holiday = new holidayTest(); + +r($holiday->getDaysBetweenTest('2022-04-01', '2022-04-21')) && p() && e('21'); //返回2022-04-01到2022-04-21之间的天数 +r($holiday->getDaysBetweenTest('2022-05-23', '2022-05-30')) && p() && e('8'); //返回2022-05-23到2022-05-30之间的天数 +r($holiday->getDaysBetweenTest('2021-01-01', '2022-01-01')) && p() && e('366'); //测试传入一间隔一整年的两天 +r($holiday->getDaysBetweenTest('2022-05-07', '2022-05-08')) && p() && e('2'); //返回2022-05-07到2022-05-08之间的天数 +r($holiday->getDaysBetweenTest('2022-05-07', '2022-05-07')) && p() && e('1'); //测试传入同一天的情况 diff --git a/test/model/holiday/getyearpairs.php b/test/model/holiday/getyearpairs.php new file mode 100755 index 0000000000..b0cbc20495 --- /dev/null +++ b/test/model/holiday/getyearpairs.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getYearPairs(); +cid=1 +pid=1 + +*/ + +$holiday = new holidayTest(); + +r($holiday->getYearPairsTest()) && p() && e('1'); //测试getYearPairsTest方法 diff --git a/test/model/holiday/isholiday.php b/test/model/holiday/isholiday.php new file mode 100755 index 0000000000..43245ca9eb --- /dev/null +++ b/test/model/holiday/isholiday.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +isHoliday(); +cid=1 +pid=1 + +*/ +$holidays = array('2022-04-10', '2022-04-16'); +$workingDays = array('2022-05-07', '2022-05-13'); + +$holiday = new holidayTest(); + +r($holiday->isHolidayTest($holidays[0])) && p() && e('It is a holiday'); // 测试节假日2022年4月10日 +r($holiday->isHolidayTest($holidays[1])) && p() && e('It is a holiday'); // 测试节假日2022年4月16日 +r($holiday->isHolidayTest($workingDays[0])) && p() && e('It is not a holiday'); // 测试补班2022年5月7日 +r($holiday->isHolidayTest($workingDays[1])) && p() && e('It is not a holiday'); // 测试补班2022年5月13日 diff --git a/test/model/holiday/update.php b/test/model/holiday/update.php new file mode 100755 index 0000000000..6279b05d14 --- /dev/null +++ b/test/model/holiday/update.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +create(); +cid=1 +pid=1 + +*/ + +$holidayIDList = array('1', '2'); + +$holiday = new holidayTest(); + +$updateType = array('type' => 'working'); +$updateName = array('name' => '修改holiday的名字'); +$updateDesc = array('desc' => '一些描述'); +$noName = array('name' => ''); +$noBegin = array('begin' => ''); +$noEnd = array('end' => ''); +$endltBegin = array('begin' => '2022-05-08', 'end' => '2022-05-01'); + +r($holiday->updateTest($holidayIDList[0], $updateType)) && p() && e('true'); //测试修改类型 +r($holiday->updateTest($holidayIDList[0], $updateName)) && p() && e('true'); //测试修改名称 +r($holiday->updateTest($holidayIDList[0], $updateDesc)) && p() && e('true'); //测试修改描述 +r($holiday->updateTest($holidayIDList[0], $noName)) && p('name:0') && e('『名称』不能为空。'); //测试将必填项名称置空 +r($holiday->updateTest($holidayIDList[0], $noBegin)) && p('begin:0') && e('『开始日期』应当为合法的日期。'); //测试将必填项开始日期置空 +r($holiday->updateTest($holidayIDList[0], $noEnd)) && p('end:0') && e('『结束日期』应当为合法的日期。'); //测试将必填项结束日期置空 +r($holiday->updateTest($holidayIDList[0], $endltBegin)) && p('end:0') && e('『结束日期』应当不小于'); //测试输入大于开始日期的结束日期 + +system("./ztest init"); From 30170a62baf4cff53dbcc83d53981b6f1cbd14dd Mon Sep 17 00:00:00 2001 From: liyang <“liyang@easycorp.ltd”> Date: Fri, 6 May 2022 17:28:52 +0800 Subject: [PATCH 04/41] add doc data --- test/class/doc.class.php | 516 +++++++++++++++++++++ test/data/weeklyreport.yaml | 6 +- test/model/doc/buildbrowseswitch.php | 19 + test/model/doc/buildcollectbutton4doc.php | 19 + test/model/doc/buildcreatebutton4doc.php | 19 + test/model/doc/buildcrumbtitle.php | 19 + test/model/doc/checkautoloadpage.php | 19 + test/model/doc/checkprivdoc.php | 19 + test/model/doc/checkprivlib.php | 19 + test/model/doc/create.php | 55 +++ test/model/doc/createapilib.php | 41 ++ test/model/doc/createlib.php | 56 +++ test/model/doc/extractketablecss.php | 22 + test/model/doc/filldocsintree.php | 19 + test/model/doc/getalllibgroups.php | 19 + test/model/doc/getalllibsbytype.php | 19 + test/model/doc/getapilibs.php | 31 ++ test/model/doc/getapimoduletree.php | 19 + test/model/doc/getbyid.php | 24 + test/model/doc/getbyidlist.php | 21 + test/model/doc/getdocmenu.php | 27 ++ test/model/doc/getdocs.php | 26 ++ test/model/doc/getdocsbybrowsetype.php | 39 ++ test/model/doc/getdoctree.php | 19 + test/model/doc/getexecutionmodulepairs.php | 21 + test/model/doc/getfileicon.php | 19 + test/model/doc/getfilesourcepairs.php | 19 + test/model/doc/getlibbyid.php | 22 + test/model/doc/getlibfiles.php | 19 + test/model/doc/getlibidlistbyproject.php | 19 + test/model/doc/getlibs.php | 65 +++ test/model/doc/getlibsbyobject.php | 19 + test/model/doc/getlimitlibs.php | 19 + test/model/doc/getobjectsbydoc.php | 21 + test/model/doc/getorderedobjects.php | 19 + test/model/doc/getpreandnextdoc.php | 19 + test/model/doc/getprivdocs.php | 28 ++ test/model/doc/getprivlibsbydoc.php | 21 + test/model/doc/getproductcrumb.php | 19 + test/model/doc/getstatisticinfo.php | 19 + test/model/doc/getsublibgroups.php | 19 + test/model/doc/gettoandcclist.php | 19 + test/model/doc/gettreemenu.php | 19 + test/model/doc/printchildmodule.php | 19 + test/model/doc/savedraft.php | 25 + test/model/doc/select.php | 19 + test/model/doc/setfastmenu.php | 19 + test/model/doc/setlibusers.php | 19 + test/model/doc/setmenubytype.php | 19 + test/model/doc/statlibcounts.php | 19 + test/model/doc/summary.php | 19 + test/model/doc/update.php | 47 ++ test/model/doc/updateapilib.php | 37 ++ test/model/doc/updatelib.php | 57 +++ 54 files changed, 1812 insertions(+), 4 deletions(-) create mode 100644 test/class/doc.class.php create mode 100644 test/model/doc/buildbrowseswitch.php create mode 100644 test/model/doc/buildcollectbutton4doc.php create mode 100644 test/model/doc/buildcreatebutton4doc.php create mode 100644 test/model/doc/buildcrumbtitle.php create mode 100644 test/model/doc/checkautoloadpage.php create mode 100644 test/model/doc/checkprivdoc.php create mode 100644 test/model/doc/checkprivlib.php create mode 100644 test/model/doc/create.php create mode 100644 test/model/doc/createapilib.php create mode 100644 test/model/doc/createlib.php create mode 100644 test/model/doc/extractketablecss.php create mode 100644 test/model/doc/filldocsintree.php create mode 100644 test/model/doc/getalllibgroups.php create mode 100644 test/model/doc/getalllibsbytype.php create mode 100644 test/model/doc/getapilibs.php create mode 100644 test/model/doc/getapimoduletree.php create mode 100644 test/model/doc/getbyid.php create mode 100644 test/model/doc/getbyidlist.php create mode 100644 test/model/doc/getdocmenu.php create mode 100644 test/model/doc/getdocs.php create mode 100644 test/model/doc/getdocsbybrowsetype.php create mode 100644 test/model/doc/getdoctree.php create mode 100644 test/model/doc/getexecutionmodulepairs.php create mode 100644 test/model/doc/getfileicon.php create mode 100644 test/model/doc/getfilesourcepairs.php create mode 100644 test/model/doc/getlibbyid.php create mode 100644 test/model/doc/getlibfiles.php create mode 100644 test/model/doc/getlibidlistbyproject.php create mode 100644 test/model/doc/getlibs.php create mode 100644 test/model/doc/getlibsbyobject.php create mode 100644 test/model/doc/getlimitlibs.php create mode 100644 test/model/doc/getobjectsbydoc.php create mode 100644 test/model/doc/getorderedobjects.php create mode 100644 test/model/doc/getpreandnextdoc.php create mode 100644 test/model/doc/getprivdocs.php create mode 100644 test/model/doc/getprivlibsbydoc.php create mode 100644 test/model/doc/getproductcrumb.php create mode 100644 test/model/doc/getstatisticinfo.php create mode 100644 test/model/doc/getsublibgroups.php create mode 100644 test/model/doc/gettoandcclist.php create mode 100644 test/model/doc/gettreemenu.php create mode 100644 test/model/doc/printchildmodule.php create mode 100644 test/model/doc/savedraft.php create mode 100644 test/model/doc/select.php create mode 100644 test/model/doc/setfastmenu.php create mode 100644 test/model/doc/setlibusers.php create mode 100644 test/model/doc/setmenubytype.php create mode 100644 test/model/doc/statlibcounts.php create mode 100644 test/model/doc/summary.php create mode 100644 test/model/doc/update.php create mode 100644 test/model/doc/updateapilib.php create mode 100644 test/model/doc/updatelib.php diff --git a/test/class/doc.class.php b/test/class/doc.class.php new file mode 100644 index 0000000000..143e7413aa --- /dev/null +++ b/test/class/doc.class.php @@ -0,0 +1,516 @@ +objectModel = $tester->loadModel('doc'); + } + + /** + * Function createLib test by doc + * + * @param array $param + * @access public + * @return object + */ + public function createLibTest($param) + { + $createFields = array('type' => '', 'name' => '', 'acl' => ''); + + foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; + foreach($param as $key => $value) $_POST[$key] = $value; + $objectID = $this->objectModel->createLib(); + + unset($_POST); + + if(dao::isError()) return dao::getError(); + + $objects = $this->objectModel->getLibById($objectID); + + return $objects; + } + + /** + * Function createApiLib test by doc + * + * @param array $param + * @access public + * @return object + */ + public function createApiLibTest($param) + { + global $tester; + $tester->app->loadConfig('api'); + $tester->app->loadLang('doclib'); + + $createFields = array('name' => '', 'baseUrl' => '', 'acl' => '', 'desc' => '测试详情'); + + foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; + foreach($param as $key => $value) $_POST[$key] = $value; + $objectID = $this->objectModel->createApiLib(); + + unset($_POST); + + if(dao::isError()) return dao::getError(); + + $objects = $this->objectModel->getLibById($objectID); + + return $objects; + } + + /** + * Function updateApiLib test by doc + * + * @param int $id + * @param array $param + * @access public + * @return void + */ + public function updateApiLibTest($id, $param) + { + global $tester; + $tester->app->loadConfig('api'); + $tester->app->loadLang('doclib'); + + $oldDoc = $this->objectModel->getLibById($id); + $data = new stdClass; + foreach($param as $key => $value) $data->$key = $value; + + $objects = $this->objectModel->updateApiLib($id, $oldDoc, $data); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Function updateLib test by doc + * + * @param int $libID + * @param array $param + * @access public + * @return array + */ + public function updateLibTest($libID, $param) + { + global $tester; + $tester->app->loadConfig('doc'); + + foreach($param as $key => $value) $_POST[$key] = $value; + $objects = $this->objectModel->updateLib($libID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Function getDocsByBrowseType test by doc + * + * @param string $browseType + * @param array $moduleID + * @param string $sort + * @param mixed $pager + * @access public + * @return array + */ + public function getDocsByBrowseTypeTest($browseType, $moduleID, $sort = 'id_desc', $pager = null) + { + global $tester; + $tester->app->loadConfig('doc'); + + $objects = $this->objectModel->getDocsByBrowseType($browseType, $queryID = '', $moduleID, $sort, $pager); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + /** + * Function create test by doc + * + * @param array $param + * @access public + * @return array + */ + public function createTest($param) + { + global $tester; + $tester->app->loadConfig('api'); + $tester->app->loadLang('doclib'); + + $labels = array(); + $files = array(); + + $createFields = array('lib' => '', 'module' => '', 'title' => '', 'keywords' => '', 'type' => '', 'content' => '', 'contentMarkdown' => '', 'contentType' => '', + 'url' => '', 'labels' => $labels, 'files' => $files, 'contactListMenu' => '', 'acl' => ''); + + foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; + foreach($param as $key => $value) $_POST[$key] = $value; + + $this->objectModel->create(); + + if(dao::isError()) return dao::getError(); + + $objects = $tester->dao->select('*')->from(TABLE_DOC)->where('title')->eq($_POST['title'])->andwhere('lib')->eq($_POST['lib'])->fetchAll(); + unset($_POST); + + return $objects; + } + + /** + * Function update test by doc + * + * @param int $docID + * @param array $param + * @access public + * @return array + */ + public function updateTest($docID, $param) + { + global $tester; + $tester->app->loadConfig('api'); + $tester->app->loadLang('doclib'); + + $labels = array(); + $files = array(); + + $createFields = array('lib' => '', 'module' => '', 'title' => '', 'keywords' => '', 'type' => '', 'content' => '', 'contentType' => '', + 'url' => '', 'labels' => $labels, 'files' => $files, 'contactListMenu' => '', 'acl' => ''); + + foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; + foreach($param as $key => $value) $_POST[$key] = $value; + + $objects = $this->objectModel->update($docID); + + if(dao::isError()) return dao::getError(); + + return $objects["changes"]; + } + + /** + * Function saveDraft test by doc + * + * @param mixed $docID + * @param array $param + * @access public + * @return void + */ + public function saveDraftTest($docID, $param = array()) + { + global $tester; + $tester->app->loadConfig('doc'); + $tester->app->loadConfig('allowedTags'); + $createFields = array('content' => ''); + + foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; + foreach($param as $key => $value) $_POST[$key] = $value; + + $this->objectModel->saveDraft($docID); + + if(dao::isError()) return dao::getError(); + + $objects = $tester->dao->select('id,draft')->from(TABLE_DOC)->where('id')->eq($docID)->fetchAll('id'); + unset($_POST); + + return $objects; + } + + public function extractKETableCSSTest($content) + { + $objects = $this->objectModel->extractKETableCSS($content); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function checkPrivLibTest($object, $extra = '') + { + $objects = $this->objectModel->checkPrivLib($object, $extra = ''); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function checkPrivDocTest($object) + { + $objects = $this->objectModel->checkPrivDoc($object); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getAllLibsByTypeTest($type, $pager = null, $product = '') + { + $objects = $this->objectModel->getAllLibsByType($type, $pager = null, $product = ''); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getAllLibGroupsTest($appendLibs = '') + { + $objects = $this->objectModel->getAllLibGroups($appendLibs = ''); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getLimitLibsTest($type, $limit = 0) + { + $objects = $this->objectModel->getLimitLibs($type, $limit = 0); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getSubLibGroupsTest($type, $idList) + { + $objects = $this->objectModel->getSubLibGroups($type, $idList); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getLibsByObjectTest($type, $objectID, $mode = '', $appendLib = 0) + { + $objects = $this->objectModel->getLibsByObject($type, $objectID, $mode = '', $appendLib = 0); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getOrderedObjectsTest($objectType = 'product') + { + $objects = $this->objectModel->getOrderedObjects($objectType = 'product'); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function statLibCountsTest($idList) + { + $objects = $this->objectModel->statLibCounts($idList); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getLibFilesTest($type, $objectID, $orderBy, $pager = null) + { + $objects = $this->objectModel->getLibFiles($type, $objectID, $orderBy, $pager = null); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getFileSourcePairsTest($files) + { + $objects = $this->objectModel->getFileSourcePairs($files); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getFileIconTest($files) + { + $objects = $this->objectModel->getFileIcon($files); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getDocTreeTest($libID) + { + $objects = $this->objectModel->getDocTree($libID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function fillDocsInTreeTest($node, $libID) + { + $objects = $this->objectModel->fillDocsInTree($node, $libID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getProductCrumbTest($productID, $executionID = 0) + { + $objects = $this->objectModel->getProductCrumb($productID, $executionID = 0); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function setLibUsersTest($type, $objectID) + { + $objects = $this->objectModel->setLibUsers($type, $objectID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getLibIdListByProjectTest($projectID = 0) + { + $objects = $this->objectModel->getLibIdListByProject($projectID = 0); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getStatisticInfoTest() + { + $objects = $this->objectModel->getStatisticInfo(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getPreAndNextDocTest($docID, $libID) + { + $objects = $this->objectModel->getPreAndNextDoc($docID, $libID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function printChildModuleTest($module, $libID, $methodName, $browseType, $moduleID) + { + $objects = $this->objectModel->printChildModule($module, $libID, $methodName, $browseType, $moduleID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function buildCrumbTitleTest($libID = 0, $param = 0, $title = '') + { + $objects = $this->objectModel->buildCrumbTitle($libID = 0, $param = 0, $title = ''); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function buildCreateButton4DocTest($objectType, $objectID, $libID) + { + $objects = $this->objectModel->buildCreateButton4Doc($objectType, $objectID, $libID); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function buildCollectButton4DocTest() + { + $objects = $this->objectModel->buildCollectButton4Doc(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function buildBrowseSwitchTest($type, $objectID, $viewType) + { + $objects = $this->objectModel->buildBrowseSwitch($type, $objectID, $viewType); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function setFastMenuTest($fastLib) + { + $objects = $this->objectModel->setFastMenu($fastLib); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getToAndCcListTest($doc) + { + $objects = $this->objectModel->getToAndCcList($doc); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function selectTest($type, $objects, $objectID, $libs, $libID = 0) + { + $objects = $this->objectModel->select($type, $objects, $objectID, $libs, $libID = 0); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getApiModuleTreeTest($rootID, $docID = 0, $release = 0) + { + $objects = $this->objectModel->getApiModuleTree($rootID, $docID = 0, $release = 0); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getTreeMenuTest($type, $objectID, $rootID, $startModule = 0, $docID = 0) + { + $objects = $this->objectModel->getTreeMenu($type, $objectID, $rootID, $startModule = 0, $docID = 0); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function summaryTest($files) + { + $objects = $this->objectModel->summary($files); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function setMenuByTypeTest($type, $objectID, $libID, $appendLib = 0) + { + $objects = $this->objectModel->setMenuByType($type, $objectID, $libID, $appendLib = 0); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function checkAutoloadPageTest($doc) + { + $objects = $this->objectModel->checkAutoloadPage($doc); + + if(dao::isError()) return dao::getError(); + + return $objects; + } +} diff --git a/test/data/weeklyreport.yaml b/test/data/weeklyreport.yaml index 3af89e6b9a..b7693c1b6b 100644 --- a/test/data/weeklyreport.yaml +++ b/test/data/weeklyreport.yaml @@ -21,10 +21,8 @@ fields: format: "" - field: weekStart note: "" - range: "(M)-(w):60s" - type: timestamp - format: "YYYY-MM-DD" - prefix: "" + range: "" + prefix: "2022-05-02" postfix: "" - field: pv range: 1-10 diff --git a/test/model/doc/buildbrowseswitch.php b/test/model/doc/buildbrowseswitch.php new file mode 100644 index 0000000000..b371650616 --- /dev/null +++ b/test/model/doc/buildbrowseswitch.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +buildBrowseSwitch(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->buildBrowseSwitchTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/buildcollectbutton4doc.php b/test/model/doc/buildcollectbutton4doc.php new file mode 100644 index 0000000000..d2397de676 --- /dev/null +++ b/test/model/doc/buildcollectbutton4doc.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +buildCollectButton4Doc(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->buildCollectButton4DocTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/buildcreatebutton4doc.php b/test/model/doc/buildcreatebutton4doc.php new file mode 100644 index 0000000000..f6faa0f554 --- /dev/null +++ b/test/model/doc/buildcreatebutton4doc.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +buildCreateButton4Doc(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->buildCreateButton4DocTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/buildcrumbtitle.php b/test/model/doc/buildcrumbtitle.php new file mode 100644 index 0000000000..a23de3163a --- /dev/null +++ b/test/model/doc/buildcrumbtitle.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +buildCrumbTitle(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->buildCrumbTitleTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/checkautoloadpage.php b/test/model/doc/checkautoloadpage.php new file mode 100644 index 0000000000..4d77393db1 --- /dev/null +++ b/test/model/doc/checkautoloadpage.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +checkAutoloadPage(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->checkAutoloadPageTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/checkprivdoc.php b/test/model/doc/checkprivdoc.php new file mode 100644 index 0000000000..c8b39faad5 --- /dev/null +++ b/test/model/doc/checkprivdoc.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +checkPrivDoc(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->checkPrivDocTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/checkprivlib.php b/test/model/doc/checkprivlib.php new file mode 100644 index 0000000000..455b604d6f --- /dev/null +++ b/test/model/doc/checkprivlib.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +checkPrivLib(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->checkPrivLibTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/create.php b/test/model/doc/create.php new file mode 100644 index 0000000000..60d16e880e --- /dev/null +++ b/test/model/doc/create.php @@ -0,0 +1,55 @@ +#!/usr/bin/env php +create(); +cid=1 +pid=1 + +创建产品文档 >> 1,新建产品文档 +创建项目文档 >> 27,新建项目文档 +创建执行文档 >> 127,新建执行文档 +创建自定义文档 >> text, +创建url文档 >> url,www.baidu.com +创建Markdown文档 >> text,Markdown +创建私有文档 >> private +创建自定义文档 >> custom,1,2,3 +不输入文档库 >> 『所属文档库』不能为空。 +不输入标题 >> 『文档标题』不能为空。 + +*/ +$libIDs = array('1', '117', '217', '821'); +$type = array('text', 'url', 'execution', 'custom', ''); +$acl = array('', 'open', 'custom', 'private'); +$groups = array('1', '2', '3'); +$users = array('admin', 'dev1', 'dev10'); + +$createProductDoc = array('lib' => $libIDs[0], 'title' => '新建产品文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$createProjectDoc = array('lib' => $libIDs[1], 'title' => '新建项目文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$createExecutionDoc = array('lib' => $libIDs[2], 'title' => '新建执行文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$createCustomDoc = array('lib' => $libIDs[3], 'title' => '新建自定义文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$createUrlDoc = array('lib' => $libIDs[0], 'title' => '新建URL文档', 'type' => $type[1], 'url' => 'www.baidu.com', 'acl' => $acl[1]); +$createMarkdownDoc = array('lib' => $libIDs[0], 'title' => '新建markdown文档', 'type' => $type[0], 'contentType' => 'markdown', 'contentMarkdown' => 'Markdown', 'acl' => $acl[1]); +$privateDoc = array('lib' => $libIDs[0], 'title' => '新建私有文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[3]); +$customDoc = array('lib' => $libIDs[0], 'title' => '新建自定义文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[2], 'groups' => $groups, 'users' => $users); +$noLib = array('title' => '无文档库', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$noTitle = array('lib' => $libIDs[0], 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$noType = array('lib' => $libIDs[0], 'title' => '无TYPE', 'contentType' => 'html', 'acl' => $acl[1]); + +$doc = new docTest(); +r($doc->createTest($createProductDoc)) && p('0:product,title') && e('1,新建产品文档'); //创建产品文档 +r($doc->createTest($createProjectDoc)) && p('0:project,title') && e('27,新建项目文档'); //创建项目文档 +r($doc->createTest($createExecutionDoc)) && p('0:execution,title') && e('127,新建执行文档'); //创建执行文档 +r($doc->createTest($createCustomDoc)) && p('0:type,draft') && e('text,'); //创建自定义文档 +r($doc->createTest($createUrlDoc)) && p('0:type,draft') && e('url,www.baidu.com'); //创建url文档 +r($doc->createTest($createMarkdownDoc)) && p('0:type,draft') && e('text,Markdown'); //创建Markdown文档 +r($doc->createTest($privateDoc)) && p('0:acl') && e('private'); //创建私有文档 +r($doc->createTest($customDoc)) && p('0:acl,groups') && e('custom,1,2,3'); //创建自定义文档 +r($doc->createTest($noLib)) && p('lib') && e('『所属文档库』不能为空。');//不输入文档库 +r($doc->createTest($noTitle)) && p('title:0') && e('『文档标题』不能为空。'); //不输入标题 + +system("./ztest init"); \ No newline at end of file diff --git a/test/model/doc/createapilib.php b/test/model/doc/createapilib.php new file mode 100644 index 0000000000..442157c270 --- /dev/null +++ b/test/model/doc/createapilib.php @@ -0,0 +1,41 @@ +#!/usr/bin/env php +createApiLib(); +cid=1 +pid=1 + +新建公有接口库 >> api;新建api文档库 +新建私有接口库 >> private;www.zentaopms.com +新建自定义接口库 >> custom;1,2,3;admin,dev1,dev10 +接口库名称为空 >> 『接口库名称』不能为空。 +重复创建接口库 >> 『接口库名称』已经有『新建api文档库』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。 + +*/ +$acl = array('', 'open', 'custom', 'private'); +$groups = array('1', '2', '3'); +$users = array('admin', 'dev1', 'dev10'); + +$openApilib = array('name' => '新建api文档库', 'acl' => $acl[1], 'baseUrl' => 'www.zentaopms.com'); +$privateApilib = array('name' => '新建私有api文档库', 'acl' => $acl[3], 'baseUrl' => 'www.zentaopms.com'); +$customApilib = array('name' => '新建自定义api文档库', 'acl' => $acl[2], 'baseUrl' => 'www.zentaopms.com', 'groups' => $groups, 'users' => $users); +$noName = array('name' => '', 'acl' => $acl[1], 'baseUrl' => 'www.zentaopms.com'); +$noAcl = array('name' => '无权限', 'acl' => $acl[0], 'baseUrl' => 'www.zentaopms.com'); +$noBaseUrl = array('name' => 'noBaseUrl', 'acl' => $acl[0], 'baseUrl' => ''); + +$doc = new docTest(); + +r($doc->createApiLibTest($openApilib)) && p('type;name') && e('api;新建api文档库'); //新建公有接口库 +r($doc->createApiLibTest($privateApilib)) && p('acl;baseUrl') && e('private;www.zentaopms.com'); //新建私有接口库 +r($doc->createApiLibTest($customApilib)) && p('acl;groups;users') && e('custom;1,2,3;admin,dev1,dev10');//新建自定义接口库 +r($doc->createApiLibTest($noName)) && p('name:0') && e('『接口库名称』不能为空。'); //接口库名称为空 +r($doc->createApiLibTest($noAcl)) && p('acl') && e(''); //接口库权限为空 +r($doc->createApiLibTest($noBaseUrl)) && p('baseUrl') && e(''); //接口库地址为空 +r($doc->createApiLibTest($openApilib)) && p('name:0') && e('『接口库名称』已经有『新建api文档库』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。');//重复创建接口库 + +system("./ztest init"); \ No newline at end of file diff --git a/test/model/doc/createlib.php b/test/model/doc/createlib.php new file mode 100644 index 0000000000..eaebcde663 --- /dev/null +++ b/test/model/doc/createlib.php @@ -0,0 +1,56 @@ +#!/usr/bin/env php +createLib(); +cid=1 +pid=1 + +新建公有产品文档库 >> product;新建文档库 +新建公有项目文档库 >> project;default +新建公有执行文档库 >> execution;rnd +新建公有自定义文档库 >> custom;0 +新建私有自定义文档库 >> product;1,2,3;admin,dev1,dev10 +新建无产品产品文档库 >> 『产品库』应当是数字。 +新建无项目项目文档库 >> 『project』应当是数字。 +新建无执行执行文档库 >> 『迭代库』应当是数字。 + +*/ +$type = array('product', 'project', 'execution', 'custom', ''); +$product = array('', '1'); +$project = array('', '11'); +$execution = array('', '101'); +$name = array('', '新建文档库'); +$acl = array('', 'default', 'custom'); +$groups = array('1', '2', '3'); +$users = array('admin', 'dev1', 'dev10'); + +$createProduct = array('type' => $type[0], 'product' => $product[1], 'name' => $name[1], 'acl' => $acl[1]); +$createProject = array('type' => $type[1], 'project' => $project[1], 'name' => $name[1], 'acl' => $acl[1]); +$createExecution = array('type' => $type[2], 'execution' => $execution[1], 'name' => $name[1], 'acl' => $acl[1]); +$createCustom = array('type' => $type[3], 'name' => $name[1], 'acl' => $acl[1]); +$customLib = array('type' => $type[0], 'product' => $product[1], 'name' => $name[1], 'acl' => $acl[2], 'groups' => $groups, 'users' => $users); +$noType = array('type' => $type[4], 'product' => $product[1], 'name' => $name[1], 'acl' => $acl[1]); +$noProduct = array('type' => $type[0], 'product' => $product[0], 'name' => $name[1], 'acl' => $acl[1]); +$noProject = array('type' => $type[1], 'project' => $project[0], 'name' => $name[1], 'acl' => $acl[1]); +$noExecution = array('type' => $type[2], 'execution' => $execution[0], 'name' => $name[1], 'acl' => $acl[1]); +$noAcl = array('type' => $type[0], 'product' => $product[1], 'name' => $name[1], 'acl' => $acl[0]); + +$doc = new docTest(); + +r($doc->createLibTest($createProduct)) && p('type;name') && e('product;新建文档库'); //新建公有产品文档库 +r($doc->createLibTest($createProject)) && p('type;acl') && e('project;default'); //新建公有项目文档库 +r($doc->createLibTest($createExecution)) && p('type;vision') && e('execution;rnd'); //新建公有执行文档库 +r($doc->createLibTest($createCustom)) && p('type;project') && e('custom;0'); //新建公有自定义文档库 +r($doc->createLibTest($customLib)) && p('type;groups;users') && e('product;1,2,3;admin,dev1,dev10');//新建私有自定义文档库 +r($doc->createLibTest($noType)) && p('type') && e(''); //新建无类型文档库 +r($doc->createLibTest($noProduct)) && p('product:0') && e('『产品库』应当是数字。'); //新建无产品产品文档库 +r($doc->createLibTest($noProject)) && p('project:0') && e('『project』应当是数字。'); //新建无项目项目文档库 +r($doc->createLibTest($noExecution)) && p('execution:0') && e('『迭代库』应当是数字。'); //新建无执行执行文档库 +r($doc->createLibTest($noAcl)) && p('acl') && e(''); //新建无权限控制文档库 + +system("./ztest init"); \ No newline at end of file diff --git a/test/model/doc/extractketablecss.php b/test/model/doc/extractketablecss.php new file mode 100644 index 0000000000..326c6c9df9 --- /dev/null +++ b/test/model/doc/extractketablecss.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +extractKETableCSS(); +cid=1 +pid=1 + + + +*/ +global $tester; +$doc = $tester->loadModel('doc'); +$content = 'test'; +$css = ''; + +r($doc->extractKETableCSS($content)) && p() && e('0'); //未过滤数据查询 +r($doc->extractKETableCSS($css)) && p() && e('.ke-table1{border:1px #000000 solid}');//过滤后数据查询 diff --git a/test/model/doc/filldocsintree.php b/test/model/doc/filldocsintree.php new file mode 100644 index 0000000000..28aa89df22 --- /dev/null +++ b/test/model/doc/filldocsintree.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +fillDocsInTree(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->fillDocsInTreeTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getalllibgroups.php b/test/model/doc/getalllibgroups.php new file mode 100644 index 0000000000..90c886c9e6 --- /dev/null +++ b/test/model/doc/getalllibgroups.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getAllLibGroups(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getAllLibGroupsTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getalllibsbytype.php b/test/model/doc/getalllibsbytype.php new file mode 100644 index 0000000000..8f213598eb --- /dev/null +++ b/test/model/doc/getalllibsbytype.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getAllLibsByType(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getAllLibsByTypeTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getapilibs.php b/test/model/doc/getapilibs.php new file mode 100644 index 0000000000..012d9f8dbd --- /dev/null +++ b/test/model/doc/getapilibs.php @@ -0,0 +1,31 @@ +#!/usr/bin/env php +getApiLibs(); +cid=1 +pid=1 + +查询全部接口库 >> api +查询额外的产品库 >> product +查询接口库 >> 接口库 +查询全部接口库统计 >> 10 +查询额外的产品库统计 >> 11 +查询接口库统计 >> 10 + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +$docLibIDList = array('0', '17', '901'); + +r($doc->getApiLibs($docLibIDList[0])) && p('901:type') && e('api'); //查询全部接口库 +r($doc->getApiLibs($docLibIDList[1])) && p('17:type') && e('product');//查询额外的产品库 +r($doc->getApiLibs($docLibIDList[2])) && p('902:name') && e('接口库'); //查询接口库 +r(count($doc->getApiLibs($docLibIDList[0]))) && p() && e('10'); //查询全部接口库统计 +r(count($doc->getApiLibs($docLibIDList[1]))) && p() && e('11'); //查询额外的产品库统计 +r(count($doc->getApiLibs($docLibIDList[2]))) && p() && e('10'); //查询接口库统计 \ No newline at end of file diff --git a/test/model/doc/getapimoduletree.php b/test/model/doc/getapimoduletree.php new file mode 100644 index 0000000000..95670d6d74 --- /dev/null +++ b/test/model/doc/getapimoduletree.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getApiModuleTree(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getApiModuleTreeTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getbyid.php b/test/model/doc/getbyid.php new file mode 100644 index 0000000000..a34f860421 --- /dev/null +++ b/test/model/doc/getbyid.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +getById(); +cid=1 +pid=1 + + + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +$docIDList = array('0', '17', '1'); +$versionList = array('0', '1', '2'); + +r($doc->getById($docIDList[1], $versionList[0])) && p('product;title') && e('17;文档标题17'); //正常根据id查询doc +r($doc->getById($docIDList[0], $versionList[0])) && p() && e('0'); //查询不存在的doc +r($doc->getById($docIDList[2], $versionList[1])) && p('version;content') && e('2;文档正文1'); //查询版本为1的文档内容 +r($doc->getById($docIDList[2], $versionList[2])) && p('version;content') && e('2;文档正文901'); //查询版本为2的文档内容 \ No newline at end of file diff --git a/test/model/doc/getbyidlist.php b/test/model/doc/getbyidlist.php new file mode 100644 index 0000000000..74ec12d822 --- /dev/null +++ b/test/model/doc/getbyidlist.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +getByIdList(); +cid=1 +pid=1 + + + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +$docIDList = array('0', '117', '1', '217'); + +r($doc->getByIdList($docIDList)) && p('901:lib,content') && e('1,文档正文901');//正常查询文档库下的文档 +r(count($doc->getByIdList($docIDList))) && p() && e('3'); //查询文档库下的文档统计 \ No newline at end of file diff --git a/test/model/doc/getdocmenu.php b/test/model/doc/getdocmenu.php new file mode 100644 index 0000000000..f1cc218282 --- /dev/null +++ b/test/model/doc/getdocmenu.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +getDocMenu(); +cid=1 +pid=1 + + + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +$docIDList = array('0', '17'); +$parents = array('0', '3637'); +$orderBy = array('name_asc', 'id_desc'); +$browseTypes = array('collectedbyme', ''); + +r($doc->getDocMenu($docIDList[1], $parents[0], $orderBy[0], $browseTypes[1])) && p('3637:name,parent') && e('目录17,0'); //无子目录查询 +r($doc->getDocMenu($docIDList[1], $parents[1], $orderBy[0], $browseTypes[1])) && p('3754:name,parent') && e('子目录34,3637');//有子目录查询 +r(count($doc->getDocMenu($docIDList[1], $parents[1], $orderBy[0], $browseTypes[1]))) && p() && e('2'); //子目录查询统计 +r($doc->getDocMenu($docIDList[0], $parents[0], $orderBy[0], $browseTypes[0])) && p() && e('0'); //无效数据查询 \ No newline at end of file diff --git a/test/model/doc/getdocs.php b/test/model/doc/getdocs.php new file mode 100644 index 0000000000..e782b17128 --- /dev/null +++ b/test/model/doc/getdocs.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +getDocs(); +cid=1 +pid=1 + +正常获取文档库下的文档 >> 1,文档标题1 +获取文档目录下的文档 >> 2,3622 +libID为空查询 >> 900 + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +$libIDlist = array('1', '2', ''); +$moduleIDList = array('0','3621', '3622'); +$orderBy = 'id_desc'; + +r($doc->getDocs($libIDlist[0], $moduleIDList[0], $orderBy)) && p('1:lib,title') && e('1,文档标题1');//正常获取文档库下的文档 +r($doc->getDocs($libIDlist[1], $moduleIDList, $orderBy)) && p('2:lib,module') && e('2,3622'); //获取文档目录下的文档 +r(count($doc->getDocs($libIDlist[2], $moduleIDList[0], $orderBy))) && p() && e('900'); //libID为空查询 \ No newline at end of file diff --git a/test/model/doc/getdocsbybrowsetype.php b/test/model/doc/getdocsbybrowsetype.php new file mode 100644 index 0000000000..0b987b50e8 --- /dev/null +++ b/test/model/doc/getdocsbybrowsetype.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +getDocsByBrowseType(); +cid=1 +pid=1 + +all类型查询 >> 1,文档标题1 +openedbyme类型查询 >> 2,正常产品2 +editedbyme类型查询 >> 0 +byediteddate类型查询 >> 900,admin +collectedbyme类型查询 >> 0 +test类型查询 >> 0 +加上moduleId查询 >> 关键词1 +all类型查询 >> 900 +openedbyme类型查询 >> 900 +byediteddate类型查询 >> 900 + +*/ +$browseType = array('all', 'openedbyme', 'editedbyme', 'byediteddate', 'collectedbyme', 'test'); +$moduleIds = array('', '3621', '3622', '3623'); + +$doc = new docTest(); + +r($doc->getDocsByBrowseTypeTest($browseType[0], $moduleIds[0])) && p('1:lib,title') && e('1,文档标题1');//all类型查询 +r($doc->getDocsByBrowseTypeTest($browseType[1], $moduleIds[0])) && p('2:lib,objectName') && e('2,正常产品2');//openedbyme类型查询 +r($doc->getDocsByBrowseTypeTest($browseType[2], $moduleIds[0])) && p() && e('0'); //editedbyme类型查询 +r($doc->getDocsByBrowseTypeTest($browseType[3], $moduleIds[0])) && p('900:lib,users') && e('900,admin'); //byediteddate类型查询 +r($doc->getDocsByBrowseTypeTest($browseType[4], $moduleIds[0])) && p() && e('0'); //collectedbyme类型查询 +r($doc->getDocsByBrowseTypeTest($browseType[5], $moduleIds[0])) && p() && e('0'); //test类型查询 +r($doc->getDocsByBrowseTypeTest($browseType[3], $moduleIds)) && p('1:keywords') && e('关键词1'); //加上moduleId查询 +r(count($doc->getDocsByBrowseTypeTest($browseType[0], $moduleIds[0]))) && p('1:lib,title') && e('900'); //all类型查询 +r(count($doc->getDocsByBrowseTypeTest($browseType[1], $moduleIds[0]))) && p('2:lib,objectName') && e('900'); //openedbyme类型查询 +r(count($doc->getDocsByBrowseTypeTest($browseType[3], $moduleIds[0]))) && p('900:lib,users') && e('900'); //byediteddate类型查询 \ No newline at end of file diff --git a/test/model/doc/getdoctree.php b/test/model/doc/getdoctree.php new file mode 100644 index 0000000000..247c9b34ec --- /dev/null +++ b/test/model/doc/getdoctree.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getDocTree(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getDocTreeTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getexecutionmodulepairs.php b/test/model/doc/getexecutionmodulepairs.php new file mode 100644 index 0000000000..1b9299fbb2 --- /dev/null +++ b/test/model/doc/getexecutionmodulepairs.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +getExecutionModulePairs(); +cid=1 +pid=1 + +正常查询 >> 子目录200 +正常查询统计 >> 4520 + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +r($doc->getExecutionModulePairs()) && p('3920') && e('子目录200');//正常查询 +r(count($doc->getExecutionModulePairs())) && p() && e('4520'); //正常查询统计 \ No newline at end of file diff --git a/test/model/doc/getfileicon.php b/test/model/doc/getfileicon.php new file mode 100644 index 0000000000..7dc8bf3819 --- /dev/null +++ b/test/model/doc/getfileicon.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getFileIcon(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getFileIconTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getfilesourcepairs.php b/test/model/doc/getfilesourcepairs.php new file mode 100644 index 0000000000..f4f4279d42 --- /dev/null +++ b/test/model/doc/getfilesourcepairs.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getFileSourcePairs(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getFileSourcePairsTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getlibbyid.php b/test/model/doc/getlibbyid.php new file mode 100644 index 0000000000..90ffbf10b4 --- /dev/null +++ b/test/model/doc/getlibbyid.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +getLibById(); +cid=1 +pid=1 + +正常查询文档库 >> 产品主库 +查询不存在的文档库 >> 0 + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +$docLibIDList = array('0', '17'); + +r($doc->getLibById($docLibIDList[1])) && p('name') && e('产品主库');//正常查询文档库 +r($doc->getLibById($docLibIDList[0])) && p() && e('0'); //查询不存在的文档库 \ No newline at end of file diff --git a/test/model/doc/getlibfiles.php b/test/model/doc/getlibfiles.php new file mode 100644 index 0000000000..9c9b825e20 --- /dev/null +++ b/test/model/doc/getlibfiles.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getLibFiles(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getLibFilesTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getlibidlistbyproject.php b/test/model/doc/getlibidlistbyproject.php new file mode 100644 index 0000000000..7b73aa1285 --- /dev/null +++ b/test/model/doc/getlibidlistbyproject.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getLibIdListByProject(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getLibIdListByProjectTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getlibs.php b/test/model/doc/getlibs.php new file mode 100644 index 0000000000..dc0e76e9a4 --- /dev/null +++ b/test/model/doc/getlibs.php @@ -0,0 +1,65 @@ +#!/usr/bin/env php +getLibs(); +cid=1 +pid=1 + +全部文档库查询 >> 产品主库 +api文档库查询 >> 0 +产品文档库查询 >> 产品主库 +项目文档库查询 >> 项目主库 +执行文档库查询 >> 迭代主库 +产品文档库关联查询 >> 正常产品1 / 产品主库 +notdoc查询 >> 产品主库 +额外文档库查询 >> 产品主库 +产品单独查询 >> 产品主库 +项目单独查询 >> 项目主库 +执行单独查询 >> 迭代主库 +全部文档库查询统计 >> 900 +产品文档库查询统计 >> 100 +项目文档库查询统计 >> 90 +执行文档库查询统计 >> 630 +产品文档库关联查询统计 >> 900 +notdoc查询统计 >> 900 +额外文档库查询统计 >> 2 +产品单独查询统计 >> 1 +项目单独查询统计 >> 1 +执行单独查询统计 >> 1 + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +$types = array('all', 'api', 'product', 'project', 'execution'); +$extra = array('', 'withObject', 'notdoc'); +$appendLibs = array('17', '1'); +$objectIDs = array('1', '11', '101', '0'); +//var_dump($doc->getLibs($types[4], $extra[0], '', $objectIDs[2]));die; +r($doc->getLibs($types[0], $extra[0], '', $objectIDs[3])) && p('1') && e('产品主库'); //全部文档库查询 +r($doc->getLibs($types[1], $extra[0], '', $objectIDs[3])) && p() && e('0'); //api文档库查询 +r($doc->getLibs($types[2], $extra[0], '', $objectIDs[3])) && p('10') && e('产品主库'); //产品文档库查询 +r($doc->getLibs($types[3], $extra[0], '', $objectIDs[3])) && p('110') && e('项目主库'); //项目文档库查询 +r($doc->getLibs($types[4], $extra[0], '', $objectIDs[3])) && p('200') && e('迭代主库'); //执行文档库查询 +r($doc->getLibs($types[0], $extra[1], '', $objectIDs[3])) && p('1') && e('正常产品1 / 产品主库');//产品文档库关联查询 +r($doc->getLibs($types[0], $extra[2], '', $objectIDs[3])) && p('1') && e('产品主库'); //notdoc查询 +r($doc->getLibs($types[1], $extra[0], $appendLibs, $objectIDs[3])) && p('1') && e('产品主库'); //额外文档库查询 +r($doc->getLibs($types[2], $extra[0], '', $objectIDs[0])) && p('1') && e('产品主库'); //产品单独查询 +r($doc->getLibs($types[3], $extra[0], '', $objectIDs[1])) && p('101') && e('项目主库'); //项目单独查询 +r($doc->getLibs($types[4], $extra[0], '', $objectIDs[2])) && p('191') && e('迭代主库'); //执行单独查询 + +r(count($doc->getLibs($types[0], $extra[0], '', $objectIDs[3]))) && p() && e('900');//全部文档库查询统计 +r(count($doc->getLibs($types[2], $extra[0], '', $objectIDs[3]))) && p() && e('100');//产品文档库查询统计 +r(count($doc->getLibs($types[3], $extra[0], '', $objectIDs[3]))) && p() && e('90'); //项目文档库查询统计 +r(count($doc->getLibs($types[4], $extra[0], '', $objectIDs[3]))) && p() && e('630');//执行文档库查询统计 +r(count($doc->getLibs($types[0], $extra[1], '', $objectIDs[3]))) && p() && e('900');//产品文档库关联查询统计 +r(count($doc->getLibs($types[0], $extra[2], '', $objectIDs[3]))) && p() && e('900');//notdoc查询统计 +r(count($doc->getLibs($types[1], $extra[0], $appendLibs, $objectIDs[3]))) && p() && e('2'); //额外文档库查询统计 +r(count($doc->getLibs($types[2], $extra[0], '', $objectIDs[0]))) && p() && e('1'); //产品单独查询统计 +r(count($doc->getLibs($types[3], $extra[0], '', $objectIDs[1]))) && p() && e('1'); //项目单独查询统计 +r(count($doc->getLibs($types[4], $extra[0], '', $objectIDs[2]))) && p() && e('1'); //执行单独查询统计 \ No newline at end of file diff --git a/test/model/doc/getlibsbyobject.php b/test/model/doc/getlibsbyobject.php new file mode 100644 index 0000000000..04f9d2bfd4 --- /dev/null +++ b/test/model/doc/getlibsbyobject.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getLibsByObject(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getLibsByObjectTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getlimitlibs.php b/test/model/doc/getlimitlibs.php new file mode 100644 index 0000000000..2d1f7cdda2 --- /dev/null +++ b/test/model/doc/getlimitlibs.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getLimitLibs(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getLimitLibsTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getobjectsbydoc.php b/test/model/doc/getobjectsbydoc.php new file mode 100644 index 0000000000..7a6af46349 --- /dev/null +++ b/test/model/doc/getobjectsbydoc.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +getObjectsByDoc(); +cid=1 +pid=1 + + + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +$docIdList = array('17', '117', '217'); + +r($doc->getObjectsByDoc($docIdList)) && p('0:27;1:127;2:17') && e('项目17;迭代27;正常产品17');//查询文档库的项目产品迭代 \ No newline at end of file diff --git a/test/model/doc/getorderedobjects.php b/test/model/doc/getorderedobjects.php new file mode 100644 index 0000000000..bd315aaafc --- /dev/null +++ b/test/model/doc/getorderedobjects.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getOrderedObjects(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getOrderedObjectsTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getpreandnextdoc.php b/test/model/doc/getpreandnextdoc.php new file mode 100644 index 0000000000..0e9019503d --- /dev/null +++ b/test/model/doc/getpreandnextdoc.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getPreAndNextDoc(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getPreAndNextDocTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getprivdocs.php b/test/model/doc/getprivdocs.php new file mode 100644 index 0000000000..2aa2c347ff --- /dev/null +++ b/test/model/doc/getprivdocs.php @@ -0,0 +1,28 @@ +#!/usr/bin/env php +getPrivDocs(); +cid=1 +pid=1 + +查询单条doc >> 1 +查询多条doc >> 1;2 +查询模块doc >> 1;2 +不传入libid查询统计 >> 900 + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +$libIDlist = array('1', '2', ''); +$moduleIDList = array('0','3621', '3622'); + +r($doc->getPrivDocs($libIDlist[0], $moduleIDList[0])) && p('1') && e('1'); //查询单条doc +r($doc->getPrivDocs($libIDlist, $moduleIDList[0])) && p('1;2') && e('1;2');//查询多条doc +r($doc->getPrivDocs($libIDlist, $moduleIDList)) && p('1;2') && e('1;2');//查询模块doc +r(count($doc->getPrivDocs($libIDlist[2], $moduleIDList[0]))) && p() && e('900');//不传入libid查询统计 \ No newline at end of file diff --git a/test/model/doc/getprivlibsbydoc.php b/test/model/doc/getprivlibsbydoc.php new file mode 100644 index 0000000000..df33fddd9a --- /dev/null +++ b/test/model/doc/getprivlibsbydoc.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +getPrivLibsByDoc(); +cid=1 +pid=1 + +正常查询 >> 900 +正常查询统计 >> 600 + +*/ +global $tester; +$doc = $tester->loadModel('doc'); + +r($doc->getPrivLibsByDoc()) && p('900') && e('900');//正常查询 +r(count($doc->getPrivLibsByDoc())) && p() && e('600');//正常查询统计 \ No newline at end of file diff --git a/test/model/doc/getproductcrumb.php b/test/model/doc/getproductcrumb.php new file mode 100644 index 0000000000..b252657206 --- /dev/null +++ b/test/model/doc/getproductcrumb.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getProductCrumb(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getProductCrumbTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getstatisticinfo.php b/test/model/doc/getstatisticinfo.php new file mode 100644 index 0000000000..26ceba1733 --- /dev/null +++ b/test/model/doc/getstatisticinfo.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getStatisticInfo(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getStatisticInfoTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/getsublibgroups.php b/test/model/doc/getsublibgroups.php new file mode 100644 index 0000000000..5e01e31131 --- /dev/null +++ b/test/model/doc/getsublibgroups.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getSubLibGroups(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getSubLibGroupsTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/gettoandcclist.php b/test/model/doc/gettoandcclist.php new file mode 100644 index 0000000000..8be6905993 --- /dev/null +++ b/test/model/doc/gettoandcclist.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getToAndCcList(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getToAndCcListTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/gettreemenu.php b/test/model/doc/gettreemenu.php new file mode 100644 index 0000000000..d94649bdaf --- /dev/null +++ b/test/model/doc/gettreemenu.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getTreeMenu(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->getTreeMenuTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/printchildmodule.php b/test/model/doc/printchildmodule.php new file mode 100644 index 0000000000..9a237d4e96 --- /dev/null +++ b/test/model/doc/printchildmodule.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +printChildModule(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->printChildModuleTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/savedraft.php b/test/model/doc/savedraft.php new file mode 100644 index 0000000000..9153c3fc9d --- /dev/null +++ b/test/model/doc/savedraft.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +saveDraft(); +cid=1 +pid=1 + + + +*/ +$docIDList = array('17', '118', '217'); +$content = array('content' => '测试'); + +$doc = new docTest(); +r($doc->saveDraftTest($docIDList[0], $content)) && p('17:draft') && e('测试');//产品文档内容保存 +r($doc->saveDraftTest($docIDList[1], $content)) && p('118:draft') && e('测试');//项目文档内容保存 +r($doc->saveDraftTest($docIDList[2], $content)) && p('217:draft') && e('测试');//执行文档内容保存 +r($doc->saveDraftTest($docIDList[0])) && p('17:draft') && e('测试');//文档无内容保存 + +system("./ztest init"); \ No newline at end of file diff --git a/test/model/doc/select.php b/test/model/doc/select.php new file mode 100644 index 0000000000..76d998c270 --- /dev/null +++ b/test/model/doc/select.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +select(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->selectTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/setfastmenu.php b/test/model/doc/setfastmenu.php new file mode 100644 index 0000000000..102ce1f6d8 --- /dev/null +++ b/test/model/doc/setfastmenu.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +setFastMenu(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->setFastMenuTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/setlibusers.php b/test/model/doc/setlibusers.php new file mode 100644 index 0000000000..0485e11ee1 --- /dev/null +++ b/test/model/doc/setlibusers.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +setLibUsers(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->setLibUsersTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/setmenubytype.php b/test/model/doc/setmenubytype.php new file mode 100644 index 0000000000..c1b08d8df8 --- /dev/null +++ b/test/model/doc/setmenubytype.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +setMenuByType(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->setMenuByTypeTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/statlibcounts.php b/test/model/doc/statlibcounts.php new file mode 100644 index 0000000000..730df24862 --- /dev/null +++ b/test/model/doc/statlibcounts.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +statLibCounts(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->statLibCountsTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/summary.php b/test/model/doc/summary.php new file mode 100644 index 0000000000..1c750a7518 --- /dev/null +++ b/test/model/doc/summary.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +summary(); +cid=1 +pid=1 + + + +*/ + +$doc = new docTest(); + +r($doc->summaryTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/doc/update.php b/test/model/doc/update.php new file mode 100644 index 0000000000..21ee7ccc0c --- /dev/null +++ b/test/model/doc/update.php @@ -0,0 +1,47 @@ +#!/usr/bin/env php +update(); +cid=1 +pid=1 + + + +*/ +$docID = array('1', '2', '3', '4', '5', '6', '7', '8'); +$libIDs = array('1', '117', '217', '821'); +$type = array('text', 'url', 'execution', 'custom', ''); +$acl = array('', 'open', 'custom', 'private'); +$groups = array('1', '2', '3'); +$users = array('admin', 'dev1', 'dev10'); + +$updateProductDoc = array('lib' => $libIDs[0], 'title' => '修改产品文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$updateProjectDoc = array('lib' => $libIDs[1], 'title' => '修改项目文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$updateExecutionDoc = array('lib' => $libIDs[2], 'title' => '修改执行文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$updateCustomDoc = array('lib' => $libIDs[3], 'title' => '修改自定义文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$updateUrlDoc = array('lib' => $libIDs[0], 'title' => '修改URL文档', 'type' => $type[1], 'url' => 'www.baidu.com', 'acl' => $acl[1]); +$privateDoc = array('lib' => $libIDs[0], 'title' => '修改私有文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[3]); +$customDoc = array('lib' => $libIDs[0], 'title' => '修改自定义文档', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[2], 'groups' => $groups, 'users' => $users); +$noLib = array('title' => '无文档库', 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$noTitle = array('lib' => $libIDs[0], 'type' => $type[0], 'contentType' => 'html', 'acl' => $acl[1]); +$noType = array('lib' => $libIDs[0], 'title' => '无TYPE', 'contentType' => 'html', 'acl' => $acl[1]); + +$doc = new docTest(); + +r($doc->updateTest($docID[0], $updateProductDoc)) && p('1:field,old,new') && e('title,文档标题901,修改产品文档');//修改为产品文档 +r($doc->updateTest($docID[1], $updateProjectDoc)) && p('1:field,old,new') && e('module,3622,0'); //修改为项目文档 +r($doc->updateTest($docID[2], $updateExecutionDoc)) && p('2:field,old,new') && e('title,文档标题903,修改执行文档');//修改为执行文档 +r($doc->updateTest($docID[3], $updateCustomDoc)) && p('3:field,old,new') && e('keywords,关键词4,'); //修改为自定义文档 +r($doc->updateTest($docID[4], $updateUrlDoc)) && p('4:field,old,new') && e('type,text,url'); //修改为url文档 +r($doc->updateTest($docID[6], $privateDoc)) && p('6:field,old,new') && e('acl,open,private'); //修改为私有文档 +r($doc->updateTest($docID[7], $customDoc)) && p('7:field,old,new') && e('groups,1,1,2,3'); //修改为自定义文档 +r($doc->updateTest($docID[0], $noLib)) && p('0:field,old,new') && e('lib,1,'); //修改lib为空 +r($doc->updateTest($docID[0], $noTitle)) && p('title:0') && e('『文档标题』不能为空。'); //修改标题为空 +r($doc->updateTest($docID[0], $noType)) && p('2:field,old,new') && e('type,text,'); //修改type为空 + +system("./ztest init"); \ No newline at end of file diff --git a/test/model/doc/updateapilib.php b/test/model/doc/updateapilib.php new file mode 100644 index 0000000000..6fa09031a1 --- /dev/null +++ b/test/model/doc/updateapilib.php @@ -0,0 +1,37 @@ +#!/usr/bin/env php +updateApiLib(); +cid=1 +pid=1 + +正常修改接口库 >> name,接口库,修改api文档库;baseUrl,,www.zentaopms.com;acl,private,open +修改users >> users,admin,test1 +修改名字为空 >> 『接口库名称』不能为空。 +修改成重复名称 >> 0 + +*/ +$ids = array('901', '902'); +$acl = array('', 'open', 'custom', 'private'); +$groups = array('1', '2', '3'); +$users = array('admin', 'dev1', 'dev10'); + +$openApilib = array('name' => '修改api文档库', 'baseUrl' => 'www.zentaopms.com', 'acl' => $acl[1], 'users' => 'admin', 'desc' => ''); +$updateUsers = array('users' => 'test1'); +$updateDesc = array('desc' => '修改详情'); +$noName = array('name' => ''); +$repeatName = array('name' => '修改api文档库'); + +$doc = new docTest(); + +r($doc->updateApiLibTest($ids[0], $openApilib)) && p('0:field,old,new;1:field,old,new;2:field,old,new') && e('name,接口库,修改api文档库;baseUrl,,www.zentaopms.com;acl,private,open');//正常修改接口库 +r($doc->updateApiLibTest($ids[0], $updateUsers)) && p('0:field,old,new') && e('users,admin,test1'); //修改users +r($doc->updateApiLibTest($ids[0], $noName)) && p('name:0') && e('『接口库名称』不能为空。'); //修改名字为空 +r($doc->updateApiLibTest($ids[0], $repeatName)) && p() && e('0'); //修改成重复名称 + +system("./ztest init"); \ No newline at end of file diff --git a/test/model/doc/updatelib.php b/test/model/doc/updatelib.php new file mode 100644 index 0000000000..ca022ed8f0 --- /dev/null +++ b/test/model/doc/updatelib.php @@ -0,0 +1,57 @@ +#!/usr/bin/env php +updateLib(); +cid=1 +pid=1 + +正常修改产品文档库 >> type,product,project +正常修改项目文档库 >> project,27,11 +正常修改执行文档库 >> product,0,1 +正常修改自定义文档库 >> product,17,1 +正常修改无type >> type,custom, +正常修改无产品 >> 『产品库』应当是数字。 +正常修改无项目 >> 『project』应当是数字。』 +正常修改无迭代 >> 『迭代库』应当是数字。 +正常修改无文档库名 >> 『文档库名称』不能为空。 + +*/ +$docLibIds = array('17', '117', '217'); +$type = array('product', 'project', 'execution', 'custom', ''); +$product = array('', '1'); +$project = array('', '11'); +$execution = array('', '101'); +$name = array('', '新建文档库'); +$acl = array('', 'default', 'custom'); +$groups = array('1', '2', '3'); +$users = array('admin', 'dev1', 'dev10'); + +$updateProduct = array('type' => $type[0], 'product' => $product[1], 'name' => $name[1], 'acl' => $acl[1]); +$updateProject = array('type' => $type[1], 'project' => $project[1], 'name' => $name[1], 'acl' => $acl[1]); +$updateExecution = array('type' => $type[2], 'execution' => $execution[1], 'name' => $name[1], 'acl' => $acl[1]); +$updateCustom = array('type' => $type[3], 'name' => $name[1], 'acl' => $acl[1]); +$customLib = array('type' => $type[0], 'product' => $product[1], 'name' => $name[1], 'acl' => $acl[2], 'groups' => $groups, 'users' => $users); +$noType = array('type' => $type[4], 'product' => $product[1], 'name' => $name[1], 'acl' => $acl[1]); +$noProduct = array('type' => $type[0], 'product' => $product[0], 'name' => $name[1], 'acl' => $acl[1]); +$noProject = array('type' => $type[1], 'project' => $project[0], 'name' => $name[1], 'acl' => $acl[1]); +$noExecution = array('type' => $type[2], 'execution' => $execution[0], 'name' => $name[1], 'acl' => $acl[1]); +$noName = array('type' => $type[0], 'product' => $product[1], 'name' => $name[0], 'acl' => $acl[0]); + +$doc = new docTest(); + +r($doc->updateLibTest($docLibIds[0],$updateProject)) && p('0:field,old,new') && e('type,product,project'); //正常修改产品文档库 +r($doc->updateLibTest($docLibIds[1],$updateProduct)) && p('1:field,old,new') && e('project,27,11'); //正常修改项目文档库 +r($doc->updateLibTest($docLibIds[2],$updateExecution)) && p('2:field,old,new') && e('product,0,1'); //正常修改执行文档库 +r($doc->updateLibTest($docLibIds[0],$updateCustom)) && p('1:field,old,new') && e('product,17,1'); //正常修改自定义文档库 +r($doc->updateLibTest($docLibIds[0],$noType)) && p('0:field,old,new') && e('type,custom,'); //正常修改无type +r($doc->updateLibTest($docLibIds[0],$noProduct)) && p('product:0') && e('『产品库』应当是数字。'); //正常修改无产品 +r($doc->updateLibTest($docLibIds[0],$noProject)) && p('project:0') && e('『project』应当是数字。』');//正常修改无项目 +r($doc->updateLibTest($docLibIds[0],$noExecution)) && p('execution:0') && e('『迭代库』应当是数字。'); //正常修改无迭代 +r($doc->updateLibTest($docLibIds[0],$noName)) && p('name:0') && e('『文档库名称』不能为空。'); //正常修改无文档库名 + +system("./ztest init"); \ No newline at end of file From 8d1f35aaf99b5f439b1e7a4fa891b479fdfc96b4 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Fri, 6 May 2022 17:32:59 +0800 Subject: [PATCH 05/41] * Add for git unit. --- module/git/model.php | 105 +------------------------ test/class/git.class.php | 131 ++++++++++++++++++++++++++++++++ test/model/git/convertlog.php | 29 +++++++ test/model/git/getrepologs.php | 36 +++++++++ test/model/git/getrepos.php | 25 ++++++ test/model/git/getrepotags.php | 36 +++++++++ test/model/git/setrepo.php | 27 +++++++ test/model/git/setrepos.php | 21 +++++ test/model/git/updatecommit.php | 30 ++++++++ test/ztest | 3 + 10 files changed, 342 insertions(+), 101 deletions(-) create mode 100644 test/class/git.class.php create mode 100755 test/model/git/convertlog.php create mode 100755 test/model/git/getrepologs.php create mode 100755 test/model/git/getrepos.php create mode 100755 test/model/git/getrepotags.php create mode 100755 test/model/git/setrepo.php create mode 100755 test/model/git/setrepos.php create mode 100755 test/model/git/updatecommit.php diff --git a/module/git/model.php b/module/git/model.php index 7f4aaa9ef1..b5247a16f9 100644 --- a/module/git/model.php +++ b/module/git/model.php @@ -194,7 +194,6 @@ class gitModel extends model $commits += count($logs); } } - } $this->repo->updateCommitCount($repo->id, $commits); @@ -296,6 +295,8 @@ class gitModel extends model */ public function getRepoTags($repo) { + if(empty($repo->client) or empty($repo->path) or !isset($repo->account) or !isset($repo->password) or !isset($repo->encoding)) return false; + $scm = $this->app->loadClass('scm'); $scm->setEngine($repo); return $scm->tags(''); @@ -311,6 +312,8 @@ class gitModel extends model */ public function getRepoLogs($repo, $fromRevision) { + if(empty($repo->client) or empty($repo->path) or !isset($repo->account) or !isset($repo->password) or !isset($repo->encoding)) return false; + $scm = $this->app->loadClass('scm'); $scm->setEngine($repo); $logs = $scm->log('', $fromRevision); @@ -371,106 +374,6 @@ class gitModel extends model return $parsedLog; } - /** - * Diff a url. - * - * @param string $path - * @param int $revision - * @access public - * @return string|bool - */ - public function diff($path, $revision) - { - $repo = $this->getRepoByURL($path); - if(!$repo) return false; - - $this->setClient($repo); - if(empty($this->client)) return false; - putenv('LC_CTYPE=en_US.UTF-8'); - - chdir($repo->path); - exec("{$this->client} config core.quotepath false"); - $subPath = substr($path, strlen($repo->path)); - if($subPath[0] == '/' or $subPath[0] == '\\') $subPath = substr($subPath, 1); - - $encodings = explode(',', $this->config->git->encodings); - foreach($encodings as $encoding) - { - $encoding = trim($encoding); - if($encoding == 'utf-8') continue; - $subPath = helper::convertEncoding($subPath, 'utf-8', $encoding); - if($subPath) break; - } - - exec("$this->client rev-list -n 2 $revision -- $subPath", $lists); - if(count($lists) == 2) list($nowRevision, $preRevision) = $lists; - $cmd = "$this->client diff $preRevision $nowRevision -- $subPath 2>&1"; - $diff = `$cmd`; - - $encoding = isset($repo->encoding) ? $repo->encoding : 'utf-8'; - if($encoding and $encoding != 'utf-8') $diff = helper::convertEncoding($diff, $encoding); - - return $diff; - } - - /** - * Cat a url. - * - * @param string $path - * @param int $revision - * @access public - * @return string|bool - */ - public function cat($path, $revision) - { - $repo = $this->getRepoByURL($path); - if(!$repo) return false; - - $this->setClient($repo); - if(empty($this->client)) return false; - - putenv('LC_CTYPE=en_US.UTF-8'); - - $subPath = substr($path, strlen($repo->path)); - if($subPath[0] == '/' or $subPath[0] == '\\') $subPath = substr($subPath, 1); - - $encodings = explode(',', $this->config->git->encodings); - foreach($encodings as $encoding) - { - $encoding = trim($encoding); - if($encoding == 'utf-8') continue; - $subPath = helper::convertEncoding($subPath, 'utf-8', $encoding); - if($subPath) break; - } - - chdir($repo->path); - exec("{$this->client} config core.quotepath false"); - $cmd = "$this->client show $revision:$subPath 2>&1"; - $code = `$cmd`; - - $encoding = isset($repo->encoding) ? $repo->encoding : 'utf-8'; - if($encoding and $encoding != 'utf-8') $code = helper::convertEncoding($code, $encoding); - - return $code; - } - - /** - * Get repo by url. - * - * @param string $url - * @access public - * @return object|bool - */ - public function getRepoByURL($url) - { - foreach($this->config->git->repos as $repo) - { - if(empty($repo['path'])) continue; - if(strpos($url, $repo['path']) !== false) return (object)$repo; - } - return false; - } - /** * Pring log. * diff --git a/test/class/git.class.php b/test/class/git.class.php new file mode 100644 index 0000000000..6478e17bb5 --- /dev/null +++ b/test/class/git.class.php @@ -0,0 +1,131 @@ +tester = $tester; + $this->gitModel = $this->tester->loadModel('git'); + } + + /** + * Run + * + * @access public + * @return void + */ + public function run() + { + return $this->gitModel->run(); + } + + /** + * Update commit. + * + * @param object $repo + * @param array $commentGroup + * @param bool $printLog + * @access public + * @return string + */ + public function updateCommit($repo) + { + $repoID = isset($repo->id) ? $repo->id : 0; + $oldLastSync = $this->tester->dao->select('lastSync')->from(TABLE_REPO)->where('id')->eq($repoID)->fetch('lastSync'); + $result = $this->gitModel->updateCommit($repo, array(), false); + if(empty($repoID)) return $result; + $newLastSync = $this->tester->dao->select('lastSync')->from(TABLE_REPO)->where('id')->eq($repoID)->fetch('lastSync'); + return $oldLastSync != $newLastSync; + } + + /** + * Set the repos. + * + * @access public + * @return mixed + */ + public function setRepos() + { + $this->gitModel->setRepos(); + $repo = array_shift($this->gitModel->repos); + return $repo; + } + + /** + * Get repos. + * + * @access public + * @return array + */ + public function getRepos() + { + $pairs = $this->gitModel->getRepos(); + return array_shift($pairs); + } + + /** + * Set repo. + * + * @param object $repo + * @access public + * @return bool + */ + public function setRepo($repo) + { + $this->gitModel->client = ''; + $this->gitModel->repoRoot = ''; + + $result = $this->gitModel->setRepo($repo); + + $data = new stdclass(); + $data->result = $result; + $data->client = !empty($this->gitModel->client); + $data->repoRoot = !empty($this->gitModel->repoRoot); + return $data; + } + + /** + * get tags histories for repo. + * + * @param object $repo + * @access public + * @return mixed + */ + public function getRepoTags($repo) + { + $tags = $this->gitModel->getRepoTags($repo); + if(is_array($tags) and count($tags) >= 1) return 1; + return 0; + } + + /** + * Get repo logs. + * + * @param object $repo + * @param int $fromRevision + * @access public + * @return array + */ + public function getRepoLogs($repo) + { + $logs = $this->gitModel->getRepoLogs($repo, ''); + if(is_array($logs) and count($logs) >= 1) return 1; + return 0; + } + + /** + * Convert log from xml format to object. + * + * @param object $log + * @access public + * @return object + */ + public function convertLog($log) + { + $parsedLogs = $this->gitModel->convertLog($log); + if(empty($parsedLogs->revision)) $parsedLogs->revision = 0; + return $parsedLogs; + } +} diff --git a/test/model/git/convertlog.php b/test/model/git/convertlog.php new file mode 100755 index 0000000000..0ff4c58935 --- /dev/null +++ b/test/model/git/convertlog.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +convertLog(); +cid=1 +pid=1 + +使用正确格式的数据 >> e7699d04f1586d337f34496da932dde55db92616 +使用空数据 >> 0 + +*/ + +$git = new gitTest(); + +$log[] = "commit e7699d04f1586d337f34496da932dde55db92616"; +$log[] = "Author: zhengrunyu "; +$log[] = "Date: Thu May 5 16:19:48 2022 +0800"; +$log[] = " * Fix bug 22061."; +r($git->convertLog($log)) && p('revision') && e('e7699d04f1586d337f34496da932dde55db92616'); // 使用正确格式的数据 + +$log = array(); +r($git->convertLog($log)) && p('revision') && e(0); // 使用空的数据 + +system("./ztest init"); diff --git a/test/model/git/getrepologs.php b/test/model/git/getrepologs.php new file mode 100755 index 0000000000..b2e1dac8c9 --- /dev/null +++ b/test/model/git/getrepologs.php @@ -0,0 +1,36 @@ +#!/usr/bin/env php +getRepoLogs(); +cid=1 +pid=1 + +获取版本库的tags >> 1 +使用空数据 >> 0 +使用错误的版本库 >> 0 + +*/ + +$git = new gitTest(); + +/* Fix error Gitlab url. */ +$tester->dao->update(TABLE_PIPELINE)->set('url')->eq('http://10.0.1.161:51080')->where('id')->eq(1)->exec(); + +$repo = $tester->dao->select('*')->from(TABLE_REPO)->limit(1)->fetch(); +if(strtolower($repo->SCM) == 'gitlab') $repo = $tester->loadModel('repo')->processGitlab($repo); +r($git->getRepoLogs($repo)) && p() && e(1); // 获取版本库的tags + +$repo = new stdclass(); +r($git->getRepoLogs($repo)) && p() && e(0); // 使用空数据 + +$repo = new stdclass(); +$repo->client = ''; +$repo->path = ''; +r($git->getRepoLogs($repo)) && p() && e(0); // 使用错误的版本库 + +system("./ztest init"); diff --git a/test/model/git/getrepos.php b/test/model/git/getrepos.php new file mode 100755 index 0000000000..0d7260bc9f --- /dev/null +++ b/test/model/git/getrepos.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +getRepos(); +cid=1 +pid=1 + +获取版本库 >> http://10.0.1.161:51080/api/v4/projects/42/repository/ + +*/ + +$git = new gitTest(); + +/* Fix error Gitlab url. */ +$tester->dao->update(TABLE_PIPELINE)->set('url')->eq('http://10.0.1.161:51080')->where('id')->eq(1)->exec(); + +$tester->dao->update(TABLE_REPO)->set('synced')->eq(1)->where('id')->eq(1)->exec(); +r($git->getRepos()) && p() && e('http://192.168.1.161:51080/api/v4/projects/42/repository/'); // 获取版本库 + +system("./ztest init"); diff --git a/test/model/git/getrepotags.php b/test/model/git/getrepotags.php new file mode 100755 index 0000000000..79f46b5a2e --- /dev/null +++ b/test/model/git/getrepotags.php @@ -0,0 +1,36 @@ +#!/usr/bin/env php +getRepoTags(); +cid=1 +pid=1 + +获取版本库的tags >> 1 +使用空数据 >> 0 +使用错误的版本库 >> 0 + +*/ + +$git = new gitTest(); + +/* Fix error Gitlab url. */ +$tester->dao->update(TABLE_PIPELINE)->set('url')->eq('http://10.0.1.161:51080')->where('id')->eq(1)->exec(); + +$repo = $tester->dao->select('*')->from(TABLE_REPO)->limit(1)->fetch(); +if(strtolower($repo->SCM) == 'gitlab') $repo = $tester->loadModel('repo')->processGitlab($repo); +r($git->getRepoTags($repo)) && p() && e(1); // 获取版本库的tags + +$repo = new stdclass(); +r($git->getRepoTags($repo)) && p() && e(0); // 使用空数据 + +$repo = new stdclass(); +$repo->client = ''; +$repo->path = ''; +r($git->getRepoTags($repo)) && p() && e(0); // 使用错误的版本库 + +system("./ztest init"); diff --git a/test/model/git/setrepo.php b/test/model/git/setrepo.php new file mode 100755 index 0000000000..46af69a3c9 --- /dev/null +++ b/test/model/git/setrepo.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +setRepo(); +cid=1 +pid=1 + +设置错误版本号参数 >> ,, +设置正确版本号参数 >> 1,1,1 + +*/ + +$git = new gitTest(); + +$repo = new stdclass(); +r($git->setRepo($repo)) && p("result,client,repoRoot") && e(",,"); // 设置错误版本库参数 + +$repo = $tester->dao->select('*')->from(TABLE_REPO)->limit(1)->fetch(); +if(strtolower($repo->SCM) == 'gitlab') $repo = $tester->loadModel('repo')->processGitlab($repo); +r($git->setRepo($repo)) && p("result,client,repoRoot") && e("1,1,1"); // 设置正确版本库参数 + +system("./ztest init"); diff --git a/test/model/git/setrepos.php b/test/model/git/setrepos.php new file mode 100755 index 0000000000..33df336ce5 --- /dev/null +++ b/test/model/git/setrepos.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +setRepos(); +cid=1 +pid=1 + +设置版本库 >> 1 + +*/ + +$git = new gitTest(); +$tester->dao->update(TABLE_REPO)->set('synced')->eq(1)->where('id')->eq(1)->exec(); +r($git->setRepos()) && p('id') && e(1); // 设置版本库 + +system("./ztest init"); diff --git a/test/model/git/updatecommit.php b/test/model/git/updatecommit.php new file mode 100755 index 0000000000..6e75cb6323 --- /dev/null +++ b/test/model/git/updatecommit.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +updatecommit(); +cid=1 +pid=1 + +测试正常的版本库 >> 1 +测试空的版本库 >> 0 + +*/ + +$git = new gitTest(); + +/* Fix error Gitlab url. */ +$tester->dao->update(TABLE_PIPELINE)->set('url')->eq('http://10.0.1.161:51080')->where('id')->eq(1)->exec(); + +$repo = $tester->dao->select('*')->from(TABLE_REPO)->limit(1)->fetch(); +if(strtolower($repo->SCM) == 'gitlab') $repo = $tester->loadModel('repo')->processGitlab($repo); +r($git->updateCommit($repo)) && p() && e(1); // 测试正常的版本库 + +$repo = new stdclass(); +r($git->updateCommit($repo)) && p() && e(0); // 测试空的版本库 + +system("./ztest init"); diff --git a/test/ztest b/test/ztest index 73056510a0..cfb9cad01a 100755 --- a/test/ztest +++ b/test/ztest @@ -55,6 +55,9 @@ switch($argv[1]) case 'execution': ztfRun('model/execution'); break; + case 'git': + ztfRun('model/git'); + break; case 'group': ztfRun('model/group'); break; From 95ae927251272dbaae9ed39c3688a071c8f7d536 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Sat, 7 May 2022 08:31:55 +0800 Subject: [PATCH 06/41] * Add test case file. --- module/setting/model.php | 9 +- test/class/setting.class.php | 126 ++++++++++++++++++ test/model/setting/createdao.php | 17 +++ test/model/setting/deleteitems.php | 17 +++ test/model/setting/getitem.php | 17 +++ test/model/setting/getitems.php | 17 +++ .../model/setting/getsysandpersonalconfig.php | 17 +++ test/model/setting/getursr.php | 17 +++ test/model/setting/getversion.php | 17 +++ test/model/setting/parseitemparam.php | 17 +++ test/model/setting/setitem.php | 17 +++ test/model/setting/setitems.php | 17 +++ test/model/setting/setsn.php | 17 +++ test/model/setting/snneededupdate.php | 17 +++ test/model/setting/updateversion.php | 17 +++ test/ztest | 3 + 16 files changed, 357 insertions(+), 2 deletions(-) create mode 100644 test/class/setting.class.php create mode 100644 test/model/setting/createdao.php create mode 100644 test/model/setting/deleteitems.php create mode 100644 test/model/setting/getitem.php create mode 100644 test/model/setting/getitems.php create mode 100644 test/model/setting/getsysandpersonalconfig.php create mode 100644 test/model/setting/getursr.php create mode 100644 test/model/setting/getversion.php create mode 100644 test/model/setting/parseitemparam.php create mode 100644 test/model/setting/setitem.php create mode 100644 test/model/setting/setitems.php create mode 100644 test/model/setting/setsn.php create mode 100644 test/model/setting/snneededupdate.php create mode 100644 test/model/setting/updateversion.php diff --git a/module/setting/model.php b/module/setting/model.php index 72e55e0482..064c6f4aa2 100644 --- a/module/setting/model.php +++ b/module/setting/model.php @@ -77,8 +77,7 @@ class settingModel extends model $item->section = $section; $item->key = $key; $item->value = $value; - - if($vision) $item->vision = $vision; + $item->vision = empty($vision) ? '' : $vision; $this->dao->replace(TABLE_CONFIG)->data($item)->exec(); } @@ -164,6 +163,12 @@ class settingModel extends model */ public function createDAO($params, $method = 'select') { + $params['vision'] = isset($params['vision']) ? $params['vision'] : ''; + $params['owner'] = isset($params['owner']) ? $params['owner'] : ''; + $params['module'] = isset($params['module']) ? $params['module'] : ''; + $params['section'] = isset($params['section']) ? $params['section'] : ''; + $params['key'] = isset($params['key']) ? $params['key'] : ''; + return $this->dao->$method('*')->from(TABLE_CONFIG)->where('1 = 1') ->beginIF($params['vision'])->andWhere('vision')->in($params['vision'])->fi() ->beginIF($params['owner'])->andWhere('owner')->in($params['owner'])->fi() diff --git a/test/class/setting.class.php b/test/class/setting.class.php new file mode 100644 index 0000000000..7c6639ea28 --- /dev/null +++ b/test/class/setting.class.php @@ -0,0 +1,126 @@ +objectModel = $tester->loadModel('setting'); + } + + public function getItemTest($paramString) + { + $objects = $this->objectModel->getItem($paramString); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getItemsTest($paramString) + { + $objects = $this->objectModel->getItems($paramString); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function setItemTest($path, $value = '') + { + $objects = $this->objectModel->setItem($path, $value = ''); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function setItemsTest($path, $items) + { + $objects = $this->objectModel->setItems($path, $items); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function deleteItemsTest($paramString) + { + $objects = $this->objectModel->deleteItems($paramString); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function parseItemParamTest($paramString) + { + $objects = $this->objectModel->parseItemParam($paramString); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function createDAOTest($params, $method = 'select') + { + $objects = $this->objectModel->createDAO($params, $method = 'select'); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getSysAndPersonalConfigTest($account = '') + { + $objects = $this->objectModel->getSysAndPersonalConfig($account = ''); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getVersionTest() + { + $objects = $this->objectModel->getVersion(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getURSRTest() + { + $objects = $this->objectModel->getURSR(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function updateVersionTest($version) + { + $objects = $this->objectModel->updateVersion($version); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function setSNTest() + { + $objects = $this->objectModel->setSN(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function snNeededUpdateTest($sn) + { + $objects = $this->objectModel->snNeededUpdate($sn); + + if(dao::isError()) return dao::getError(); + + return $objects; + } +} diff --git a/test/model/setting/createdao.php b/test/model/setting/createdao.php new file mode 100644 index 0000000000..1e5b299bb8 --- /dev/null +++ b/test/model/setting/createdao.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +createDAO(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->createDAOTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/deleteitems.php b/test/model/setting/deleteitems.php new file mode 100644 index 0000000000..f4e098ab30 --- /dev/null +++ b/test/model/setting/deleteitems.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +deleteItems(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->deleteItemsTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/getitem.php b/test/model/setting/getitem.php new file mode 100644 index 0000000000..5f225edb7e --- /dev/null +++ b/test/model/setting/getitem.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getItem(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->getItemTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/getitems.php b/test/model/setting/getitems.php new file mode 100644 index 0000000000..26a599d319 --- /dev/null +++ b/test/model/setting/getitems.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getItems(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->getItemsTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/getsysandpersonalconfig.php b/test/model/setting/getsysandpersonalconfig.php new file mode 100644 index 0000000000..8342b1ed77 --- /dev/null +++ b/test/model/setting/getsysandpersonalconfig.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getSysAndPersonalConfig(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->getSysAndPersonalConfigTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/getursr.php b/test/model/setting/getursr.php new file mode 100644 index 0000000000..6a0239cf07 --- /dev/null +++ b/test/model/setting/getursr.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getURSR(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->getURSRTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/getversion.php b/test/model/setting/getversion.php new file mode 100644 index 0000000000..8c9a982342 --- /dev/null +++ b/test/model/setting/getversion.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getVersion(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->getVersionTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/parseitemparam.php b/test/model/setting/parseitemparam.php new file mode 100644 index 0000000000..a121884eb0 --- /dev/null +++ b/test/model/setting/parseitemparam.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +parseItemParam(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->parseItemParamTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/setitem.php b/test/model/setting/setitem.php new file mode 100644 index 0000000000..698edea9f0 --- /dev/null +++ b/test/model/setting/setitem.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +setItem(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->setItemTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/setitems.php b/test/model/setting/setitems.php new file mode 100644 index 0000000000..90161bb8d3 --- /dev/null +++ b/test/model/setting/setitems.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +setItems(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->setItemsTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/setsn.php b/test/model/setting/setsn.php new file mode 100644 index 0000000000..2d8092362f --- /dev/null +++ b/test/model/setting/setsn.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +setSN(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->setSNTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/snneededupdate.php b/test/model/setting/snneededupdate.php new file mode 100644 index 0000000000..c1c0b73aa0 --- /dev/null +++ b/test/model/setting/snneededupdate.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +snNeededUpdate(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->snNeededUpdateTest()) && p() && e(); \ No newline at end of file diff --git a/test/model/setting/updateversion.php b/test/model/setting/updateversion.php new file mode 100644 index 0000000000..150d77e580 --- /dev/null +++ b/test/model/setting/updateversion.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +updateVersion(); +cid=1 +pid=1 + +*/ + +$setting = new settingTest(); + +r($setting->updateVersionTest()) && p() && e(); \ No newline at end of file diff --git a/test/ztest b/test/ztest index 61374a132c..5038673164 100755 --- a/test/ztest +++ b/test/ztest @@ -88,6 +88,9 @@ switch($argv[1]) case 'report': ztfRun('model/report'); break; + case 'setting': + ztfRun('model/setting'); + break; case 'stage': ztfRun('model/stage'); break; From a6d2780d2e84da88781c6be2460cf51f7dc818c8 Mon Sep 17 00:00:00 2001 From: renying Date: Sat, 7 May 2022 08:37:36 +0800 Subject: [PATCH 07/41] Add weekly module auto test. --- module/weekly/model.php | 2 +- test/class/weekly.class.php | 120 +++++++++++++++++++--- test/model/weekly/getac.php | 16 ++- test/model/weekly/getcv.php | 23 ++++- test/model/weekly/getev.php | 16 ++- test/model/weekly/getfinished.php | 17 ++- test/model/weekly/getplanedtaskbyweek.php | 16 ++- test/model/weekly/getpostponed.php | 16 ++- test/model/weekly/getpv.php | 17 ++- test/model/weekly/getstaff.php | 17 ++- test/model/weekly/getsv.php | 22 +++- test/model/weekly/gettasksofnextweek.php | 17 ++- test/model/weekly/gettips.php | 16 ++- test/model/weekly/getworkloadbytype.php | 11 +- 14 files changed, 301 insertions(+), 25 deletions(-) mode change 100644 => 100755 test/model/weekly/getac.php mode change 100644 => 100755 test/model/weekly/getcv.php mode change 100644 => 100755 test/model/weekly/getev.php mode change 100644 => 100755 test/model/weekly/getfinished.php mode change 100644 => 100755 test/model/weekly/getplanedtaskbyweek.php mode change 100644 => 100755 test/model/weekly/getpostponed.php mode change 100644 => 100755 test/model/weekly/getpv.php mode change 100644 => 100755 test/model/weekly/getstaff.php mode change 100644 => 100755 test/model/weekly/getsv.php mode change 100644 => 100755 test/model/weekly/gettasksofnextweek.php mode change 100644 => 100755 test/model/weekly/gettips.php mode change 100644 => 100755 test/model/weekly/getworkloadbytype.php diff --git a/module/weekly/model.php b/module/weekly/model.php index 14c4cc7287..a2d7d5c460 100755 --- a/module/weekly/model.php +++ b/module/weekly/model.php @@ -343,7 +343,7 @@ class weeklyModel extends model $monday = $this->getThisMonday($date); $nextMonday = date('Y-m-d', strtotime("$monday +7 days")); - $executions = $this->loadModel('execution')->getList($status = 'all', $limit = 0, $productID = 0, $branch = 0, $project); + $executions = $this->loadModel('execution')->getList($project); $executionIdList = array_keys($executions); return $this->dao->select('*') diff --git a/test/class/weekly.class.php b/test/class/weekly.class.php index 38acef0d86..8a1f67ee13 100644 --- a/test/class/weekly.class.php +++ b/test/class/weekly.class.php @@ -79,87 +79,167 @@ class weeklyTest return $objects; } + /** + * Test getStaff + * + * @param int $project + * @param string $date + * @access public + * @return array + */ public function getStaffTest($project, $date = '') { - $objects = $this->objectModel->getStaff($project, $date = ''); + $objects = $this->objectModel->getStaff($project, $date); if(dao::isError()) return dao::getError(); return $objects; } - public function getFinishedTest($project, $date = '', $pager = null) + /** + * Test getFinished + * + * @param int $project + * @param string $date + * @access public + * @return void + */ + public function getFinishedTest($project, $date = '') { - $objects = $this->objectModel->getFinished($project, $date = '', $pager = null); + $objects = $this->objectModel->getFinished($project, $date); if(dao::isError()) return dao::getError(); return $objects; } + /** + * Test getPostponed + * + * @param int $project + * @param string $date + * @access public + * @return void + */ public function getPostponedTest($project, $date = '') { - $objects = $this->objectModel->getPostponed($project, $date = ''); + $objects = $this->objectModel->getPostponed($project, $date); if(dao::isError()) return dao::getError(); return $objects; } + /** + * Test getTasksOfNextWeek + * + * @param int $project + * @param string $date + * @access public + * @return void + */ public function getTasksOfNextWeekTest($project, $date = '') { - $objects = $this->objectModel->getTasksOfNextWeek($project, $date = ''); + $objects = $this->objectModel->getTasksOfNextWeek($project, $date); if(dao::isError()) return dao::getError(); return $objects; } + /** + * Test getWorkloadByType + * + * @param int $project + * @param string $date + * @access public + * @return object + */ public function getWorkloadByTypeTest($project, $date = '') { - $objects = $this->objectModel->getWorkloadByType($project, $date = ''); + $objects = $this->objectModel->getWorkloadByType($project, $date); if(dao::isError()) return dao::getError(); return $objects; } + /** + * Test getPlanedTaskByWeek + * + * @param int $project + * @param string $date + * @access public + * @return array + */ public function getPlanedTaskByWeekTest($project, $date = '') { - $objects = $this->objectModel->getPlanedTaskByWeek($project, $date = ''); + $objects = $this->objectModel->getPlanedTaskByWeek($project, $date); if(dao::isError()) return dao::getError(); return $objects; } + /** + * Test getPV + * + * @param int $project + * @param string $date + * @access public + * @return int + */ public function getPVTest($projectID, $date = '') { - $objects = $this->objectModel->getPV($projectID, $date = ''); + $objects = $this->objectModel->getPV($projectID, $date); if(dao::isError()) return dao::getError(); return $objects; } + /** + * Test get EV data. + * + * @param int $projectID + * @param string $date + * @access public + * @return int + */ public function getEVTest($projectID, $date = '') { - $objects = $this->objectModel->getEV($projectID, $date = ''); + $objects = $this->objectModel->getEV($projectID, $date); if(dao::isError()) return dao::getError(); return $objects; } + /** + * Test get AC data. + * + * @param int $project + * @param string $date + * @access public + * @return int + */ public function getACTest($project, $date = '') { - $objects = $this->objectModel->getAC($project, $date = ''); + $objects = $this->objectModel->getAC($project, $date); if(dao::isError()) return dao::getError(); return $objects; } + /** + * Test get SV data. + * + * @param int $ev + * @param int $pv + * @access public + * @return int + */ public function getSVTest($ev, $pv) { $objects = $this->objectModel->getSV($ev, $pv); @@ -169,6 +249,14 @@ class weeklyTest return $objects; } + /** + * Test getCV + * + * @param int $ev + * @param int $ac + * @access public + * @return int + */ public function getCVTest($ev, $ac) { $objects = $this->objectModel->getCV($ev, $ac); @@ -178,12 +266,20 @@ class weeklyTest return $objects; } + /** + * Test getTips + * + * @param string $type + * @param int $data + * @access public + * @return string + */ public function getTipsTest($type = 'progress', $data = 0) { - $objects = $this->objectModel->getTips($type = 'progress', $data = 0); + $objects = $this->objectModel->getTips($type, $data); if(dao::isError()) return dao::getError(); return $objects; } -} \ No newline at end of file +} diff --git a/test/model/weekly/getac.php b/test/model/weekly/getac.php old mode 100644 new mode 100755 index 2f7b99c48c..482a35417e --- a/test/model/weekly/getac.php +++ b/test/model/weekly/getac.php @@ -10,8 +10,22 @@ title=测试 weeklyModel->getAC(); cid=1 pid=1 +测试project值为0,date值为2022-05-01 >> 4191 +测试project值为0,date值为空 >> 4191 +测试project值为11,date值为2022-05-01 >> 21 +测试project值为11,date值为空 >> 21 +测试project值为41,date值为2022-05-01 >> 42 +测试project值为41,date值为空 >> 42 + */ +$projectList = array(0, 11, 41); +$dateList = array('2022-05-01', ''); $weekly = new weeklyTest(); -r($weekly->getACTest()) && p() && e(); \ No newline at end of file +r($weekly->getACTest($projectList[0], $dateList[0])) && p() && e('4191'); //测试project值为0,date值为2022-05-01 +r($weekly->getACTest($projectList[0], $dateList[1])) && p() && e('4191'); //测试project值为0,date值为空 +r($weekly->getACTest($projectList[1], $dateList[0])) && p() && e('21'); //测试project值为11,date值为2022-05-01 +r($weekly->getACTest($projectList[1], $dateList[1])) && p() && e('21'); //测试project值为11,date值为空 +r($weekly->getACTest($projectList[2], $dateList[0])) && p() && e('42'); //测试project值为41,date值为2022-05-01 +r($weekly->getACTest($projectList[2], $dateList[1])) && p() && e('42'); //测试project值为41,date值为空 \ No newline at end of file diff --git a/test/model/weekly/getcv.php b/test/model/weekly/getcv.php old mode 100644 new mode 100755 index 035abe4d24..2a00e9f2e6 --- a/test/model/weekly/getcv.php +++ b/test/model/weekly/getcv.php @@ -10,8 +10,29 @@ title=测试 weeklyModel->getCV(); cid=1 pid=1 +测试ev值为0,ac值为0 >> 0 +测试ev值为0,ac值为10 >> -100.00 +测试ev值为0,ac值为100 >> -100.00 +测试ev值为10,ac值为0 >> 0 +测试ev值为10,ac值为10 >> 0.00 +测试ev值为10,ac值为100 >> -90.00 +测试ev值为100,ac值为0 >> 0 +测试ev值为100,ac值为10 >> 900.00 +测试ev值为100,ac值为100 >> 0.00 + */ +$evList = array(0, 10, 100); +$acList = array(0, 10, 100); + $weekly = new weeklyTest(); -r($weekly->getCVTest()) && p() && e(); \ No newline at end of file +r($weekly->getCVTest($evList[0], $acList[0])) && p() && e('0'); //测试ev值为0,ac值为0 +r($weekly->getCVTest($evList[0], $acList[1])) && p() && e('-100.00'); //测试ev值为0,ac值为10 +r($weekly->getCVTest($evList[0], $acList[2])) && p() && e('-100.00'); //测试ev值为0,ac值为100 +r($weekly->getCVTest($evList[1], $acList[0])) && p() && e('0'); //测试ev值为10,ac值为0 +r($weekly->getCVTest($evList[1], $acList[1])) && p() && e('0.00'); //测试ev值为10,ac值为10 +r($weekly->getCVTest($evList[1], $acList[2])) && p() && e('-90.00'); //测试ev值为10,ac值为100 +r($weekly->getCVTest($evList[2], $acList[0])) && p() && e('0'); //测试ev值为100,ac值为0 +r($weekly->getCVTest($evList[2], $acList[1])) && p() && e('900.00'); //测试ev值为100,ac值为10 +r($weekly->getCVTest($evList[2], $acList[2])) && p() && e('0.00'); //测试ev值为100,ac值为100 \ No newline at end of file diff --git a/test/model/weekly/getev.php b/test/model/weekly/getev.php old mode 100644 new mode 100755 index 95562a540d..b31ea7f474 --- a/test/model/weekly/getev.php +++ b/test/model/weekly/getev.php @@ -10,8 +10,22 @@ title=测试 weeklyModel->getEV(); cid=1 pid=1 +测试projectID值为0,date值为2022-05-01 >> 771.55 +测试projectID值为0,date值为空 >> 2342.78 +测试projectID值为11,date值为2022-05-01 >> 15.3 +测试projectID值为11,date值为空 >> 54.18 +测试projectID值为41,date值为2022-05-01 >> 6.91 +测试projectID值为41,date值为空 >> 19.87 + */ +$projectIDList = array(0, 11, 41); +$dateList = array('2022-05-01', ''); $weekly = new weeklyTest(); -r($weekly->getEVTest()) && p() && e(); \ No newline at end of file +r($weekly->getEVTest($projectIDList[0], $dateList[0])) && p() && e('771.55'); //测试projectID值为0,date值为2022-05-01 +r($weekly->getEVTest($projectIDList[0], $dateList[1])) && p() && e('2342.78'); //测试projectID值为0,date值为空 +r($weekly->getEVTest($projectIDList[1], $dateList[0])) && p() && e('15.3'); //测试projectID值为11,date值为2022-05-01 +r($weekly->getEVTest($projectIDList[1], $dateList[1])) && p() && e('54.18'); //测试projectID值为11,date值为空 +r($weekly->getEVTest($projectIDList[2], $dateList[0])) && p() && e('6.91'); //测试projectID值为41,date值为2022-05-01 +r($weekly->getEVTest($projectIDList[2], $dateList[1])) && p() && e('19.87'); //测试projectID值为41,date值为空 \ No newline at end of file diff --git a/test/model/weekly/getfinished.php b/test/model/weekly/getfinished.php old mode 100644 new mode 100755 index 38c5ad07e0..f0b2463fc9 --- a/test/model/weekly/getfinished.php +++ b/test/model/weekly/getfinished.php @@ -10,8 +10,23 @@ title=测试 weeklyModel->getFinished(); cid=1 pid=1 +测试project值为0,date值为2022-05-01 >> 0 +测试project值为0,date值为空 >> 0 +测试project值为1,date值为2022-05-01 >> 0 +测试project值为1,date值为空 >> 0 +测试project值为11,date值为2022-05-01 >> 0 +测试project值为11,date值为空 >> 0 + */ +$projectList = array(0, 1, 11); +$dateList = array('2022-05-01', ''); + $weekly = new weeklyTest(); -r($weekly->getFinishedTest()) && p() && e(); \ No newline at end of file +r($weekly->getFinishedTest($projectList[0], $dateList[0])) && p() && e('0'); //测试project值为0,date值为2022-05-01 +r($weekly->getFinishedTest($projectList[0], $dateList[1])) && p() && e('0'); //测试project值为0,date值为空 +r($weekly->getFinishedTest($projectList[1], $dateList[0])) && p() && e('0'); //测试project值为1,date值为2022-05-01 +r($weekly->getFinishedTest($projectList[1], $dateList[1])) && p() && e('0'); //测试project值为1,date值为空 +r($weekly->getFinishedTest($projectList[2], $dateList[0])) && p() && e('0'); //测试project值为11,date值为2022-05-01 +r($weekly->getFinishedTest($projectList[2], $dateList[1])) && p() && e('0'); //测试project值为11,date值为空 \ No newline at end of file diff --git a/test/model/weekly/getplanedtaskbyweek.php b/test/model/weekly/getplanedtaskbyweek.php old mode 100644 new mode 100755 index 68290e3cc0..3b232e2a96 --- a/test/model/weekly/getplanedtaskbyweek.php +++ b/test/model/weekly/getplanedtaskbyweek.php @@ -10,8 +10,22 @@ title=测试 weeklyModel->getPlanedTaskByWeek(); cid=1 pid=1 +测试project值为0,date值为2022-05-01 >> 子任务5 +测试project值为0,date值为空 >> 开发任务610 +测试project值为1,date值为2022-05-01 >> 0 +测试project值为1,date值为空 >> 0 +测试project值为11,date值为2022-05-01 >> 开发任务11 +测试project值为11,date值为空 >> 开发任务11 + */ +$projectList = array(0, 1, 11); +$dateList = array('2022-05-01', ''); $weekly = new weeklyTest(); -r($weekly->getPlanedTaskByWeekTest()) && p() && e(); \ No newline at end of file +r($weekly->getPlanedTaskByWeekTest($projectList[0], $dateList[0])) && p('905:name') && e('子任务5'); //测试project值为0,date值为2022-05-01 +r($weekly->getPlanedTaskByWeekTest($projectList[0], $dateList[1])) && p('600:name') && e('开发任务610'); //测试project值为0,date值为空 +r($weekly->getPlanedTaskByWeekTest($projectList[1], $dateList[0])) && p() && e('0'); //测试project值为1,date值为2022-05-01 +r($weekly->getPlanedTaskByWeekTest($projectList[1], $dateList[1])) && p() && e('0'); //测试project值为1,date值为空 +r($weekly->getPlanedTaskByWeekTest($projectList[2], $dateList[0])) && p('1:name') && e('开发任务11'); //测试project值为11,date值为2022-05-01 +r($weekly->getPlanedTaskByWeekTest($projectList[2], $dateList[1])) && p('1:name') && e('开发任务11'); //测试project值为11,date值为空 \ No newline at end of file diff --git a/test/model/weekly/getpostponed.php b/test/model/weekly/getpostponed.php old mode 100644 new mode 100755 index acaf88a500..e160a85f5e --- a/test/model/weekly/getpostponed.php +++ b/test/model/weekly/getpostponed.php @@ -10,8 +10,22 @@ title=测试 weeklyModel->getPostponed(); cid=1 pid=1 +测试project值为0,date值为2022-05-01 >> 子任务4 +测试project值为0,date值为空 >> 开发任务608 +测试project值为1,date值为2022-05-01 >> 0 +测试project值为1,date值为空 >> 0 +测试project值为11,date值为2022-05-01 >> 开发任务101 +测试project值为11,date值为空 >> 开发任务461 + */ +$projectList = array(0, 1, 11); +$dateList = array('2022-05-01', ''); $weekly = new weeklyTest(); -r($weekly->getPostponedTest()) && p() && e(); \ No newline at end of file +r($weekly->getPostponedTest($projectList[0], $dateList[0])) && p('92:name') && e('子任务4'); //测试project值为0,date值为2022-05-01 +r($weekly->getPostponedTest($projectList[0], $dateList[1])) && p('56:name') && e('开发任务608'); //测试project值为0,date值为空 +r($weekly->getPostponedTest($projectList[1], $dateList[0])) && p() && e('0'); //测试project值为1,date值为2022-05-01 +r($weekly->getPostponedTest($projectList[1], $dateList[1])) && p() && e('0'); //测试project值为1,date值为空 +r($weekly->getPostponedTest($projectList[2], $dateList[0])) && p('5:name') && e('开发任务101'); //测试project值为11,date值为2022-05-01 +r($weekly->getPostponedTest($projectList[2], $dateList[1])) && p('1:name') && e('开发任务461'); //测试project值为11,date值为空 \ No newline at end of file diff --git a/test/model/weekly/getpv.php b/test/model/weekly/getpv.php old mode 100644 new mode 100755 index 3fd279a9a6..b5832f0757 --- a/test/model/weekly/getpv.php +++ b/test/model/weekly/getpv.php @@ -10,8 +10,23 @@ title=测试 weeklyModel->getPV(); cid=1 pid=1 +测试projectID值为0,date值为2022-05-01 >> 1488 +测试projectID值为0,date值为空 >> 4223.02 +测试projectID值为11,date值为2022-05-01 >> 24 +测试projectID值为11,date值为空 >> 100 +测试projectID值为41,date值为2022-05-01 >> 9 +测试projectID值为41,date值为空 >> 50.5 + */ +$projectIDList = array(0, 11, 41); +$dateList = array('2022-05-01', ''); + $weekly = new weeklyTest(); -r($weekly->getPVTest()) && p() && e(); \ No newline at end of file +r($weekly->getPVTest($projectIDList[0], $dateList[0])) && p() && e('1488'); //测试projectID值为0,date值为2022-05-01 +r($weekly->getPVTest($projectIDList[0], $dateList[1])) && p() && e('4223.02'); //测试projectID值为0,date值为空 +r($weekly->getPVTest($projectIDList[1], $dateList[0])) && p() && e('24'); //测试projectID值为11,date值为2022-05-01 +r($weekly->getPVTest($projectIDList[1], $dateList[1])) && p() && e('100'); //测试projectID值为11,date值为空 +r($weekly->getPVTest($projectIDList[2], $dateList[0])) && p() && e('9'); //测试projectID值为41,date值为2022-05-01 +r($weekly->getPVTest($projectIDList[2], $dateList[1])) && p() && e('50.5'); //测试projectID值为41,date值为空 \ No newline at end of file diff --git a/test/model/weekly/getstaff.php b/test/model/weekly/getstaff.php old mode 100644 new mode 100755 index e601f180a2..0f18b7ff56 --- a/test/model/weekly/getstaff.php +++ b/test/model/weekly/getstaff.php @@ -10,8 +10,23 @@ title=测试 weeklyModel->getStaff(); cid=1 pid=1 +测试project值为0,date值为2022-05-01 >> 0 +测试project值为0,date值为空 >> 0 +测试project值为1,date值为2022-05-01 >> 0 +测试project值为1,date值为空 >> 0 +测试project值为11,date值为2022-05-01 >> 0 +测试project值为11,date值为空 >> 0 + */ +$projectList = array(0, 1, 11); +$dateList = array('2022-05-01', ''); + $weekly = new weeklyTest(); -r($weekly->getStaffTest()) && p() && e(); \ No newline at end of file +r($weekly->getStaffTest($projectList[0], $dateList[0])) && p() && e('0'); //测试project值为0,date值为2022-05-01 +r($weekly->getStaffTest($projectList[0], $dateList[1])) && p() && e('0'); //测试project值为0,date值为空 +r($weekly->getStaffTest($projectList[1], $dateList[0])) && p() && e('0'); //测试project值为1,date值为2022-05-01 +r($weekly->getStaffTest($projectList[1], $dateList[1])) && p() && e('0'); //测试project值为1,date值为空 +r($weekly->getStaffTest($projectList[2], $dateList[0])) && p() && e('0'); //测试project值为11,date值为2022-05-01 +r($weekly->getStaffTest($projectList[2], $dateList[1])) && p() && e('0'); //测试project值为11,date值为空 \ No newline at end of file diff --git a/test/model/weekly/getsv.php b/test/model/weekly/getsv.php old mode 100644 new mode 100755 index 937ef27cd8..f29de94def --- a/test/model/weekly/getsv.php +++ b/test/model/weekly/getsv.php @@ -10,8 +10,28 @@ title=测试 weeklyModel->getSV(); cid=1 pid=1 +测试ev值为0,pv值为0 >> 0 +测试ev值为0,pv值为10 >> -100.00 +测试ev值为0,pv值为100 >> -100.00 +测试ev值为10,pv值为0 >> 0 +测试ev值为10,pv值为10 >> 0.00 +测试ev值为10,pv值为100 >> -90.00 +测试ev值为100,pv值为0 >> 0 +测试ev值为100,pv值为10 >> 900.00 +测试ev值为100,pv值为100 >> 0.00 + */ +$evList = array(0, 10, 100); +$pvList = array(0, 10, 100); $weekly = new weeklyTest(); -r($weekly->getSVTest()) && p() && e(); \ No newline at end of file +r($weekly->getSVTest($evList[0], $pvList[0])) && p() && e('0'); //测试ev值为0,pv值为0 +r($weekly->getSVTest($evList[0], $pvList[1])) && p() && e('-100.00'); //测试ev值为0,pv值为10 +r($weekly->getSVTest($evList[0], $pvList[2])) && p() && e('-100.00'); //测试ev值为0,pv值为100 +r($weekly->getSVTest($evList[1], $pvList[0])) && p() && e('0'); //测试ev值为10,pv值为0 +r($weekly->getSVTest($evList[1], $pvList[1])) && p() && e('0.00'); //测试ev值为10,pv值为10 +r($weekly->getSVTest($evList[1], $pvList[2])) && p() && e('-90.00'); //测试ev值为10,pv值为100 +r($weekly->getSVTest($evList[2], $pvList[0])) && p() && e('0'); //测试ev值为100,pv值为0 +r($weekly->getSVTest($evList[2], $pvList[1])) && p() && e('900.00'); //测试ev值为100,pv值为10 +r($weekly->getSVTest($evList[2], $pvList[2])) && p() && e('0.00'); //测试ev值为100,pv值为100 \ No newline at end of file diff --git a/test/model/weekly/gettasksofnextweek.php b/test/model/weekly/gettasksofnextweek.php old mode 100644 new mode 100755 index 9be0e830df..8ce28e9b19 --- a/test/model/weekly/gettasksofnextweek.php +++ b/test/model/weekly/gettasksofnextweek.php @@ -10,8 +10,23 @@ title=测试 weeklyModel->getTasksOfNextWeek(); cid=1 pid=1 +测试project值为0,date值为2022-05-01 >> 子任务10 +测试project值为0,date值为空 >> 开发任务606 +测试project值为1,date值为2022-05-01 >> 0 +测试project值为1,date值为空 >> 0 +测试project值为11,date值为2022-05-01 >> 开发任务551 +测试project值为11,date值为空 >> 开发任务11 + */ +$projectList = array(0, 1, 11); +$dateList = array('2022-05-01', ''); + $weekly = new weeklyTest(); -r($weekly->getTasksOfNextWeekTest()) && p() && e(); \ No newline at end of file +r($weekly->getTasksOfNextWeekTest($projectList[0], $dateList[0])) && p('910:name') && e('子任务10'); //测试project值为0,date值为2022-05-01 +r($weekly->getTasksOfNextWeekTest($projectList[0], $dateList[1])) && p('596:name') && e('开发任务606'); //测试project值为0,date值为空 +r($weekly->getTasksOfNextWeekTest($projectList[1], $dateList[0])) && p() && e('0'); //测试project值为1,date值为2022-05-01 +r($weekly->getTasksOfNextWeekTest($projectList[1], $dateList[1])) && p() && e('0'); //测试project值为1,date值为空 +r($weekly->getTasksOfNextWeekTest($projectList[2], $dateList[0])) && p('541:name') && e('开发任务551'); //测试project值为11,date值为2022-05-01 +r($weekly->getTasksOfNextWeekTest($projectList[2], $dateList[1])) && p('1:name') && e('开发任务11'); //测试project值为11,date值为空 \ No newline at end of file diff --git a/test/model/weekly/gettips.php b/test/model/weekly/gettips.php old mode 100644 new mode 100755 index fc660a2274..3eb2fb95f7 --- a/test/model/weekly/gettips.php +++ b/test/model/weekly/gettips.php @@ -10,8 +10,22 @@ title=测试 weeklyModel->getTips(); cid=1 pid=1 +测试type值为progress,data值为0 >> 0 +测试type值为progress,data值为1 >> 0 +测试type值为cost,data值为0 >> 0 +测试type值为cost,data值为1 >> 0 +测试type值为空,data值为0 >> 0 +测试type值为空,data值为1 >> 0 + */ +$typeList = array('progress', 'cost', ''); +$dataList = array(0, 1); $weekly = new weeklyTest(); -r($weekly->getTipsTest()) && p() && e(); \ No newline at end of file +r($weekly->getTipsTest($typeList[0], $dataList[0])) && p() && e('0'); //测试type值为progress,data值为0 +r($weekly->getTipsTest($typeList[0], $dataList[1])) && p() && e('0'); //测试type值为progress,data值为1 +r($weekly->getTipsTest($typeList[1], $dataList[0])) && p() && e('0'); //测试type值为cost,data值为0 +r($weekly->getTipsTest($typeList[1], $dataList[1])) && p() && e('0'); //测试type值为cost,data值为1 +r($weekly->getTipsTest($typeList[2], $dataList[0])) && p() && e('0'); //测试type值为空,data值为0 +r($weekly->getTipsTest($typeList[2], $dataList[1])) && p() && e('0'); //测试type值为空,data值为1 \ No newline at end of file diff --git a/test/model/weekly/getworkloadbytype.php b/test/model/weekly/getworkloadbytype.php old mode 100644 new mode 100755 index 945f598ffc..cfc1063ea9 --- a/test/model/weekly/getworkloadbytype.php +++ b/test/model/weekly/getworkloadbytype.php @@ -10,8 +10,17 @@ title=测试 weeklyModel->getWorkloadByType(); cid=1 pid=1 +测试project值为0 >> 574.00,568.00,563.00,556.00,557.00,571.00,563.00,566.00 +测试project值为1 >> 0 +测试project值为11 >> 24.00,11.00,16.00,3.00,9.00,5.00,18.00,14.00 +测试project值为41 >> 13.00,12.00,3.00,7.00 + */ +$projectList = array(0, 1, 11, 41); $weekly = new weeklyTest(); -r($weekly->getWorkloadByTypeTest()) && p() && e(); \ No newline at end of file +r($weekly->getWorkloadByTypeTest($projectList[0])) && p('design,devel,test,study,discuss,ui,affair,misc') && e('574.00,568.00,563.00,556.00,557.00,571.00,563.00,566.00'); //测试project值为0 +r($weekly->getWorkloadByTypeTest($projectList[1])) && p() && e('0'); //测试project值为1 +r($weekly->getWorkloadByTypeTest($projectList[2])) && p('design,devel,test,study,discuss,ui,affair,misc') && e('24.00,11.00,16.00,3.00,9.00,5.00,18.00,14.00'); //测试project值为11 +r($weekly->getWorkloadByTypeTest($projectList[3])) && p('affair,test,study,discuss') && e('13.00,12.00,3.00,7.00'); //测试project值为41 \ No newline at end of file From 10415b31721d86d290edc0db4f2a2b6360e1591b Mon Sep 17 00:00:00 2001 From: wangxiaomeng Date: Sat, 7 May 2022 08:56:58 +0800 Subject: [PATCH 08/41] edit weekly --- test/class/weekly.class.php | 144 +++++++++++++++++++++++++--- test/model/weekly/getfromdb.php | 21 +++- test/model/weekly/getlastday.php | 10 +- test/model/weekly/getpagenav.php | 29 +++++- test/model/weekly/getthismonday.php | 9 +- test/model/weekly/getweekpairs.php | 33 ++++++- test/model/weekly/getweeksn.php | 12 ++- test/model/weekly/save.php | 21 +++- 8 files changed, 257 insertions(+), 22 deletions(-) mode change 100644 => 100755 test/model/weekly/getfromdb.php mode change 100644 => 100755 test/model/weekly/getlastday.php mode change 100644 => 100755 test/model/weekly/getpagenav.php mode change 100644 => 100755 test/model/weekly/getthismonday.php mode change 100644 => 100755 test/model/weekly/getweekpairs.php mode change 100644 => 100755 test/model/weekly/getweeksn.php mode change 100644 => 100755 test/model/weekly/save.php diff --git a/test/class/weekly.class.php b/test/class/weekly.class.php index 38acef0d86..f0bc5b384f 100644 --- a/test/class/weekly.class.php +++ b/test/class/weekly.class.php @@ -4,26 +4,101 @@ class weeklyTest public function __construct() { global $tester; - $this->objectModel = $tester->loadModel('weekly'); + $this->objectModel = $tester->loadModel('weekly'); + $this->projectModel = $tester->loadModel('project'); } - public function getPageNavTest($project, $date) + + /** + * GetPageNav + * + * @param int $projectID + * @param int $date + * @access public + * @return string + */ + + public function getPageNavTest($projectID, $date) { - $objects = $this->objectModel->getPageNav($project, $date); + if($date == 1) + { + $date = date('Y-m-d'); + } + elseif($date == 2) + { + $date = date('Y-m-d', strtotime(date('Y-m-d')."- 6 days")); + } + else + { + $date = date('Y-m-d', strtotime(date('Y-m-d') . "+ 6 days")); + } + + $project = $this->projectModel->getById($projectID); + $pageNav = $this->objectModel->getPageNav($project, $date); + + if(dao::isError()) return dao::getError(); + + $objects = strstr($pageNav,"",true); + return $objects; + } + + /** + * GetWeekPairs + * + * @param int $begin + * @access public + * @return array + */ + + public function getWeekPairsTest($begin, $end) + { + switch($begin) + { + case '1': + $begin = date('Y-m-d'); + break; + case '2': + $begin = date('Y-m-d', strtotime(date('Y-m-d')."- 6 days")); + break; + case '3': + $begin = date('Y-m-d', strtotime(date('Y-m-d') . "+ 6 days")); + break; + case '': + $begin = ''; + break; + } + + switch($begin) + { + case '1': + $end = date('Y-m-d'); + break; + case '2': + $end = date('Y-m-d', strtotime(date('Y-m-d')."- 6 days")); + break; + case '3': + $end = date('Y-m-d', strtotime(date('Y-m-d') . "+ 6 days")); + break; + case '': + $end = ''; + break; + } + + $objects = $this->objectModel->getWeekPairs($begin, $end); if(dao::isError()) return dao::getError(); return $objects; } - public function getWeekPairsTest($begin, $end = '') - { - $objects = $this->objectModel->getWeekPairs($begin, $end = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } + /** + * GetFromDB + * + * @param int $project + * @param int $date + * @access public + * @return object + */ public function getFromDBTest($project, $date) { @@ -34,15 +109,34 @@ class weeklyTest return $objects; } + /** + * Save data. + * + * @param int $project + * @param int $date + * @access public + * @return void + */ + public function saveTest($project, $date) { $objects = $this->objectModel->save($project, $date); if(dao::isError()) return dao::getError(); - return $objects; + $weekly = $this->objectModel->getFromDB($project, $date); + return $weekly; } + /** + * GetWeekSN + * + * @param int $begin + * @param int $date + * @access public + * @return int + */ + public function getWeekSNTest($begin, $date) { $objects = $this->objectModel->getWeekSN($begin, $date); @@ -52,6 +146,14 @@ class weeklyTest return $objects; } + /** + * Get monday for a date. + * + * @param int $date + * @access public + * @return date + */ + public function getThisMondayTest($date) { $objects = $this->objectModel->getThisMonday($date); @@ -61,6 +163,14 @@ class weeklyTest return $objects; } + /** + * GetThisSunday + * + * @param int $date + * @access public + * @return date + */ + public function getThisSundayTest($date) { $objects = $this->objectModel->getThisSunday($date); @@ -70,6 +180,14 @@ class weeklyTest return $objects; } + /** + * GetLastDay + * + * @param int $date + * @access public + * @return string + */ + public function getLastDayTest($date) { $objects = $this->objectModel->getLastDay($date); @@ -186,4 +304,4 @@ class weeklyTest return $objects; } -} \ No newline at end of file +} diff --git a/test/model/weekly/getfromdb.php b/test/model/weekly/getfromdb.php old mode 100644 new mode 100755 index b782bf4e3a..03e54c0367 --- a/test/model/weekly/getfromdb.php +++ b/test/model/weekly/getfromdb.php @@ -10,8 +10,25 @@ title=测试 weeklyModel->getFromDB(); cid=1 pid=1 +查询项目为已挂起、日期不为空的数据 >> 1,41 +查询项目为已挂起、日期为空的数据 >> 0 +查询项目为已关闭、日期不为空的数据 >> 2,42 +查询项目为已关闭、日期为空的数据 >> 0 +查询项目为未开始、日期不为空的数据 >> 3,43 +查询项目为未开始、日期为空的数据 >> 0 +查询项目为进行中、日期不为空的数据 >> 5,45 +查询项目为金箱子、日期为空的数据 >> 0 + */ +$productID = array('41', '42', '43', '45'); +$date = array('2022-05-03', ''); $weekly = new weeklyTest(); - -r($weekly->getFromDBTest()) && p() && e(); \ No newline at end of file +r($weekly->getFromDBTest($productID[0], $date[0])) && p('id,project') && e('1,41'); //查询项目为已挂起、日期不为空的数据 +r($weekly->getFromDBTest($productID[0], $date[1])) && p() && e('0'); //查询项目为已挂起、日期为空的数据 +r($weekly->getFromDBTest($productID[1], $date[0])) && p('id,project') && e('2,42'); //查询项目为已关闭、日期不为空的数据 +r($weekly->getFromDBTest($productID[1], $date[1])) && p() && e('0'); //查询项目为已关闭、日期为空的数据 +r($weekly->getFromDBTest($productID[2], $date[0])) && p('id,project') && e('3,43'); //查询项目为未开始、日期不为空的数据 +r($weekly->getFromDBTest($productID[2], $date[1])) && p() && e('0'); //查询项目为未开始、日期为空的数据 +r($weekly->getFromDBTest($productID[3], $date[0])) && p('id,project') && e('5,45'); //查询项目为进行中、日期不为空的数据 +r($weekly->getFromDBTest($productID[3], $date[1])) && p() && e('0'); //查询项目为金箱子、日期为空的数据 \ No newline at end of file diff --git a/test/model/weekly/getlastday.php b/test/model/weekly/getlastday.php old mode 100644 new mode 100755 index bcb22f10d6..0595add63b --- a/test/model/weekly/getlastday.php +++ b/test/model/weekly/getlastday.php @@ -10,8 +10,16 @@ title=测试 weeklyModel->getLastDay(); cid=1 pid=1 +查询日期为星期日 >> 2022-05-07 +查询日期为其他 >> 2022-05-01 +查询日期为空 >> 2022-05-10 + */ +$date = array('2022-05-08', '2022-04-29', ''); + $weekly = new weeklyTest(); -r($weekly->getLastDayTest()) && p() && e(); \ No newline at end of file +r($weekly->getLastDayTest($date[0])) && p() && e('2022-05-07'); //查询日期为星期日 +r($weekly->getLastDayTest($date[1])) && p() && e('2022-05-01'); //查询日期为其他 +r($weekly->getLastDayTest($date[2])) && p() && e('2022-05-10'); //查询日期为空 \ No newline at end of file diff --git a/test/model/weekly/getpagenav.php b/test/model/weekly/getpagenav.php old mode 100644 new mode 100755 index 0c301c5f95..cc47538a62 --- a/test/model/weekly/getpagenav.php +++ b/test/model/weekly/getpagenav.php @@ -10,8 +10,33 @@ title=测试 weeklyModel->getPageNav(); cid=1 pid=1 +查询项目为未开始,日期为当天的数据 >>
项目周报-项目集2 +查询项目为未开始,日期为一周前的数据 >>
项目周报-项目集2 +查询项目为未开始,日期为一周后的数据 >>
项目周报-项目集2 +查询项目为进行中,日期为当天的数据 >>
项目周报-项目3 +查询项目为进行中,日期为一周前的数据 >>
项目周报-项目3 +查询项目为进行中,日期为一周后的数据 >>
项目周报-项目3 +查询项目为已挂起,日期为当天的数据 >>
项目周报-项目7 +查询项目为已挂起,日期为一周前的数据 >>
项目周报-项目7 +查询项目为已挂起,日期为一周后的数据 >>
项目周报-项目7 +查询项目为已关闭,日期为当天的数据 >>
项目周报-项目8 +查询项目为已关闭,日期为一周前的数据 >>
项目周报-项目8 +查询项目为已关闭,日期为一周后的数据 >>
项目周报-项目8 + */ +$productID = array('2', '13', '17', '18'); +$date = array('1', '2', '3'); $weekly = new weeklyTest(); - -r($weekly->getPageNavTest()) && p() && e(); \ No newline at end of file +r($weekly->getPageNavTest($productID[0], $date[0])) && p() && e("
项目周报-项目集2"); //查询项目为未开始,日期为当天的数据 +r($weekly->getPageNavTest($productID[0], $date[1])) && p() && e("
项目周报-项目集2"); //查询项目为未开始,日期为一周前的数据 +r($weekly->getPageNavTest($productID[0], $date[2])) && p() && e("
项目周报-项目集2"); //查询项目为未开始,日期为一周后的数据 +r($weekly->getPageNavTest($productID[1], $date[0])) && p() && e("
项目周报-项目3"); //查询项目为进行中,日期为当天的数据 +r($weekly->getPageNavTest($productID[1], $date[1])) && p() && e("
项目周报-项目3"); //查询项目为进行中,日期为一周前的数据 +r($weekly->getPageNavTest($productID[1], $date[2])) && p() && e("
项目周报-项目3"); //查询项目为进行中,日期为一周后的数据 +r($weekly->getPageNavTest($productID[2], $date[0])) && p() && e("
项目周报-项目7"); //查询项目为已挂起,日期为当天的数据 +r($weekly->getPageNavTest($productID[2], $date[1])) && p() && e("
项目周报-项目7"); //查询项目为已挂起,日期为一周前的数据 +r($weekly->getPageNavTest($productID[2], $date[2])) && p() && e("
项目周报-项目7"); //查询项目为已挂起,日期为一周后的数据 +r($weekly->getPageNavTest($productID[3], $date[0])) && p() && e("
项目周报-项目8"); //查询项目为已关闭,日期为当天的数据 +r($weekly->getPageNavTest($productID[3], $date[1])) && p() && e("
项目周报-项目8"); //查询项目为已关闭,日期为一周前的数据 +r($weekly->getPageNavTest($productID[3], $date[2])) && p() && e("
项目周报-项目8"); //查询项目为已关闭,日期为一周后的数据 \ No newline at end of file diff --git a/test/model/weekly/getthismonday.php b/test/model/weekly/getthismonday.php old mode 100644 new mode 100755 index f622ac65b2..07a4de5dcb --- a/test/model/weekly/getthismonday.php +++ b/test/model/weekly/getthismonday.php @@ -10,8 +10,15 @@ title=测试 weeklyModel->getThisMonday(); cid=1 pid=1 +查询日期为星期日 >> 2022-05-02 +查询日期为其他 >> 2022-04-25 +查询日期为空 >> 2022-05-04 + */ +$date = array('2022-05-08', '2022-04-29', ''); $weekly = new weeklyTest(); -r($weekly->getThisMondayTest()) && p() && e(); \ No newline at end of file +r($weekly->getThisMondayTest($date[0])) && p() && e('2022-05-02'); //查询日期为星期日 +r($weekly->getThisMondayTest($date[1])) && p() && e('2022-04-25'); //查询日期为其他 +r($weekly->getThisMondayTest($date[2])) && p() && e('2022-05-04'); //查询日期为空 \ No newline at end of file diff --git a/test/model/weekly/getweekpairs.php b/test/model/weekly/getweekpairs.php old mode 100644 new mode 100755 index 0ddaeca4c9..38a1b6dbb4 --- a/test/model/weekly/getweekpairs.php +++ b/test/model/weekly/getweekpairs.php @@ -10,8 +10,39 @@ title=测试 weeklyModel->getWeekPairs(); cid=1 pid=1 + >> 0 + >> 0 + >> 0 + >> 0 + >> 第 1 周( 2022-04-25 ~ 2022-05-01) + >> 0 + >> 0 + >> 0 + >> 0 + >> 第 1 周( 2022-05-03 ~ 2022-05-09) + >> 第 4 周( 2022-05-23 ~ 2022-05-29) + >> 第 239 周( 2026-11-23 ~ 2026-11-29) + >> 第 5 周( 2022-05-30 ~ 2022-06-05) + */ +$begin = array(1, 2, 3, ''); +$end = array(1, 2, 3, ''); $weekly = new weeklyTest(); -r($weekly->getWeekPairsTest()) && p() && e(); \ No newline at end of file +r($weekly->getWeekPairsTest($begin[0], $end[0])) && p() && e('0'); +r($weekly->getWeekPairsTest($begin[0], $end[1])) && p() && e('0'); +r($weekly->getWeekPairsTest($begin[0], $end[2])) && p() && e('0'); +r($weekly->getWeekPairsTest($begin[0], $end[3])) && p() && e('0'); +r($weekly->getWeekPairsTest($begin[1], $end[0])) && p() && e(); +r($weekly->getWeekPairsTest($begin[1], $end[1])) && p() && e(); +r($weekly->getWeekPairsTest($begin[1], $end[2])) && p() && e(); +r($weekly->getWeekPairsTest($begin[1], $end[3])) && p('20220425') && e('第 1 周( 2022-04-25 ~ 2022-05-01)'); +r($weekly->getWeekPairsTest($begin[2], $end[0])) && p() && e('0'); +r($weekly->getWeekPairsTest($begin[2], $end[1])) && p() && e('0'); +r($weekly->getWeekPairsTest($begin[2], $end[2])) && p() && e('0'); +r($weekly->getWeekPairsTest($begin[2], $end[3])) && p() && e('0'); +r($weekly->getWeekPairsTest($begin[3], $end[0])) && p('20220503') && e('第 1 周( 2022-05-03 ~ 2022-05-09)'); +r($weekly->getWeekPairsTest($begin[3], $end[1])) && p('20220523') && e('第 4 周( 2022-05-23 ~ 2022-05-29)'); +r($weekly->getWeekPairsTest($begin[3], $end[2])) && p('20261123') && e('第 239 周( 2026-11-23 ~ 2026-11-29)'); +r($weekly->getWeekPairsTest($begin[3], $end[3])) && p('20220530') && e('第 5 周( 2022-05-30 ~ 2022-06-05)'); \ No newline at end of file diff --git a/test/model/weekly/getweeksn.php b/test/model/weekly/getweeksn.php old mode 100644 new mode 100755 index 2ab539e49e..456289c5c0 --- a/test/model/weekly/getweeksn.php +++ b/test/model/weekly/getweeksn.php @@ -10,8 +10,18 @@ title=测试 weeklyModel->getWeekSN(); cid=1 pid=1 +开始时间和结束时间都不为空 >> 1 +开始时间不为空,结束时间为空 >> -2730 +开始时间为空,结束时间不为空 >> 2732 +开始时间和结束时间都为空 >> 0 + */ +$begin = array('2022-05-02', ''); +$end = array('2022-05-06', ''); $weekly = new weeklyTest(); -r($weekly->getWeekSNTest()) && p() && e(); \ No newline at end of file +r($weekly->getWeekSNTest($begin[0], $end[0])) && p() && e('1'); //开始时间和结束时间都不为空 +r($weekly->getWeekSNTest($begin[0], $end[1])) && p() && e('-2730'); //开始时间不为空,结束时间为空 +r($weekly->getWeekSNTest($begin[1], $end[0])) && p() && e('2732'); //开始时间为空,结束时间不为空 +r($weekly->getWeekSNTest($begin[1], $end[1])) && p() && e('0'); //开始时间和结束时间都为空 \ No newline at end of file diff --git a/test/model/weekly/save.php b/test/model/weekly/save.php old mode 100644 new mode 100755 index 751897ec2f..7816a6cfa6 --- a/test/model/weekly/save.php +++ b/test/model/weekly/save.php @@ -10,8 +10,27 @@ title=测试 weeklyModel->save(); cid=1 pid=1 +保存项目为已挂起、日期不为空的数据 >> 11,41 +保存项目为已挂起、日期为空的数据 >> 12,41 +保存项目为已关闭、日期不为空的数据 >> 13,42 +保存项目为已关闭、日期为空的数据 >> 14,42 +保存项目为未开始、日期不为空的数据 >> 15,43 +保存项目为未开始、日期为空的数据 >> 16,43 +保存项目为进行中、日期不为空的数据 >> 17,45 +保存项目为进行中、日期为空的数据 >> 18,45 + */ +$productID = array('41', '42', '43', '45'); +$date = array('2022-04-29', ''); $weekly = new weeklyTest(); +r($weekly->saveTest($productID[0], $date[0])) && p('id,project') && e('11,41'); //保存项目为已挂起、日期不为空的数据 +r($weekly->saveTest($productID[0], $date[1])) && p('id,project') && e('12,41'); //保存项目为已挂起、日期为空的数据 +r($weekly->saveTest($productID[1], $date[0])) && p('id,project') && e('13,42'); //保存项目为已关闭、日期不为空的数据 +r($weekly->saveTest($productID[1], $date[1])) && p('id,project') && e('14,42'); //保存项目为已关闭、日期为空的数据 +r($weekly->saveTest($productID[2], $date[0])) && p('id,project') && e('15,43'); //保存项目为未开始、日期不为空的数据 +r($weekly->saveTest($productID[2], $date[1])) && p('id,project') && e('16,43'); //保存项目为未开始、日期为空的数据 +r($weekly->saveTest($productID[3], $date[0])) && p('id,project') && e('17,45'); //保存项目为进行中、日期不为空的数据 +r($weekly->saveTest($productID[3], $date[1])) && p('id,project') && e('18,45'); //保存项目为进行中、日期为空的数据 -r($weekly->saveTest()) && p() && e(); \ No newline at end of file +system("./ztest init"); \ No newline at end of file From bc11d6a8a0877e5ae3bdb58e6e3c45227a4eb5a8 Mon Sep 17 00:00:00 2001 From: liyuchun <563917701@qq.com> Date: Sat, 7 May 2022 01:22:13 +0000 Subject: [PATCH 09/41] * Add unit test. --- module/job/model.php | 2 +- test/class/ci.class.php | 57 +++++++++++++++++++++++++++++ test/data/job.yaml | 6 +++ test/data/pipeline.yaml | 18 ++++----- test/data/zentao/config.php | 2 +- test/model/ci/setmenu.php | 19 ++++++++++ test/model/ci/synccompilestatus.php | 19 ++++++++++ 7 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 test/class/ci.class.php create mode 100644 test/model/ci/setmenu.php create mode 100644 test/model/ci/synccompilestatus.php diff --git a/module/job/model.php b/module/job/model.php index f88120da2a..751924af9e 100644 --- a/module/job/model.php +++ b/module/job/model.php @@ -486,7 +486,7 @@ class jobModel extends model } /** - * Exec jenkins pipeline. + * Exec jenkins pipeline. * * @param object $job * @param object $repo diff --git a/test/class/ci.class.php b/test/class/ci.class.php new file mode 100644 index 0000000000..7d00aceb4b --- /dev/null +++ b/test/class/ci.class.php @@ -0,0 +1,57 @@ +objectModel = $tester->loadModel('ci'); + } + + /** + * Set menu. + * + * @access public + * @return array + */ + public function setMenuTest() + { + $_SESSION['repoID'] = 1; + $this->objectModel->setMenu(); + + global $lang; + return $lang->devops->menu->code; + } + + /** + * Sync compile status. + * + * @param int $jobID + * @access public + * @return string + */ + public function syncCompileStatusTest($jobID) + { + global $tester; + $tester->loadModel('job')->exec($jobID); + $compileID = $tester->dao->select('id')->from(TABLE_COMPILE)->orderBy('id_desc')->fetch('id'); + + $notCompileMR = $tester->dao->select('id,jobID') + ->from(TABLE_MR) + ->where('jobID')->gt(0) + ->andWhere('compileStatus')->eq('created') + ->fetchPairs(); + + $compile = $tester->dao->select('compile.*, job.engine,job.pipeline, pipeline.name as jenkinsName,job.server,pipeline.url,pipeline.account,pipeline.token,pipeline.password') + ->from(TABLE_COMPILE)->alias('compile') + ->leftJoin(TABLE_JOB)->alias('job')->on('compile.job=job.id') + ->leftJoin(TABLE_PIPELINE)->alias('pipeline')->on('job.server=pipeline.id') + ->where('compile.id')->eq($compileID) + ->fetch(); + + $this->objectModel->syncCompileStatus($compile, $notCompileMR); + $compile = $tester->loadModel('compile')->getByID($compileID); + + if(dao::isError()) return dao::getError(); + return $compile; + } +} diff --git a/test/data/job.yaml b/test/data/job.yaml index 08c13e0738..2d07519293 100644 --- a/test/data/job.yaml +++ b/test/data/job.yaml @@ -41,6 +41,12 @@ fields: - field: engine note: "引擎" range: jenkins,gitlab + - field: server + note: "服务器ID" + range: 3,1 + - field: pipeline + note: "流水线" + range: dave,[{"project":"1569"}] - field: triggerType note: "触发方式" range: tag,commit,schedule diff --git a/test/data/pipeline.yaml b/test/data/pipeline.yaml index 60ad7e0b48..c4295ea9d7 100644 --- a/test/data/pipeline.yaml +++ b/test/data/pipeline.yaml @@ -3,24 +3,24 @@ author: Zeng gang version: "1.0" fields: - field: id - range: 1-2 + range: 1-3 - field: type - range: gitlab,sonarqube + range: gitlab,sonarqube,jenkins - field: name - range: gitlab服务器,sonarqube服务器 + range: gitlab服务器,sonarqube服务器,jenkins服务器 - field: url - range: [http://192.168.1.161:51080],[http://192.168.1.161:59001] + range: [http://10.0.1.161:51080],[http://10.0.1.161:59001],[http://10.0.1.161:58080] - field: account - range: [],[admin] + range: [],[admin]{2} - field: password - range: [],[UDJzc3cwcmQ=] + range: [],[UDJzc3cwcmQ=],[] - field: token - range: x88fZokrp5hShia2jyBN,YWRtaW46UDJzc3cwcmQ= + range: x88fZokrp5hShia2jyBN,YWRtaW46UDJzc3cwcmQ=,1196c85ba525a268570df9da627e3a7b2d - field: private - range: 08bcc98f75d7d40053dc80722bdc117b,228b25587479f2fc7570428e8bcbabdc + range: 08bcc98f75d7d40053dc80722bdc117b,228b25587479f2fc7570428e8bcbabdc,ec8e41481723685d9106c88be5967c41 - field: createdBy range: admin - field: createdDate - range: [2021-12-09 11:23:35],[2022-01-12 08:47:37] + range: [2021-12-09 11:23:35],[2022-01-12 08:47:37],[2022-01-12 08:47:37] - field: deleted range: 0 diff --git a/test/data/zentao/config.php b/test/data/zentao/config.php index 8f3f9bbd03..d2711081ae 100644 --- a/test/data/zentao/config.php +++ b/test/data/zentao/config.php @@ -105,7 +105,7 @@ $builder->webhook = array('rows' => 7, 'extends' => array('webhook')); $builder->entry = array('rows' => 1, 'extends' => array('entry')); $builder->weeklyreport = array('rows' => 10, 'extends' => array('weeklyreport')); -$builder->pipeline = array('rows' => 2, 'extends' => array('pipeline')); +$builder->pipeline = array('rows' => 3, 'extends' => array('pipeline')); $builder->holiday = array('rows' => 100, 'extends' => array('holiday')); $builder->repo = array('rows' => 1, 'extends' => array('repo')); $builder->job = array('rows' => 2, 'extends' => array('job')); diff --git a/test/model/ci/setmenu.php b/test/model/ci/setmenu.php new file mode 100644 index 0000000000..1b2c298dc3 --- /dev/null +++ b/test/model/ci/setmenu.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +setMenu(); +cid=1 +pid=1 + +替换devops模块的参数 >> 代码|repo|browse|repoID=1 + +*/ + +$ci = new ciTest(); + +r($ci->setMenuTest()) && p('link') && e('代码|repo|browse|repoID=1'); //替换devops模块导航的参数 diff --git a/test/model/ci/synccompilestatus.php b/test/model/ci/synccompilestatus.php new file mode 100644 index 0000000000..80d017226e --- /dev/null +++ b/test/model/ci/synccompilestatus.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +syncCompileStatus(); +cid=1 +pid=1 + +同步jenkins构建结果 >> created + +*/ + +$ci = new ciTest(); + +r($ci->syncCompileStatusTest(1)) && p('status') && e('created'); //同步jenkins构建结果 From 3ceae4320f9e23a5e3205d8bb9a8482592a2f966 Mon Sep 17 00:00:00 2001 From: sunjun Date: Sat, 7 May 2022 01:41:38 +0000 Subject: [PATCH 10/41] test_sunjun --- module/holiday/model.php | 7 ++++-- test/model/holiday/getholidays.php | 29 ++++++++++++++++++++++ test/model/holiday/getlist.php | 35 +++++++++++++++++++++++++++ test/model/holiday/getworkingdays.php | 30 +++++++++++++++++++++++ test/model/holiday/isworkingday.php | 24 ++++++++++++++++++ test/ztest | 3 +++ 6 files changed, 126 insertions(+), 2 deletions(-) create mode 100755 test/model/holiday/getholidays.php create mode 100755 test/model/holiday/getlist.php create mode 100755 test/model/holiday/getworkingdays.php create mode 100755 test/model/holiday/isworkingday.php diff --git a/module/holiday/model.php b/module/holiday/model.php index 943110a11e..8d0079aba9 100644 --- a/module/holiday/model.php +++ b/module/holiday/model.php @@ -172,13 +172,16 @@ class holidayModel extends model ->andWhere('end')->ge($begin) ->fetchAll('id'); + $naturalDays = $this->getDaysBetween($begin, $end); + $workingDays = array(); foreach($records as $record) { - $dates = $this->getDaysBetween($record->begin, $record->end); + $dates = $this->getDaysBetween($record->begin, $record->end); $workingDays = array_merge($workingDays, $dates); } - return $workingDays; + + return array_intersect($naturalDays, $workingDays); } /** diff --git a/test/model/holiday/getholidays.php b/test/model/holiday/getholidays.php new file mode 100755 index 0000000000..393f43347e --- /dev/null +++ b/test/model/holiday/getholidays.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +getHolidays(); +cid=1 +pid=1 + +返回处于2022-3-3到2022-4-7之间的休假日期。 >> 1 +返回处于2022-3-3到2022-4-8之间的休假日期。 >> 2 +测试当结束日期大于开始日期时。 >> 0 +返回处于2022-4-7到2022-4-8之间的休假日期。 >> 2 +测试当数据库没有休假记录时。 >> 0 + +*/ + +$holiday = new holidayTest(); +$begin = array('2022-03-03', '2022-04-07'); +$end = array('2022-04-07', '2022-04-08', '2022-03-05'); + +r($holiday->getHolidaysTest($begin[0], $end[0])) && p() && e('1'); //返回处于2022-3-3到2022-4-7之间的休假日期。 +r($holiday->getHolidaysTest($begin[0], $end[1])) && p() && e('2'); //返回处于2022-3-3到2022-4-8之间的休假日期。 +r($holiday->getHolidaysTest($begin[1], $end[2])) && p() && e('0'); //测试当结束日期大于开始日期时。 +r($holiday->getHolidaysTest($begin[1], $end[1])) && p() && e('2'); //返回处于2022-4-7到2022-4-8之间的休假日期。 +r($holiday->getHolidaysTest($begin[0], $end[2])) && p() && e('0'); //测试当数据库没有休假记录时。 \ No newline at end of file diff --git a/test/model/holiday/getlist.php b/test/model/holiday/getlist.php new file mode 100755 index 0000000000..da63d18d5f --- /dev/null +++ b/test/model/holiday/getlist.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +getList(); +cid=1 +pid=1 + +返回2022年的holiday list >> 100 +返回2022年2月的holiday list >> 0 +返回2022年5月的holiday list >> 100 +返回2002年的holiday list >> 0 +返回2022年所有类型的holiday list >> 100 +返回2022年类型为holiday的holiday list >> 50 +返回2022年类型为working的holiday list >> 50 +返回2022年类型为空holiday list >> 100 + +*/ + +$holiday = new holidayTest(); +$t_numyear = array('2022', '2022-02', '2022-05', '2002', ''); +$t_type = array('all', 'holiday', 'working', ''); + +r($holiday->getListTest($t_numyear[0])) && p() && e('100'); // 返回2022年的holiday list +r($holiday->getListTest($t_numyear[1])) && p() && e('0'); // 返回2022年2月的holiday list +r($holiday->getListTest($t_numyear[2])) && p() && e('100'); // 返回2022年5月的holiday list +r($holiday->getListTest($t_numyear[3])) && p() && e('0'); // 返回2002年的holiday list +r($holiday->getListTest($t_numyear[0], $t_type[0])) && p() && e('100'); // 返回2022年所有类型的holiday list +r($holiday->getListTest($t_numyear[0], $t_type[1])) && p() && e('50'); // 返回2022年类型为holiday的holiday list +r($holiday->getListTest($t_numyear[0], $t_type[2])) && p() && e('50'); // 返回2022年类型为working的holiday list +r($holiday->getListTest($t_numyear[0], $t_type[3])) && p() && e('100'); // 返回2022年类型为空holiday list \ No newline at end of file diff --git a/test/model/holiday/getworkingdays.php b/test/model/holiday/getworkingdays.php new file mode 100755 index 0000000000..0441904cb5 --- /dev/null +++ b/test/model/holiday/getworkingdays.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +getWorkingDays(); +cid=1 +pid=1 + +返回处于2022-3-3到2022-4-6之间的工作日。 >> 0 +返回处于2022-3-3到2022-4-8之间的工作日。 >> 2 +测试当结束日期大于开始日期时。 >> 0 +返回处于2022-4-6到2022-4-8之间的工作日。 >> 2 +测试当数据库没有工作日记录时。 >> 0 + +*/ + +$holiday = new holidayTest(); + +$begin = array('2022-03-03', '2022-04-07'); +$end = array('2022-04-06', '2022-04-08', '2022-03-05'); + +r($holiday->getWorkingDaysTest($begin[0], $end[0])) && p() && e('0'); //返回处于2022-3-3到2022-4-6之间的工作日。 +r($holiday->getWorkingDaysTest($begin[0], $end[1])) && p() && e('2'); //返回处于2022-3-3到2022-4-8之间的工作日。 +r($holiday->getWorkingDaysTest($begin[1], $end[0])) && p() && e('0'); //测试当结束日期大于开始日期时。 +r($holiday->getWorkingDaysTest($begin[1], $end[1])) && p() && e('2'); //返回处于2022-4-6到2022-4-8之间的工作日。 +r($holiday->getWorkingDaysTest($begin[0], $end[2])) && p() && e('0'); //测试当数据库没有工作日记录时。 \ No newline at end of file diff --git a/test/model/holiday/isworkingday.php b/test/model/holiday/isworkingday.php new file mode 100755 index 0000000000..e58ed4f4b6 --- /dev/null +++ b/test/model/holiday/isworkingday.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +isWorkingDay(); +cid=1 +pid=1 + +测试不是工作日 >> 0 +测试是工作日 >> 1 +测试日期格式不对 >> 0 + +*/ + +$holiday = new holidayTest(); +$date = array('2022-03-01', '2022-04-09', '2002-2-2'); + +r($holiday->isWorkingDayTest($date[0])) && p() && e('0'); // 测试不是工作日 +r($holiday->isWorkingDayTest($date[1])) && p() && e('1'); // 测试是工作日 +r($holiday->isWorkingDayTest($date[2])) && p() && e('0'); // 测试日期格式不对 \ No newline at end of file diff --git a/test/ztest b/test/ztest index 358a930ca6..ea46226195 100755 --- a/test/ztest +++ b/test/ztest @@ -82,6 +82,9 @@ switch($argv[1]) case 'branch': ztfRun('model/branch'); break; + case 'holiday': + ztfRun('model/holiday'); + break; case 'report': ztfRun('model/report'); break; From 54fe0bd623c57f03adc71d206524fba4b4694a13 Mon Sep 17 00:00:00 2001 From: wangxiaomeng Date: Sat, 7 May 2022 09:46:30 +0800 Subject: [PATCH 11/41] edit weekly --- test/class/weekly.class.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/test/class/weekly.class.php b/test/class/weekly.class.php index f0bc5b384f..47e84d0dff 100644 --- a/test/class/weekly.class.php +++ b/test/class/weekly.class.php @@ -20,19 +20,6 @@ class weeklyTest public function getPageNavTest($projectID, $date) { - if($date == 1) - { - $date = date('Y-m-d'); - } - elseif($date == 2) - { - $date = date('Y-m-d', strtotime(date('Y-m-d')."- 6 days")); - } - else - { - $date = date('Y-m-d', strtotime(date('Y-m-d') . "+ 6 days")); - } - $project = $this->projectModel->getById($projectID); $pageNav = $this->objectModel->getPageNav($project, $date); From 48b87266004f8f303fb2898ab0b31a312334bd5c Mon Sep 17 00:00:00 2001 From: sunjun Date: Sat, 7 May 2022 01:56:15 +0000 Subject: [PATCH 12/41] test_sunjun1 --- test/class/holiday.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/class/holiday.class.php b/test/class/holiday.class.php index d3c59768ae..a5ad1f7d40 100644 --- a/test/class/holiday.class.php +++ b/test/class/holiday.class.php @@ -34,11 +34,11 @@ class holidayTest */ public function getListTest($year = '', $type = 'all') { - $objects = $this->objectModel->getList($year = '', $type = 'all'); + $objects = $this->objectModel->getList($year, $type); if(dao::isError()) return dao::getError(); - return $objects; + return count($objects); } /** @@ -140,10 +140,10 @@ class holidayTest if(dao::isError()) return dao::getError(); - return $objects; + return count($objects); } - public function getWorkingDaysTest($begin, $end) + public function getWorkingDaysTest($begin = '', $end = '') { $objects = $this->objectModel->getWorkingDays($begin, $end); From 909c567b754a6cd054358bc4e56f080fa2fd463d Mon Sep 17 00:00:00 2001 From: wangxiaomeng Date: Sat, 7 May 2022 09:57:37 +0800 Subject: [PATCH 13/41] edit weekly --- test/model/weekly/getpagenav.php | 10 +--------- test/model/weekly/getthissunday.php | 9 ++++++++- 2 files changed, 9 insertions(+), 10 deletions(-) mode change 100644 => 100755 test/model/weekly/getthissunday.php diff --git a/test/model/weekly/getpagenav.php b/test/model/weekly/getpagenav.php index cc47538a62..c3869f5945 100755 --- a/test/model/weekly/getpagenav.php +++ b/test/model/weekly/getpagenav.php @@ -12,31 +12,23 @@ pid=1 查询项目为未开始,日期为当天的数据 >>
项目周报-项目集2 查询项目为未开始,日期为一周前的数据 >>
项目周报-项目集2 -查询项目为未开始,日期为一周后的数据 >>
项目周报-项目集2 查询项目为进行中,日期为当天的数据 >>
项目周报-项目3 查询项目为进行中,日期为一周前的数据 >>
项目周报-项目3 -查询项目为进行中,日期为一周后的数据 >>
项目周报-项目3 查询项目为已挂起,日期为当天的数据 >>
项目周报-项目7 查询项目为已挂起,日期为一周前的数据 >>
项目周报-项目7 -查询项目为已挂起,日期为一周后的数据 >>
项目周报-项目7 查询项目为已关闭,日期为当天的数据 >>
项目周报-项目8 查询项目为已关闭,日期为一周前的数据 >>
项目周报-项目8 -查询项目为已关闭,日期为一周后的数据 >>
项目周报-项目8 */ $productID = array('2', '13', '17', '18'); -$date = array('1', '2', '3'); +$date = array('2022-05-07', ''); $weekly = new weeklyTest(); r($weekly->getPageNavTest($productID[0], $date[0])) && p() && e("
项目周报-项目集2"); //查询项目为未开始,日期为当天的数据 r($weekly->getPageNavTest($productID[0], $date[1])) && p() && e("
项目周报-项目集2"); //查询项目为未开始,日期为一周前的数据 -r($weekly->getPageNavTest($productID[0], $date[2])) && p() && e("
项目周报-项目集2"); //查询项目为未开始,日期为一周后的数据 r($weekly->getPageNavTest($productID[1], $date[0])) && p() && e("
项目周报-项目3"); //查询项目为进行中,日期为当天的数据 r($weekly->getPageNavTest($productID[1], $date[1])) && p() && e("
项目周报-项目3"); //查询项目为进行中,日期为一周前的数据 -r($weekly->getPageNavTest($productID[1], $date[2])) && p() && e("
项目周报-项目3"); //查询项目为进行中,日期为一周后的数据 r($weekly->getPageNavTest($productID[2], $date[0])) && p() && e("
项目周报-项目7"); //查询项目为已挂起,日期为当天的数据 r($weekly->getPageNavTest($productID[2], $date[1])) && p() && e("
项目周报-项目7"); //查询项目为已挂起,日期为一周前的数据 -r($weekly->getPageNavTest($productID[2], $date[2])) && p() && e("
项目周报-项目7"); //查询项目为已挂起,日期为一周后的数据 r($weekly->getPageNavTest($productID[3], $date[0])) && p() && e("
项目周报-项目8"); //查询项目为已关闭,日期为当天的数据 r($weekly->getPageNavTest($productID[3], $date[1])) && p() && e("
项目周报-项目8"); //查询项目为已关闭,日期为一周前的数据 -r($weekly->getPageNavTest($productID[3], $date[2])) && p() && e("
项目周报-项目8"); //查询项目为已关闭,日期为一周后的数据 \ No newline at end of file diff --git a/test/model/weekly/getthissunday.php b/test/model/weekly/getthissunday.php old mode 100644 new mode 100755 index 30182dd1cb..e3f4b574e5 --- a/test/model/weekly/getthissunday.php +++ b/test/model/weekly/getthissunday.php @@ -10,8 +10,15 @@ title=测试 weeklyModel->getThisSunday(); cid=1 pid=1 +查询日期为星期日 >> 2022-05-08 +查询日期为其他 >> 2022-05-01 +查询日期为空 >> 2022-05-10 + */ +$date = array('2022-05-08', '2022-04-29', ''); $weekly = new weeklyTest(); -r($weekly->getThisSundayTest()) && p() && e(); \ No newline at end of file +r($weekly->getThisSundayTest($date[0])) && p() && e('2022-05-08'); //查询日期为星期日 +r($weekly->getThisSundayTest($date[1])) && p() && e('2022-05-01'); //查询日期为其他 +r($weekly->getThisSundayTest($date[2])) && p() && e('2022-05-10'); //查询日期为空 \ No newline at end of file From 7eddd0aad5299d4e82ad9aa6f0f029fdf10b7eb9 Mon Sep 17 00:00:00 2001 From: liyang <“liyang@easycorp.ltd”> Date: Sat, 7 May 2022 10:12:34 +0800 Subject: [PATCH 14/41] Add data --- test/data/log.yaml | 68 +++++++++++++++++++++++++++++++++++++ test/data/usertpl.yaml | 47 +++++++++++++++++++++++++ test/data/zentao/config.php | 2 ++ 3 files changed, 117 insertions(+) create mode 100644 test/data/log.yaml create mode 100644 test/data/usertpl.yaml diff --git a/test/data/log.yaml b/test/data/log.yaml new file mode 100644 index 0000000000..9ac693b34a --- /dev/null +++ b/test/data/log.yaml @@ -0,0 +1,68 @@ +title: table zt_log +desc: "接口日志" +author: automated export +version: "1.0" +fields: + - field: id + note: "ID" + range: 1-10000 + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: objectType + note: "对象类型" + range: entry,webhook{9} + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: objectID + note: "对象ID" + range: 1-10000 + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: action + note: "操作日志ID" + range: 1-10000 + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: date + note: "日期" + range: "(-1M)-(1w)" + type: timestamp + format: "YYYY-MM-DD hh:mm:ss" + prefix: "" + postfix: "" + - field: url + note: "请求地址" + range: "qcmmi" + prefix: "http://" + postfix: ".com" + loop: 0 + format: "" + - field: contentType + note: "内容类型" + range: "application/json" + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: data + note: "数据" + range: a-z + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: result + note: "结果" + range: a-z + prefix: "" + postfix: "" + loop: 0 + format: "" diff --git a/test/data/usertpl.yaml b/test/data/usertpl.yaml new file mode 100644 index 0000000000..a282e2086f --- /dev/null +++ b/test/data/usertpl.yaml @@ -0,0 +1,47 @@ +title: table zt_usertpl +desc: "用户模块" +author: automated export +version: "1.0" +fields: + - field: id + note: "ID" + range: 1-10000 + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: account + range: admin,dev10,top10,test10,po10 + note: "用户名" + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: type + note: "类型" + range: task,story,bug,exportstory + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: title + note: "模板名" + range: 1-10000 + prefix: "模板名称" + postfix: "" + loop: 0 + format: "" + - field: content + note: "内容" + range: 1-10000 + prefix: "模块内容" + postfix: "" + loop: 0 + format: "" + - field: public + note: "是否公开" + range: 0,1 + prefix: "" + postfix: "" + loop: 0 + format: "" diff --git a/test/data/zentao/config.php b/test/data/zentao/config.php index 7c4c86f244..efdfcbc3b4 100644 --- a/test/data/zentao/config.php +++ b/test/data/zentao/config.php @@ -104,8 +104,10 @@ $builder->designspec = array('rows' => 120, 'extends' => array('designspec')); $builder->stage = array('rows' => 6, 'extends' => array('stage')); $builder->webhook = array('rows' => 7, 'extends' => array('webhook')); $builder->entry = array('rows' => 1, 'extends' => array('entry')); +$builder->log = array('rows' => 10, 'extends' => array('log')); $builder->weeklyreport = array('rows' => 10, 'extends' => array('weeklyreport')); $builder->metting = array('rows' => 10, 'extends' => array('meeting')); +$builder->usertpl = array('rows' => 10, 'extends' => array('usertpl')); $builder->pipeline = array('rows' => 2, 'extends' => array('pipeline')); $builder->holiday = array('rows' => 100, 'extends' => array('holiday')); From 319ec152a2dbbea470408e03f9669d0072390683 Mon Sep 17 00:00:00 2001 From: wangxiaomeng Date: Sat, 7 May 2022 10:18:27 +0800 Subject: [PATCH 15/41] edit weekly --- test/class/weekly.class.php | 4 +++- test/model/weekly/getpagenav.php | 18 +++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/test/class/weekly.class.php b/test/class/weekly.class.php index 47e84d0dff..8f26e51f99 100644 --- a/test/class/weekly.class.php +++ b/test/class/weekly.class.php @@ -25,7 +25,9 @@ class weeklyTest if(dao::isError()) return dao::getError(); - $objects = strstr($pageNav,"
",true); + $start_str = mb_strpos($pageNav,"ass='btn'>") + mb_strlen("class='btn'>"); + $end_str = mb_strpos($pageNav,"") - $start_str; + $objects = mb_substr($pageNav,$start_str,$end_str); return $objects; } diff --git a/test/model/weekly/getpagenav.php b/test/model/weekly/getpagenav.php index c3869f5945..c8f6397685 100755 --- a/test/model/weekly/getpagenav.php +++ b/test/model/weekly/getpagenav.php @@ -20,15 +20,15 @@ pid=1 查询项目为已关闭,日期为一周前的数据 >>
项目周报-项目8 */ -$productID = array('2', '13', '17', '18'); +$productID = array('19', '13', '17', '18'); $date = array('2022-05-07', ''); $weekly = new weeklyTest(); -r($weekly->getPageNavTest($productID[0], $date[0])) && p() && e("
项目周报-项目集2"); //查询项目为未开始,日期为当天的数据 -r($weekly->getPageNavTest($productID[0], $date[1])) && p() && e("
项目周报-项目集2"); //查询项目为未开始,日期为一周前的数据 -r($weekly->getPageNavTest($productID[1], $date[0])) && p() && e("
项目周报-项目3"); //查询项目为进行中,日期为当天的数据 -r($weekly->getPageNavTest($productID[1], $date[1])) && p() && e("
项目周报-项目3"); //查询项目为进行中,日期为一周前的数据 -r($weekly->getPageNavTest($productID[2], $date[0])) && p() && e("
项目周报-项目7"); //查询项目为已挂起,日期为当天的数据 -r($weekly->getPageNavTest($productID[2], $date[1])) && p() && e("
项目周报-项目7"); //查询项目为已挂起,日期为一周前的数据 -r($weekly->getPageNavTest($productID[3], $date[0])) && p() && e("
项目周报-项目8"); //查询项目为已关闭,日期为当天的数据 -r($weekly->getPageNavTest($productID[3], $date[1])) && p() && e("
项目周报-项目8"); //查询项目为已关闭,日期为一周前的数据 +r($weekly->getPageNavTest($productID[0], $date[0])) && p() && e('周报-项目19'); //查询项目为未开始,日期为当天的数据 +r($weekly->getPageNavTest($productID[0], $date[1])) && p() && e('周报-项目19'); //查询项目为未开始,日期为一周前的数据 +r($weekly->getPageNavTest($productID[1], $date[0])) && p() && e('周报-项目3'); //查询项目为进行中,日期为当天的数据 +r($weekly->getPageNavTest($productID[1], $date[1])) && p() && e('周报-项目3'); //查询项目为进行中,日期为一周前的数据 +r($weekly->getPageNavTest($productID[2], $date[0])) && p() && e('周报-项目7'); //查询项目为已挂起,日期为当天的数据 +r($weekly->getPageNavTest($productID[2], $date[1])) && p() && e('周报-项目7'); //查询项目为已挂起,日期为一周前的数据 +r($weekly->getPageNavTest($productID[3], $date[0])) && p() && e('周报-项目8'); //查询项目为已关闭,日期为当天的数据 +r($weekly->getPageNavTest($productID[3], $date[1])) && p() && e('周报-项目8'); //查询项目为已关闭,日期为一周前的数据 From 2dea32e6bee20c86f07246c1b8164124f8c536e9 Mon Sep 17 00:00:00 2001 From: wangxiaomeng Date: Sat, 7 May 2022 10:25:48 +0800 Subject: [PATCH 16/41] edit weekly --- test/model/weekly/getpagenav.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/model/weekly/getpagenav.php b/test/model/weekly/getpagenav.php index c8f6397685..faa38b85f2 100755 --- a/test/model/weekly/getpagenav.php +++ b/test/model/weekly/getpagenav.php @@ -1,4 +1,4 @@ -#!/usr/bin/env php +usr/bin/env php getPageNav(); cid=1 pid=1 -查询项目为未开始,日期为当天的数据 >>
项目周报-项目集2 -查询项目为未开始,日期为一周前的数据 >>
项目周报-项目集2 -查询项目为进行中,日期为当天的数据 >>
项目周报-项目3 -查询项目为进行中,日期为一周前的数据 >>
项目周报-项目3 -查询项目为已挂起,日期为当天的数据 >>
项目周报-项目7 -查询项目为已挂起,日期为一周前的数据 >>
项目周报-项目7 -查询项目为已关闭,日期为当天的数据 >>
项目周报-项目8 -查询项目为已关闭,日期为一周前的数据 >>
项目周报-项目8 +查询项目为未开始,日期为当天的数据 >> 周报-项目19 +查询项目为未开始,日期为一周前的数据 >> 周报-项目19 +查询项目为进行中,日期为当天的数据 >> 周报-项目3 +查询项目为进行中,日期为一周前的数据 >> 周报-项目3 +查询项目为已挂起,日期为当天的数据 >> 周报-项目7 +查询项目为已挂起,日期为一周前的数据 >> 周报-项目7 +查询项目为已关闭,日期为当天的数据 >> 周报-项目8 +查询项目为已关闭,日期为一周前的数据 >> 周报-项目8 */ $productID = array('19', '13', '17', '18'); $date = array('2022-05-07', ''); $weekly = new weeklyTest(); -r($weekly->getPageNavTest($productID[0], $date[0])) && p() && e('周报-项目19'); //查询项目为未开始,日期为当天的数据 -r($weekly->getPageNavTest($productID[0], $date[1])) && p() && e('周报-项目19'); //查询项目为未开始,日期为一周前的数据 +r($weekly->getPageNavTest($productID[0], $date[0])) && p() && e('周报-项目9'); //查询项目为未开始,日期为当天的数据 +r($weekly->getPageNavTest($productID[0], $date[1])) && p() && e('周报-项目9'); //查询项目为未开始,日期为一周前的数据 r($weekly->getPageNavTest($productID[1], $date[0])) && p() && e('周报-项目3'); //查询项目为进行中,日期为当天的数据 r($weekly->getPageNavTest($productID[1], $date[1])) && p() && e('周报-项目3'); //查询项目为进行中,日期为一周前的数据 r($weekly->getPageNavTest($productID[2], $date[0])) && p() && e('周报-项目7'); //查询项目为已挂起,日期为当天的数据 From a667418b5031afae4fbd63bad4b99b5c0aa8b62b Mon Sep 17 00:00:00 2001 From: liyang <“liyang@easycorp.ltd”> Date: Sat, 7 May 2022 10:26:34 +0800 Subject: [PATCH 17/41] Add notify data --- test/data/notify.yaml | 98 +++++++++++++++++++++++++++++++++++++ test/data/zentao/config.php | 1 + 2 files changed, 99 insertions(+) create mode 100644 test/data/notify.yaml diff --git a/test/data/notify.yaml b/test/data/notify.yaml new file mode 100644 index 0000000000..fca26c1104 --- /dev/null +++ b/test/data/notify.yaml @@ -0,0 +1,98 @@ +title: table zt_notify +desc: "消息通知" +author: automated export +version: "1.0" +fields: + - field: id + note: "ID" + range: 1-10000 + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: objectType + note: "对象类型" + range: mail + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: objectID + note: "对象ID" + range: 0 + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: action + note: "操作记录ID" + range: 0 + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: toList + note: "指派用户" + range: admin,user10,test10,dev10,top10 + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: ccList + range: 0 + note: "" + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: subject + note: "主题" + range: 1-100 + prefix: "主题" + postfix: "" + loop: 0 + format: "" + - field: data + note: "记录数据" + range: 1-100 + prefix: "用户创建了任务" + postfix: "" + loop: 0 + format: "" + - field: createdBy + note: "创建者" + range: dev12,test12,admin + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: createdDate + note: "创建日期" + range: "(1M)-(1w)" + type: timestamp + format: "YYYY-MM-DD hh:mm:ss" + prefix: "" + postfix: "" + loop: 0 + - field: sendTime + note: "发送日期" + range: "(1M)-(1w)" + type: timestamp + format: "YYYY-MM-DD hh:mm:ss" + prefix: "" + postfix: "" + loop: 0 + - field: status + note: "状态" + range: wait,fail + prefix: "" + postfix: "" + loop: 0 + format: "" + - field: failReason + note: "失败原因" + range: "" + prefix: "" + postfix: "" + loop: 0 + format: "" diff --git a/test/data/zentao/config.php b/test/data/zentao/config.php index efdfcbc3b4..19f49f5808 100644 --- a/test/data/zentao/config.php +++ b/test/data/zentao/config.php @@ -115,6 +115,7 @@ $builder->repo = array('rows' => 1, 'extends' => array('repo')); $builder->job = array('rows' => 2, 'extends' => array('job')); $builder->mr = array('rows' => 1, 'extends' => array('mr')); $builder->oauth = array('rows' => 90, 'extends' => array('oauth')); +$builder->notify = array('rows' => 10, 'extends' => array('notify')); $builder->vm = array('rows' => 1, 'extends' => array('vm')); $builder->vmtemplate = array('rows' => 1, 'extends' => array('vmtemplate')); From 31944ec84ffcd10139294cee4fdd30c79b6a206f Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Sat, 7 May 2022 10:31:14 +0800 Subject: [PATCH 18/41] * Add sso test case. --- test/class/sso.class.php | 59 +++++++++++++++++++++++++++++++++ test/data/user.yaml | 9 +++-- test/model/sso/createuser.php | 44 ++++++++++++++++++++++++ test/model/sso/getbinduser.php | 24 ++++++++++++++ test/model/sso/getbindusers.php | 17 ++++++++++ test/ztest | 3 ++ 6 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 test/class/sso.class.php create mode 100755 test/model/sso/createuser.php create mode 100755 test/model/sso/getbinduser.php create mode 100755 test/model/sso/getbindusers.php diff --git a/test/class/sso.class.php b/test/class/sso.class.php new file mode 100644 index 0000000000..0d3e81a3f1 --- /dev/null +++ b/test/class/sso.class.php @@ -0,0 +1,59 @@ +objectModel = $tester->loadModel('sso'); + } + + /** + * Test create a user. + * + * @param array $param + * @access public + * @return void + */ + public function createTest($param = array()) + { + foreach($param as $key => $value) $_POST[$key] = $value; + + $result = $this->objectModel->createUser(); + + unset($_POST); + if($result['status'] == 'fail') return 'fail'; + + $object = $this->objectModel->getBindUser($param['account']); + return $object; + } + + /** + * Test bind a user. + * + * @param array $param + * @param string $bindUser + * @access public + * @return void + */ + public function bindTest($param = array(), $bindUser = '') + { + global $tester; + if($bindUser) + { + $tester->session->ssoData = new stdClass(); + $tester->session->ssoData->account = $bindUser; + } + + foreach($param as $key => $value) $_POST[$key] = $value; + if(isset($param['password1'])) $_POST['passwordStrength'] = strlen($param['password1']); + + $object = $this->objectModel->bind(); + + unset($_POST); + + if(!$object) return 'fail'; + if(is_int($object)) return 'user get error'; + + return $object; + } +} diff --git a/test/data/user.yaml b/test/data/user.yaml index 670bc1aeff..16e537f0bd 100644 --- a/test/data/user.yaml +++ b/test/data/user.yaml @@ -50,14 +50,14 @@ fields: - field: commiter note: "源代码帐号" fields: - - field: commiter1 + - field: commiter1 range: admin,user{99},test{100},dev{100},pm{100},po{100},td{100},pd{100},qd{100},top{100},outside{100},others{100},a,bb,ccc,qwuiadsd?!2as@#%$aasd~aj1!@#1 - field: commiter2 range: [],1-99,1-100,1-100,1-100,1-100,1-100,1-100,1-100,1-100,1-100,1-100,[]{4} - field: avatar note: "" fields: - - field: avatar1 + - field: avatar1 range: /home/z/tmp/,/home/z/user/ - field: avatar2 range: 1-10,10-20 @@ -167,6 +167,11 @@ fields: range: 1 - field: ranzhi note: "ZDOO账号" + fields: + - field: account1 + range: admin,user{99},test{100},dev{100},pm{100},po{100},td{100},pd{100},qd{100},top{100},outside{100},others{100},a,bb,ccc,qwuiadsd?!2as@#%$aasd~aj1!@#1 + - field: account2 + range: [],1-99,1-100,1-100,1-100,1-100,1-100,1-100,1-100,1-100,1-100,1-100,[]{4} - field: score note: "积分" range: 1-10000:R diff --git a/test/model/sso/createuser.php b/test/model/sso/createuser.php new file mode 100755 index 0000000000..5e181bd87c --- /dev/null +++ b/test/model/sso/createuser.php @@ -0,0 +1,44 @@ +#!/usr/bin/env php +createUser(); +cid=1 +pid=1 + +用户存在的情况 >> fail +用户信息错误的情况 >> fail +用户不存在的情况 >> bindUser1 + +*/ + +$sso = new ssoTest(); + +$existsUser = array( + 'account' => 'admin' +); + +$newUser = array( + 'account' => 'bindUser1', + 'realname' => '绑定用户1', + 'email' => 'user@test.com', + 'gender' => 'm', + 'ranzhi' => 'bindUser1' +); + +$failUser = array( + 'account' => 'bindUser2', + 'realname' => '绑定用户2', + 'email' => 'user@test.com', + 'gender' => '', + 'ranzhi' => 'bindUser2' +); + +r($sso->createTest($existsUser)) && p('status') && e('fail'); // 用户存在的情况 +r($sso->createTest($failUser)) && p('status') && e('fail'); // 用户信息错误的情况 +r($sso->createTest($newUser)) && p('account') && e('bindUser1'); // 用户不存在的情况 +system("./ztest init"); diff --git a/test/model/sso/getbinduser.php b/test/model/sso/getbinduser.php new file mode 100755 index 0000000000..facc679613 --- /dev/null +++ b/test/model/sso/getbinduser.php @@ -0,0 +1,24 @@ +#!/usr/bin/env php +getBindUser(); +cid=1 +pid=1 + +用户不存在绑定的情况 >> not user +用户存在绑定的情况 >> admin + +*/ + +$sso = $tester->loadModel('sso'); + +$emptyUser = ''; +$realUser = 'admin'; + +$res = $sso->getBindUser($emptyUser); +if(!$res) $res = 'not user'; +r($res) && p() && e('not user'); // 用户不存在绑定的情况 +r($sso->getBindUser($realUser)) && p('account') && e('admin'); // 用户存在绑定的情况 diff --git a/test/model/sso/getbindusers.php b/test/model/sso/getbindusers.php new file mode 100755 index 0000000000..65a3d2fb00 --- /dev/null +++ b/test/model/sso/getbindusers.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getBindUsers(); +cid=1 +pid=1 + +获取第一条记录账号 >> admin + +*/ + +$sso = $tester->loadModel('sso'); + +r($sso->getBindUsers()) && p('admin') && e('admin'); // 获取第一条记录账号 diff --git a/test/ztest b/test/ztest index cfb9cad01a..e4b227b9a3 100755 --- a/test/ztest +++ b/test/ztest @@ -94,6 +94,9 @@ switch($argv[1]) case 'report': ztfRun('model/report'); break; + case 'sso': + ztfRun('model/sso'); + break; case 'stage': ztfRun('model/stage'); break; From 10020ed142cc67c9f0426fefdf3418c0e5662a06 Mon Sep 17 00:00:00 2001 From: wangxiaomeng Date: Sat, 7 May 2022 10:31:54 +0800 Subject: [PATCH 19/41] edit weekly --- test/model/weekly/getpagenav.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/model/weekly/getpagenav.php b/test/model/weekly/getpagenav.php index faa38b85f2..b61229aab8 100755 --- a/test/model/weekly/getpagenav.php +++ b/test/model/weekly/getpagenav.php @@ -10,8 +10,8 @@ title=测试 weeklyModel->getPageNav(); cid=1 pid=1 -查询项目为未开始,日期为当天的数据 >> 周报-项目19 -查询项目为未开始,日期为一周前的数据 >> 周报-项目19 +查询项目为未开始,日期为当天的数据 >> 周报-项目9 +查询项目为未开始,日期为一周前的数据 >> 周报-项目9 查询项目为进行中,日期为当天的数据 >> 周报-项目3 查询项目为进行中,日期为一周前的数据 >> 周报-项目3 查询项目为已挂起,日期为当天的数据 >> 周报-项目7 From 84f9b06602bc0d1904b130fba9ffb387f1fa6b5f Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Sat, 7 May 2022 02:31:57 +0000 Subject: [PATCH 20/41] * Add tutorial auto test. --- test/class/tutorial.class.php | 172 ++++++++++++++++++ test/model/tutorial/checknovice.php | 20 ++ test/model/tutorial/getexecution.php | 19 ++ test/model/tutorial/getexecutionpairs.php | 17 ++ test/model/tutorial/getexecutionproducts.php | 19 ++ test/model/tutorial/getexecutionstories.php | 17 ++ .../model/tutorial/getexecutionstorypairs.php | 17 ++ test/model/tutorial/getmodulepairs.php | 17 ++ test/model/tutorial/getproduct.php | 18 ++ test/model/tutorial/getproductpairs.php | 17 ++ test/model/tutorial/getproductstats.php | 17 ++ test/model/tutorial/getproject.php | 17 ++ test/model/tutorial/getprojectpairs.php | 17 ++ test/model/tutorial/getprojectstats.php | 19 ++ test/model/tutorial/getstories.php | 18 ++ test/model/tutorial/getteammembers.php | 17 ++ test/model/tutorial/getteammemberspairs.php | 17 ++ test/model/tutorial/gettutorialed.php | 17 ++ test/model/tutorial/getuserpairs.php | 17 ++ test/ztest | 7 +- 20 files changed, 494 insertions(+), 2 deletions(-) create mode 100644 test/class/tutorial.class.php create mode 100644 test/model/tutorial/checknovice.php create mode 100644 test/model/tutorial/getexecution.php create mode 100644 test/model/tutorial/getexecutionpairs.php create mode 100644 test/model/tutorial/getexecutionproducts.php create mode 100644 test/model/tutorial/getexecutionstories.php create mode 100644 test/model/tutorial/getexecutionstorypairs.php create mode 100644 test/model/tutorial/getmodulepairs.php create mode 100644 test/model/tutorial/getproduct.php create mode 100644 test/model/tutorial/getproductpairs.php create mode 100644 test/model/tutorial/getproductstats.php create mode 100644 test/model/tutorial/getproject.php create mode 100644 test/model/tutorial/getprojectpairs.php create mode 100644 test/model/tutorial/getprojectstats.php create mode 100644 test/model/tutorial/getstories.php create mode 100644 test/model/tutorial/getteammembers.php create mode 100644 test/model/tutorial/getteammemberspairs.php create mode 100644 test/model/tutorial/gettutorialed.php create mode 100644 test/model/tutorial/getuserpairs.php diff --git a/test/class/tutorial.class.php b/test/class/tutorial.class.php new file mode 100644 index 0000000000..b3f26312a0 --- /dev/null +++ b/test/class/tutorial.class.php @@ -0,0 +1,172 @@ +objectModel = $tester->loadModel('tutorial'); + } + + public function checkNoviceTest() + { + $this->app->user->modifyPassword = 1; + $objects = $this->objectModel->checkNovice(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getProductPairsTest() + { + $objects = $this->objectModel->getProductPairs(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getModulePairsTest() + { + $objects = $this->objectModel->getModulePairs(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getProductTest() + { + $objects = $this->objectModel->getProduct(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getProductStatsTest() + { + $objects = $this->objectModel->getProductStats(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getProjectTest() + { + $objects = $this->objectModel->getProject(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getProjectPairsTest() + { + $objects = $this->objectModel->getProjectPairs(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getProjectStatsTest($browseType = '') + { + $objects = $this->objectModel->getProjectStats($browseType = ''); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getStoriesTest() + { + $objects = $this->objectModel->getStories(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getExecutionPairsTest() + { + $objects = $this->objectModel->getExecutionPairs(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getExecutionTest() + { + $objects = $this->objectModel->getExecution(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getExecutionProductsTest() + { + $objects = $this->objectModel->getExecutionProducts(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getExecutionStoriesTest() + { + $objects = $this->objectModel->getExecutionStories(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getExecutionStoryPairsTest() + { + $objects = $this->objectModel->getExecutionStoryPairs(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getTeamMembersTest() + { + $objects = $this->objectModel->getTeamMembers(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getTeamMembersPairsTest() + { + $objects = $this->objectModel->getTeamMembersPairs(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getUserPairsTest() + { + $objects = $this->objectModel->getUserPairs(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } + + public function getTutorialedTest() + { + $objects = $this->objectModel->getTutorialed(); + + if(dao::isError()) return dao::getError(); + + return $objects; + } +} diff --git a/test/model/tutorial/checknovice.php b/test/model/tutorial/checknovice.php new file mode 100644 index 0000000000..c88b9f36ee --- /dev/null +++ b/test/model/tutorial/checknovice.php @@ -0,0 +1,20 @@ +#!/usr/bin/env php +checkNovice(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->checkNoviceTest()) && p() && e('0'); //检查当account是admin的时候的返回值。 +r($tutorial->checkNoviceTest()) && p() && e('0'); //检查当$this->app->user->modifyPassword是不为空的时候的返回值。 +su('guest'); +r($tutorial->checkNoviceTest()) && p() && e('0'); //检查当account是guest的时候的返回值。 diff --git a/test/model/tutorial/getexecution.php b/test/model/tutorial/getexecution.php new file mode 100644 index 0000000000..862226215c --- /dev/null +++ b/test/model/tutorial/getexecution.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getExecution(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getExecutionTest()) && p('id') && e('3'); //检查获取数据的id +r($tutorial->getExecutionTest()) && p('PM') && e('admin'); //检查获取数据的PM +r($tutorial->getExecutionTest()) && p('burns:0') && e('35'); //检查获取数据的burns diff --git a/test/model/tutorial/getexecutionpairs.php b/test/model/tutorial/getexecutionpairs.php new file mode 100644 index 0000000000..3e058f1586 --- /dev/null +++ b/test/model/tutorial/getexecutionpairs.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getExecutionPairs(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getExecutionPairsTest()) && p('3') && e('Test execution'); //检查获取的数据信息 diff --git a/test/model/tutorial/getexecutionproducts.php b/test/model/tutorial/getexecutionproducts.php new file mode 100644 index 0000000000..a55baa9884 --- /dev/null +++ b/test/model/tutorial/getexecutionproducts.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getExecutionProducts(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getExecutionProductsTest()) && p('1:type') && e('normal'); //测试拿到的数据是否正确 +r($tutorial->getExecutionProductsTest()) && p('1[branches]:1') && e('Test branch'); //测试拿到的数据是否正确 +r($tutorial->getExecutionProductsTest()) && p('1[plans]:1') && e('Test plan'); //测试拿到的数据是否正确 diff --git a/test/model/tutorial/getexecutionstories.php b/test/model/tutorial/getexecutionstories.php new file mode 100644 index 0000000000..c635786a6b --- /dev/null +++ b/test/model/tutorial/getexecutionstories.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getExecutionStories(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getExecutionStoriesTest()) && p('1:stage') && e('wait'); //检查是否获取到数据 diff --git a/test/model/tutorial/getexecutionstorypairs.php b/test/model/tutorial/getexecutionstorypairs.php new file mode 100644 index 0000000000..6a5e186093 --- /dev/null +++ b/test/model/tutorial/getexecutionstorypairs.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getExecutionStoryPairs(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getExecutionStoryPairsTest()) && p('1') && e('Test story'); diff --git a/test/model/tutorial/getmodulepairs.php b/test/model/tutorial/getmodulepairs.php new file mode 100644 index 0000000000..119538b2f8 --- /dev/null +++ b/test/model/tutorial/getmodulepairs.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getModulePairs(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getModulePairsTest()) && p('1') && e('Test module'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getproduct.php b/test/model/tutorial/getproduct.php new file mode 100644 index 0000000000..e0c51c7741 --- /dev/null +++ b/test/model/tutorial/getproduct.php @@ -0,0 +1,18 @@ +#!/usr/bin/env php +getProduct(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getProductTest()) && p('id') && e('1'); //测试是否能拿到数据 +r($tutorial->getProductTest()) && p('branches:1') && e('Test branch'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getproductpairs.php b/test/model/tutorial/getproductpairs.php new file mode 100644 index 0000000000..58248fe8f1 --- /dev/null +++ b/test/model/tutorial/getproductpairs.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getProductPairs(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getProductPairsTest()) && p('1') && e('Test product'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getproductstats.php b/test/model/tutorial/getproductstats.php new file mode 100644 index 0000000000..ba1edf796b --- /dev/null +++ b/test/model/tutorial/getproductstats.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getProductStats(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getProductStatsTest()) && p() && e(); diff --git a/test/model/tutorial/getproject.php b/test/model/tutorial/getproject.php new file mode 100644 index 0000000000..d2962ce551 --- /dev/null +++ b/test/model/tutorial/getproject.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getProject(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getProjectTest()) && p('type') && e('project'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getprojectpairs.php b/test/model/tutorial/getprojectpairs.php new file mode 100644 index 0000000000..26ddf80e1d --- /dev/null +++ b/test/model/tutorial/getprojectpairs.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getProjectPairs(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getProjectPairsTest()) && p('2') && e('Test Project'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getprojectstats.php b/test/model/tutorial/getprojectstats.php new file mode 100644 index 0000000000..4c6b2613d0 --- /dev/null +++ b/test/model/tutorial/getprojectstats.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +getProjectStats(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getProjectStatsTest()) && p('2:model') && e('scrum'); //测试是否能拿到数据 +r($tutorial->getProjectStatsTest()) && p('2[hours]:totalLeft') && e('0'); //测试是否能拿到数据 +r($tutorial->getProjectStatsTest()) && p('2[teamMembers]:0') && e('admin'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getstories.php b/test/model/tutorial/getstories.php new file mode 100644 index 0000000000..8485a1248a --- /dev/null +++ b/test/model/tutorial/getstories.php @@ -0,0 +1,18 @@ +#!/usr/bin/env php +getStories(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getStoriesTest()) && p('0:module') && e('1'); //测试是否能拿到数据 +r($tutorial->getStoriesTest()) && p('1:pri') && e('3'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getteammembers.php b/test/model/tutorial/getteammembers.php new file mode 100644 index 0000000000..1672027d2a --- /dev/null +++ b/test/model/tutorial/getteammembers.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getTeamMembers(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getTeamMembersTest()) && p('admin:days') && e('10'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getteammemberspairs.php b/test/model/tutorial/getteammemberspairs.php new file mode 100644 index 0000000000..77ea12413f --- /dev/null +++ b/test/model/tutorial/getteammemberspairs.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getTeamMembersPairs(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getTeamMembersPairsTest()) && p('admin') && e('admin'); diff --git a/test/model/tutorial/gettutorialed.php b/test/model/tutorial/gettutorialed.php new file mode 100644 index 0000000000..5393a33f7b --- /dev/null +++ b/test/model/tutorial/gettutorialed.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getTutorialed(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getTutorialedTest()) && p() && e('0'); diff --git a/test/model/tutorial/getuserpairs.php b/test/model/tutorial/getuserpairs.php new file mode 100644 index 0000000000..12634a76d5 --- /dev/null +++ b/test/model/tutorial/getuserpairs.php @@ -0,0 +1,17 @@ +#!/usr/bin/env php +getUserPairs(); +cid=1 +pid=1 + +*/ + +$tutorial = new tutorialTest(); + +r($tutorial->getUserPairsTest()) && p('admin') && e('admin'); //测试是否能拿到数据 diff --git a/test/ztest b/test/ztest index cfb9cad01a..2dd1c291ef 100755 --- a/test/ztest +++ b/test/ztest @@ -64,6 +64,9 @@ switch($argv[1]) case 'kanban': ztfRun('model/kanban'); break; + case 'message': + ztfRun('model/message'); + break; case 'model': ztfRun('model'); break; @@ -112,8 +115,8 @@ switch($argv[1]) case 'todo': ztfRun('model/todo'); break; - case 'message': - ztfRun('model/message'); + case 'tutorial': + ztfRun('model/tutorial'); break; case 'tree': ztfRun('model/tree'); From d27114d98d78e86276cc7b50f14be859c248f287 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Sat, 7 May 2022 10:32:17 +0800 Subject: [PATCH 21/41] * Remove bind func. --- test/class/sso.class.php | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/test/class/sso.class.php b/test/class/sso.class.php index 0d3e81a3f1..57753a8b63 100644 --- a/test/class/sso.class.php +++ b/test/class/sso.class.php @@ -26,34 +26,4 @@ class ssoTest $object = $this->objectModel->getBindUser($param['account']); return $object; } - - /** - * Test bind a user. - * - * @param array $param - * @param string $bindUser - * @access public - * @return void - */ - public function bindTest($param = array(), $bindUser = '') - { - global $tester; - if($bindUser) - { - $tester->session->ssoData = new stdClass(); - $tester->session->ssoData->account = $bindUser; - } - - foreach($param as $key => $value) $_POST[$key] = $value; - if(isset($param['password1'])) $_POST['passwordStrength'] = strlen($param['password1']); - - $object = $this->objectModel->bind(); - - unset($_POST); - - if(!$object) return 'fail'; - if(is_int($object)) return 'user get error'; - - return $object; - } } From 11a6f3353ce95cc1b65eef66e3a67494b3b3b289 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Sat, 7 May 2022 10:32:27 +0800 Subject: [PATCH 22/41] * Fix bug. --- test/model/pipeline/create.php | 6 +++--- test/model/pipeline/getpairs.php | 4 ++-- test/model/pipeline/update.php | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/model/pipeline/create.php b/test/model/pipeline/create.php index 110eefd069..9f8c1900ab 100644 --- a/test/model/pipeline/create.php +++ b/test/model/pipeline/create.php @@ -31,9 +31,9 @@ $data->url = 'http://www.zentaopms.com/'; $data->name = ''; $result4 = $pipeline->createTest('Jenkins', $data); //添加名称为空时 -r($result1) && p('type') && e('Jenkins'); //获取添加的type -r($result2) && p('account') && e('JenkinsAccount'); //获取添加的account +r($result1) && p('type') && e('Jenkins'); //获取添加的type +r($result2) && p('account') && e('JenkinsAccount'); //获取添加的account r($result3) && p('url:0') && e('『服务地址』应当为合法的URL。'); //添加错误的url信息 -r($result4) && p('name:0') && e('『名称』不能为空'); //添加名称为空时 +r($result4) && p('name:0') && e('『名称』不能为空'); //添加名称为空时 system('./ztest init'); diff --git a/test/model/pipeline/getpairs.php b/test/model/pipeline/getpairs.php index 8b67e1040a..2c856409f2 100644 --- a/test/model/pipeline/getpairs.php +++ b/test/model/pipeline/getpairs.php @@ -18,6 +18,6 @@ $data[0] = array('type' => 'gitlab', 'id' => 1); $data[1] = array('type' => 'sonarqube', 'id' => 2); $data[2] = array('type' => 'testType'); -r($pipeline->getPairs($data[0])) && p() && e('gitlab服务器'); //id为1且type为gitlab的pipeline名称 +r($pipeline->getPairs($data[0])) && p() && e('gitlab服务器'); //id为1且type为gitlab的pipeline名称 r($pipeline->getPairs($data[1])) && p() && e('sonarqube服务器'); //id为2且type为sonarqube的pipeline名称 -r($pipeline->getPairs($data[2])) && p() && e('没有获取到数据'); //获取不存在的type +r($pipeline->getPairs($data[2])) && p() && e('没有获取到数据'); //获取不存在的type diff --git a/test/model/pipeline/update.php b/test/model/pipeline/update.php index 5524297701..441f77f312 100644 --- a/test/model/pipeline/update.php +++ b/test/model/pipeline/update.php @@ -27,8 +27,8 @@ $result3 = $pipeline->updateTest(1); unset($_POST); -r($result1) && p('name') && e('测试修改gitlab服务器名称'); //获取修改后的name值 -r($result2) && p('name:0') && e('『名称』不能为空。'); //当名称为空时 -r($result3) && p('url:0') && e('『服务地址』不能为空。'); //url为空时 +r($result1) && p('name') && e('测试修改gitlab服务器名称'); //获取修改后的name值 +r($result2) && p('name:0') && e('『名称』不能为空。'); //当名称为空时 +r($result3) && p('url:0') && e('『服务地址』不能为空。'); //url为空时 system('./ztest init'); From b482db69c87813999b512968ee72d812470d1984 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Sat, 7 May 2022 02:41:12 +0000 Subject: [PATCH 23/41] * Add tutorial auto test. --- test/class/tutorial.class.php | 109 ++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/test/class/tutorial.class.php b/test/class/tutorial.class.php index b3f26312a0..c2d3157252 100644 --- a/test/class/tutorial.class.php +++ b/test/class/tutorial.class.php @@ -7,6 +7,12 @@ class tutorialTest $this->objectModel = $tester->loadModel('tutorial'); } + /** + * Check novice. + * + * @access public + * @return void + */ public function checkNoviceTest() { $this->app->user->modifyPassword = 1; @@ -17,6 +23,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial product pairs. + * + * @access public + * @return void + */ public function getProductPairsTest() { $objects = $this->objectModel->getProductPairs(); @@ -26,6 +38,12 @@ class tutorialTest return $objects; } + /** + * Get module pairs for tutorial. + * + * @access public + * @return void + */ public function getModulePairsTest() { $objects = $this->objectModel->getModulePairs(); @@ -35,6 +53,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial product. + * + * @access public + * @return void + */ public function getProductTest() { $objects = $this->objectModel->getProduct(); @@ -44,6 +68,12 @@ class tutorialTest return $objects; } + /** + * Get product stats for tutorial. + * + * @access public + * @return void + */ public function getProductStatsTest() { $objects = $this->objectModel->getProductStats(); @@ -53,6 +83,12 @@ class tutorialTest return $objects; } + /** + * Get project for tutorial. + * + * @access public + * @return void + */ public function getProjectTest() { $objects = $this->objectModel->getProject(); @@ -62,6 +98,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial project pairs. + * + * @access public + * @return void + */ public function getProjectPairsTest() { $objects = $this->objectModel->getProjectPairs(); @@ -71,6 +113,13 @@ class tutorialTest return $objects; } + /** + * Get project stats for tutorial. + * + * @param string $browseType + * @access public + * @return void + */ public function getProjectStatsTest($browseType = '') { $objects = $this->objectModel->getProjectStats($browseType = ''); @@ -80,6 +129,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial stories. + * + * @access public + * @return void + */ public function getStoriesTest() { $objects = $this->objectModel->getStories(); @@ -89,6 +144,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial Execution pairs. + * + * @access public + * @return void + */ public function getExecutionPairsTest() { $objects = $this->objectModel->getExecutionPairs(); @@ -98,6 +159,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial execution. + * + * @access public + * @return void + */ public function getExecutionTest() { $objects = $this->objectModel->getExecution(); @@ -107,6 +174,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial execution products. + * + * @access public + * @return void + */ public function getExecutionProductsTest() { $objects = $this->objectModel->getExecutionProducts(); @@ -116,6 +189,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial execution stories. + * + * @access public + * @return void + */ public function getExecutionStoriesTest() { $objects = $this->objectModel->getExecutionStories(); @@ -125,6 +204,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial execution story pairs. + * + * @access public + * @return void + */ public function getExecutionStoryPairsTest() { $objects = $this->objectModel->getExecutionStoryPairs(); @@ -134,6 +219,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial team members. + * + * @access public + * @return void + */ public function getTeamMembersTest() { $objects = $this->objectModel->getTeamMembers(); @@ -143,6 +234,12 @@ class tutorialTest return $objects; } + /** + * Get team members pairs. + * + * @access public + * @return void + */ public function getTeamMembersPairsTest() { $objects = $this->objectModel->getTeamMembersPairs(); @@ -152,6 +249,12 @@ class tutorialTest return $objects; } + /** + * Get tutorial user pairs. + * + * @access public + * @return void + */ public function getUserPairsTest() { $objects = $this->objectModel->getUserPairs(); @@ -161,6 +264,12 @@ class tutorialTest return $objects; } + /** + * Get tutorialed. + * + * @access public + * @return void + */ public function getTutorialedTest() { $objects = $this->objectModel->getTutorialed(); From ba659545554b568cf66475ab66dc764fb0150cdb Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Sat, 7 May 2022 10:42:34 +0800 Subject: [PATCH 24/41] * Fix bug. --- test/class/pipeline.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/class/pipeline.class.php b/test/class/pipeline.class.php index 2bb604620e..2fd000a20b 100644 --- a/test/class/pipeline.class.php +++ b/test/class/pipeline.class.php @@ -51,7 +51,9 @@ class pipelineTest /** * Get pipeline pairs * - * @return array + * @param int $data + * @access public + * @return array */ public function getPairs($data) { @@ -67,8 +69,10 @@ class pipelineTest /** * Create a pipeline. * + * @param int $type + * @param int $param * @access public - * @return bool + * @return void */ public function createTest($type, $param) { From 80fea70b03d19087994c39d9147925eab2c4ad23 Mon Sep 17 00:00:00 2001 From: wangxiaomeng Date: Sat, 7 May 2022 10:42:49 +0800 Subject: [PATCH 25/41] edit weekly --- test/class/weekly.class.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/class/weekly.class.php b/test/class/weekly.class.php index 8f26e51f99..0538c73170 100644 --- a/test/class/weekly.class.php +++ b/test/class/weekly.class.php @@ -13,7 +13,7 @@ class weeklyTest * GetPageNav * * @param int $projectID - * @param int $date + * @param string $date * @access public * @return string */ @@ -35,6 +35,7 @@ class weeklyTest * GetWeekPairs * * @param int $begin + * @param int $end * @access public * @return array */ @@ -84,7 +85,7 @@ class weeklyTest * GetFromDB * * @param int $project - * @param int $date + * @param string $date * @access public * @return object */ @@ -102,7 +103,7 @@ class weeklyTest * Save data. * * @param int $project - * @param int $date + * @param string $date * @access public * @return void */ @@ -120,8 +121,8 @@ class weeklyTest /** * GetWeekSN * - * @param int $begin - * @param int $date + * @param string $begin + * @param string $date * @access public * @return int */ @@ -138,7 +139,7 @@ class weeklyTest /** * Get monday for a date. * - * @param int $date + * @param string $date * @access public * @return date */ @@ -155,7 +156,7 @@ class weeklyTest /** * GetThisSunday * - * @param int $date + * @param string $date * @access public * @return date */ @@ -172,7 +173,7 @@ class weeklyTest /** * GetLastDay * - * @param int $date + * @param string $date * @access public * @return string */ From db997a1fb00db81d78d3c4022296fa324f6aae18 Mon Sep 17 00:00:00 2001 From: zhouxudong Date: Sat, 7 May 2022 02:54:01 +0000 Subject: [PATCH 26/41] * Add tutorial auto test. --- test/class/tutorial.class.php | 2 +- test/model/tutorial/getexecutionstorypairs.php | 2 +- test/model/tutorial/getproductstats.php | 3 ++- test/model/tutorial/getteammemberspairs.php | 2 +- test/model/tutorial/gettutorialed.php | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/class/tutorial.class.php b/test/class/tutorial.class.php index c2d3157252..b7c646167f 100644 --- a/test/class/tutorial.class.php +++ b/test/class/tutorial.class.php @@ -80,7 +80,7 @@ class tutorialTest if(dao::isError()) return dao::getError(); - return $objects; + return $objects[0][0]['products']; } /** diff --git a/test/model/tutorial/getexecutionstorypairs.php b/test/model/tutorial/getexecutionstorypairs.php index 6a5e186093..186628d4a0 100644 --- a/test/model/tutorial/getexecutionstorypairs.php +++ b/test/model/tutorial/getexecutionstorypairs.php @@ -14,4 +14,4 @@ pid=1 $tutorial = new tutorialTest(); -r($tutorial->getExecutionStoryPairsTest()) && p('1') && e('Test story'); +r($tutorial->getExecutionStoryPairsTest()) && p('1') && e('Test story'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getproductstats.php b/test/model/tutorial/getproductstats.php index ba1edf796b..7308866323 100644 --- a/test/model/tutorial/getproductstats.php +++ b/test/model/tutorial/getproductstats.php @@ -14,4 +14,5 @@ pid=1 $tutorial = new tutorialTest(); -r($tutorial->getProductStatsTest()) && p() && e(); +r($tutorial->getProductStatsTest()) && p('1:code') && e('test'); //测试是否能拿到数据 +r($tutorial->getProductStatsTest()) && p('1[branches]:1') && e('Test branch'); //测试是否能拿到数据 diff --git a/test/model/tutorial/getteammemberspairs.php b/test/model/tutorial/getteammemberspairs.php index 77ea12413f..ce359fa5eb 100644 --- a/test/model/tutorial/getteammemberspairs.php +++ b/test/model/tutorial/getteammemberspairs.php @@ -14,4 +14,4 @@ pid=1 $tutorial = new tutorialTest(); -r($tutorial->getTeamMembersPairsTest()) && p('admin') && e('admin'); +r($tutorial->getTeamMembersPairsTest()) && p('admin') && e('admin'); //测试是否能拿到数据 diff --git a/test/model/tutorial/gettutorialed.php b/test/model/tutorial/gettutorialed.php index 5393a33f7b..2db34cf134 100644 --- a/test/model/tutorial/gettutorialed.php +++ b/test/model/tutorial/gettutorialed.php @@ -14,4 +14,4 @@ pid=1 $tutorial = new tutorialTest(); -r($tutorial->getTutorialedTest()) && p() && e('0'); +r($tutorial->getTutorialedTest()) && p() && e('0'); //测试是否能拿到数据 From 87e4148d226fcd84eac07b3fbc13f386fa4cc7f6 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Sat, 7 May 2022 10:58:07 +0800 Subject: [PATCH 27/41] * Add unit test of file. --- test/class/file.class.php | 159 +++++-------------------- test/data/usertpl.yaml | 2 +- test/model/file/getexporttemplate.php | 38 ++++++ test/model/file/saveexporttemplate.php | 53 +++++++++ 4 files changed, 122 insertions(+), 130 deletions(-) create mode 100755 test/model/file/getexporttemplate.php create mode 100755 test/model/file/saveexporttemplate.php diff --git a/test/class/file.class.php b/test/class/file.class.php index eb14b4b384..e69398e11d 100644 --- a/test/class/file.class.php +++ b/test/class/file.class.php @@ -7,15 +7,6 @@ class fileTest $this->objectModel = $tester->loadModel('file'); } - public function __constructTest() - { - $objects = $this->objectModel->construct(); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** * Test get files of an object. * @@ -55,15 +46,6 @@ class fileTest return $object; } - public function saveUploadTest($objectType = '', $objectID = '', $extra = '', $filesName = 'files', $labelsName = 'labels') - { - $objects = $this->objectModel->saveUpload($objectType = '', $objectID = '', $extra = '', $filesName = 'files', $labelsName = 'labels'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** * Test get counts of uploaded files. * @@ -134,15 +116,6 @@ class fileTest return $object; } - public function saveUploadFileTest($file, $uid) - { - $objects = $this->objectModel->saveUploadFile($file, $uid); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** * Test get extension of a file. * @@ -159,6 +132,13 @@ class fileTest return $string; } + /** + * Test get save name. + * + * @param string $pathName + * @access public + * @return string + */ public function getSaveNameTest($pathName) { $objects = $this->objectModel->getSaveName($pathName); @@ -184,13 +164,20 @@ class fileTest return $realpath; } + /** + * Test get export tpl. + * + * @param string $module + * @access public + * @return array + */ public function getExportTemplateTest($module) { $objects = $this->objectModel->getExportTemplate($module); if(dao::isError()) return dao::getError(); - return $objects; + return count($objects); } /** @@ -209,22 +196,26 @@ class fileTest return $path; } - public function saveExportTemplateTest($module) + /** + * Test save export template. + * + * @param string $module + * @access public + * @return object + */ + public function saveExportTemplateTest($module, $file) { - $objects = $this->objectModel->saveExportTemplate($module); + foreach($file as $key => $value) $_POST[$key] = $value; - if(dao::isError()) return dao::getError(); + $objectID = $this->objectModel->saveExportTemplate($module); - return $objects; - } + unset($_POST); - public function setPathNameTest($fileID, $extension) - { - $objects = $this->objectModel->setPathName($fileID, $extension); + if(dao::isError()) return dao::getError()['title'][0]; - if(dao::isError()) return dao::getError(); - - return $objects; + global $tester; + $object = $tester->dao->select('*')->from(TABLE_USERTPL)->where('id')->eq($objectID)->fetch(); + return $object; } /** @@ -262,60 +253,6 @@ class fileTest return $path; } - public function setImgSizeTest($content, $maxSize = 0) - { - $objects = $this->objectModel->setImgSize($content, $maxSize = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function replaceFileTest($fileID, $postName = 'upFile') - { - $objects = $this->objectModel->replaceFile($fileID, $postName = 'upFile'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function cropImageTest($rawImage, $target, $x, $y, $width, $height, $resizeWidth = 0, $resizeHeight = 0) - { - $objects = $this->objectModel->cropImage($rawImage, $target, $x, $y, $width, $height, $resizeWidth = 0, $resizeHeight = 0); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function pasteImageTest($data, $uid = '', $safe = false) - { - $objects = $this->objectModel->pasteImage($data, $uid = '', $safe = false); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function parseCSVTest($fileName) - { - $objects = $this->objectModel->parseCSV($fileName); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function processImgURLTest($data, $editorList, $uid = '') - { - $objects = $this->objectModel->processImgURL($data, $editorList, $uid = ''); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** * Test compress image. * @@ -332,15 +269,6 @@ class fileTest return $object; } - public function imagecreatefrombmpTest($filename) - { - $objects = $this->objectModel->imagecreatefrombmp($filename); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** * Test update objectID. * @@ -367,33 +295,6 @@ class fileTest return $objects; } - public function replaceImgURLTest($data, $fields) - { - $objects = $this->objectModel->replaceImgURL($data, $fields); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function sendDownHeaderTest($fileName, $fileType, $content, $type = 'content') - { - $objects = $this->objectModel->sendDownHeader($fileName, $fileType, $content, $type = 'content'); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - - public function getImageSizeTest($file) - { - $objects = $this->objectModel->getImageSize($file); - - if(dao::isError()) return dao::getError(); - - return $objects; - } - /** * Test get file pairs. * diff --git a/test/data/usertpl.yaml b/test/data/usertpl.yaml index a282e2086f..015c97b661 100644 --- a/test/data/usertpl.yaml +++ b/test/data/usertpl.yaml @@ -19,7 +19,7 @@ fields: format: "" - field: type note: "类型" - range: task,story,bug,exportstory + range: exporttask,story,exportbug,exportstory prefix: "" postfix: "" loop: 0 diff --git a/test/model/file/getexporttemplate.php b/test/model/file/getexporttemplate.php new file mode 100755 index 0000000000..80957e3c68 --- /dev/null +++ b/test/model/file/getexporttemplate.php @@ -0,0 +1,38 @@ +#!/usr/bin/env php +getExportTemplate(); +cid=1 +pid=1 + +测试获取 用户admin task 模块的用户模板 >> 1 +测试获取 用户admin bug 模块的用户模板 >> 0 +测试获取 用户admin story 模块的用户模板 >> 2 +测试获取 用户dev10 task 模块的用户模板 >> 0 +测试获取 用户dev10 bug 模块的用户模板 >> 1 +测试获取 用户dev10 story 模块的用户模板 >> 2 +测试获取 用户test10 task 模块的用户模板 >> 1 +测试获取 用户test10 bug 模块的用户模板 >> 0 +测试获取 用户test10 story 模块的用户模板 >> 2 + +*/ +$moduleName = array('task', 'bug', 'story'); + +$file = new fileTest(); + +su('admin'); +r($file->getExportTemplateTest($moduleName[0])) && p() && e('1'); // 测试获取 用户admin task 模块的用户模板 +r($file->getExportTemplateTest($moduleName[1])) && p() && e('0'); // 测试获取 用户admin bug 模块的用户模板 +r($file->getExportTemplateTest($moduleName[2])) && p() && e('2'); // 测试获取 用户admin story 模块的用户模板 +su('dev10'); +r($file->getExportTemplateTest($moduleName[0])) && p() && e('0'); // 测试获取 用户dev10 task 模块的用户模板 +r($file->getExportTemplateTest($moduleName[1])) && p() && e('1'); // 测试获取 用户dev10 bug 模块的用户模板 +r($file->getExportTemplateTest($moduleName[2])) && p() && e('2'); // 测试获取 用户dev10 story 模块的用户模板 +su('test10'); +r($file->getExportTemplateTest($moduleName[0])) && p() && e('1'); // 测试获取 用户test10 task 模块的用户模板 +r($file->getExportTemplateTest($moduleName[1])) && p() && e('0'); // 测试获取 用户test10 bug 模块的用户模板 +r($file->getExportTemplateTest($moduleName[2])) && p() && e('2'); // 测试获取 用户test10 story 模块的用户模板 \ No newline at end of file diff --git a/test/model/file/saveexporttemplate.php b/test/model/file/saveexporttemplate.php new file mode 100755 index 0000000000..25efcc6879 --- /dev/null +++ b/test/model/file/saveexporttemplate.php @@ -0,0 +1,53 @@ +#!/usr/bin/env php +saveExportTemplate(); +cid=1 +pid=1 + +测试新建 公共 bug 模板 >> 新建的公共bug模板,1 +测试新建 私有 bug 模板 >> 新建的私有bug模板,0 +测试新建 公共 task 模板 >> 新建的公共task模板,1 +测试新建 私有 task 模板 >> 新建的私有task模板,0 +测试新建 重名 模板 >> 『模板名称』已经有『新建的公共bug模板』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。 + +*/ +$module = array('bug', 'task'); + +$file1 = new stdclass(); +$file1->title = '新建的公共bug模板'; +$file1->content = array('id', 'product', 'branch', 'module', 'project', 'execution', 'story', 'task', 'title', 'keywords', 'severity', 'pri', 'type', 'os', 'browser', 'steps', 'status', 'deadline', 'activatedCount', 'confirmed', 'mailto', 'openedBy', 'openedDate', 'openedBuild', 'assignedTo', 'assignedDate', 'resolvedBy', 'resolution', 'resolvedBuild', 'resolvedDate', 'closedBy', 'closedDate', 'duplicateBug', 'linkBug', 'case', 'lastEditedBy', 'lastEditedDate', 'files', 'identify'); +$file1->public = 1; + +$file2 = new stdclass(); +$file2->title = '新建的私有bug模板'; +$file2->content = array('id', 'product', 'branch', 'module', 'project', 'execution', 'story', 'task', 'title', 'keywords', ); +$file2->public = 0; + +$file3 = new stdclass(); +$file3->title = '新建的公共task模板'; +$file3->content = array('id', 'product', 'type', 'status', 'deadline', 'openedBy', 'openedDate', 'openedBuild', 'assignedTo', 'assignedDate', 'closedBy', 'closedDate', 'duplicateBug', 'linkBug', 'case', 'lastEditedBy', 'lastEditedDate'); +$file3->public = 1; + +$file4 = new stdclass(); +$file4->title = '新建的私有task模板'; +$file4->content = array('id', 'product', 'type', 'status', 'deadline', 'lastEditedBy', 'lastEditedDate'); +$file4->public = 0; + +$file5 = new stdclass(); +$file5->title = '新建的公共bug模板'; +$file5->content = array('id', 'product', 'branch', 'module', 'project', 'execution', 'story', 'task', 'title', 'keywords', 'severity', 'pri', 'type', 'os', 'browser', 'steps', 'status', 'deadline', 'activatedCount', 'confirmed', 'mailto', 'openedBy', 'openedDate', 'openedBuild', 'assignedTo', 'assignedDate', 'resolvedBy', 'resolution', 'resolvedBuild', 'resolvedDate', 'closedBy', 'closedDate', 'duplicateBug', 'linkBug', 'case', 'lastEditedBy', 'lastEditedDate', 'files', 'identify'); +$file5->public = 1; + +$file = new fileTest(); + +r($file->saveExportTemplateTest($module[0], $file1)) && p('title,public') && e('新建的公共bug模板,1'); // 测试新建 公共 bug 模板 +r($file->saveExportTemplateTest($module[0], $file2)) && p('title,public') && e('新建的私有bug模板,0'); // 测试新建 私有 bug 模板 +r($file->saveExportTemplateTest($module[1], $file3)) && p('title,public') && e('新建的公共task模板,1'); // 测试新建 公共 task 模板 +r($file->saveExportTemplateTest($module[1], $file4)) && p('title,public') && e('新建的私有task模板,0'); // 测试新建 私有 task 模板 +r($file->saveExportTemplateTest($module[0], $file5)) && p() && e('『模板名称』已经有『新建的公共bug模板』这条记录了。如果您确定该记录已删除,请到后台-系统-数据-回收站还原。'); // 测试新建 重名 模板 \ No newline at end of file From 56706969610ca22d0b47319091aedd55d6e3e44c Mon Sep 17 00:00:00 2001 From: lanzongjun Date: Sat, 7 May 2022 11:22:26 +0800 Subject: [PATCH 28/41] * unit test entry --- test/class/entry.class.php | 231 +++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 test/class/entry.class.php diff --git a/test/class/entry.class.php b/test/class/entry.class.php new file mode 100644 index 0000000000..d1e41f7de9 --- /dev/null +++ b/test/class/entry.class.php @@ -0,0 +1,231 @@ +objectModel = $tester->loadModel('entry'); + } + + /** + * Test get entry by id. + * + * @param int $entryID + * @access public + * @return object + */ + public function getByIdTest($entryID) + { + $object = $this->objectModel->getById($entryID); + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $object; + } + } + + /** + * Test get entry by code. + * + * @param int $code + * @access public + * @return object + */ + public function getByCodeTest($code) + { + $object = $this->objectModel->getByCode($code); + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $object; + } + } + + /** + * Test get entry by key. + * + * @param int $key + * @access public + * @return object + */ + public function getByKeyTest($key) + { + $object = $this->objectModel->getByKey($key); + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $object; + } + } + + /** + * Get list test. + * + * @param string $orderBy + * @param int $pager + * @access public + * @return object + */ + public function getListTest($orderBy = 'id_desc', $pager = null) + { + $objects = $this->objectModel->getList($orderBy, $pager); + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $objects; + } + } + + /** + * Get logs test. + * + * @param int $id + * @param string $orderBy + * @param int $pager + * @access public + * @return object + */ + public function getLogsTest($id, $orderBy = 'date_desc', $pager = null) + { + $object = $this->objectModel->getLogs($id, $orderBy, $paper); + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $object; + } + } + + /** + * Test create a object. + * + * @param array $params + * @access public + * @return object + */ + public function createObject($params = array()) + { + $createFields = array(); + $createFields['name'] = '这是应用名称'; + $createFields['code'] = 'code'; + $createFields['account'] = 'admin'; + $createFields['key'] = md5(time()); + + foreach($createFields as $field => $defaultValue) $_POST[$field] = $defaultValue; + + foreach($params as $key => $value) $_POST[$key] = $value; + + $objectID = $this->objectModel->create(); + unset($_POST); + if(dao::isError()) + { + return dao::getError(); + } + else + { + $object = $this->objectModel->getById($objectID); + return $object; + } + } + + /** + * Test update a entry. + * + * @param int $entryID + * @param int $params + * @access public + * @return object + */ + public function updateObject($entryID, $params) + { + global $tester; + + $object = $tester->dbh->query("SELECT * FROM " . TABLE_ENTRY ." WHERE id = $entryID")->fetch(); + + foreach($object as $field => $value) + { + if(in_array($field, array_keys($params))) + { + $_POST[$field] = $params[$field]; + } + else + { + $_POST[$field] = $value; + } + } + + $change = $this->objectModel->update($entryID); + if($change == array()) $change = '没有数据更新'; + unset($_POST); + + if(dao::isError()) + { + return dao::getError(); + } + else + { + return $change; + } + } + + /** + * Test update calledTime. + * + * @param int $code + * @param int $time + * @access public + * @return object + */ + public function updateCalledTimeTest($code, $time) + { + $this->objectModel->updateCalledTime($code, $time); + if(dao::isError()) + { + return dao::getError(); + } + else + { + $object = $this->objectModel->getByCode($code); + return $object; + } + } + + /** + * Test save a log. + * + * @param int $entryID + * @param int $url + * @access public + * @return object + */ + public function saveLogTest($entryID, $url) + { + $this->objectModel->saveLog($entryID, $url); + if(dao::isError()) + { + return dao::getError(); + } + else + { + global $tester; + $object = $tester->dbh->query("SELECT * FROM " . TABLE_LOG ." WHERE objectID = $entryID AND objectType = 'entry'")->fetch(); + return $object; + } + + } + +} From 6e71332b6a8b5e5bf250f0bf559c0d6b2c7376c6 Mon Sep 17 00:00:00 2001 From: lanzongjun Date: Sat, 7 May 2022 11:26:53 +0800 Subject: [PATCH 29/41] * unit test entry --- test/model/entry/create.php | 33 +++++++++++++++++++++++++++++ test/model/entry/getbycode.php | 28 ++++++++++++++++++++++++ test/model/entry/getbyid.php | 28 ++++++++++++++++++++++++ test/model/entry/getbykey.php | 28 ++++++++++++++++++++++++ test/model/entry/getlist.php | 23 ++++++++++++++++++++ test/model/entry/getlogs.php | 26 +++++++++++++++++++++++ test/model/entry/savelog.php | 23 ++++++++++++++++++++ test/model/entry/update.php | 33 +++++++++++++++++++++++++++++ test/model/entry/updatecalltime.php | 25 ++++++++++++++++++++++ test/ztest | 12 +++++------ 10 files changed, 252 insertions(+), 7 deletions(-) create mode 100755 test/model/entry/create.php create mode 100755 test/model/entry/getbycode.php create mode 100755 test/model/entry/getbyid.php create mode 100755 test/model/entry/getbykey.php create mode 100755 test/model/entry/getlist.php create mode 100755 test/model/entry/getlogs.php create mode 100755 test/model/entry/savelog.php create mode 100755 test/model/entry/update.php create mode 100755 test/model/entry/updatecalltime.php diff --git a/test/model/entry/create.php b/test/model/entry/create.php new file mode 100755 index 0000000000..0fcc195a78 --- /dev/null +++ b/test/model/entry/create.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +create(); +cid=1 +pid=1 + +测试创建应用name为空报错 >> 『名称』不能为空 +测试创建应用code为空报错 >> 『代号』不能为空 +测试创建应用name为name_test >> name_test +测试创建应用code为code_test >> code_test + +*/ + +$e_name = array('name' => 'name_test'); +$e_code = array('code' => 'code_test'); +$e_name_blank = array('name' => ''); +$e_code_blank = array('code' => ''); + +$entry = new entryTest(); + +$result_name = $entry->createObject($e_name_blank); +$result_code = $entry->createObject($e_code_blank); +r($result_name['name'][0]) && p() && e('『名称』不能为空'); // 测试创建应用name为空报错 +r($result_code['code'][0]) && p() && e('『代号』不能为空'); // 测试创建应用code为空报错 +r($entry->createObject($e_name)) && p('name') && e('name_test'); // 测试创建应用name为name_test +r($entry->createObject($e_code)) && p('code') && e('code_test'); // 测试创建应用code为code_test +system("./ztest init"); diff --git a/test/model/entry/getbycode.php b/test/model/entry/getbycode.php new file mode 100755 index 0000000000..90cdd14aff --- /dev/null +++ b/test/model/entry/getbycode.php @@ -0,0 +1,28 @@ +#!/usr/bin/env php +getByCode(); +cid=1 +pid=1 + +查询code为code1的entry的name >> 这是应用名称1 +查询code为code1的entry的account >> accountadmin +查询code为code2的entry的name >> 0 +查询code为code2的entry的account >> 0 + +*/ + +$entryCodeList = array('code1', 'code2'); + +$entry = new entryTest(); + +r($entry->getByCodeTest($entryCodeList[0])) && p('name') && e('这是应用名称1'); // 查询code为code1的entry的name +r($entry->getByCodeTest($entryCodeList[0])) && p('account') && e('accountadmin'); // 查询code为code1的entry的account +r($entry->getByCodeTest($entryCodeList[1])) && p('name') && e('0'); // 查询code为code2的entry的name +r($entry->getByCodeTest($entryCodeList[1])) && p('account') && e('0'); // 查询code为code2的entry的account +system("./ztest init"); diff --git a/test/model/entry/getbyid.php b/test/model/entry/getbyid.php new file mode 100755 index 0000000000..7794a439dd --- /dev/null +++ b/test/model/entry/getbyid.php @@ -0,0 +1,28 @@ +#!/usr/bin/env php +getById(); +cid=1 +pid=1 + +查询id为1的entry的name >> 这是应用名称1 +查询id为1的entry的account >> accountadmin +查询id为1000001的entry的name >> 0 +查询id为1000001的entry的account >> 0 + +*/ + +$entryIDList = array('1', '1000001'); + +$entry = new entryTest(); + +r($entry->getByIdTest($entryIDList[0])) && p('name') && e('这是应用名称1'); // 查询id为1的entry的name +r($entry->getByIdTest($entryIDList[0])) && p('account') && e('accountadmin'); // 查询id为1的entry的account +r($entry->getByIdTest($entryIDList[1])) && p('name') && e('0'); // 查询id为1000001的entry的name +r($entry->getByIdTest($entryIDList[1])) && p('account') && e('0'); // 查询id为1000001的entry的account +system("./ztest init"); diff --git a/test/model/entry/getbykey.php b/test/model/entry/getbykey.php new file mode 100755 index 0000000000..5017815160 --- /dev/null +++ b/test/model/entry/getbykey.php @@ -0,0 +1,28 @@ +#!/usr/bin/env php +getByKey(); +cid=1 +pid=1 + +查询key为792b9b972157d2d8531b43e04c0af021的entry的name >> 这是应用名称1 +查询key为792b9b972157d2d8531b43e04c0af021的entry的account >> accountadmin +查询key为空的entry的name >> 0 +查询key为空的entry的account >> 0 + +*/ + +$entryKeyList = array('792b9b972157d2d8531b43e04c0af021', ''); + +$entry = new entryTest(); + +r($entry->getByKeyTest($entryKeyList[0])) && p('name') && e('这是应用名称1'); // 查询key为792b9b972157d2d8531b43e04c0af021的entry的name +r($entry->getByKeyTest($entryKeyList[0])) && p('account') && e('accountadmin'); // 查询key为792b9b972157d2d8531b43e04c0af021的entry的account +r($entry->getByKeyTest($entryKeyList[1])) && p('name') && e('0'); // 查询key为空的entry的name +r($entry->getByKeyTest($entryKeyList[1])) && p('account') && e('0'); // 查询key为空的entry的account +system("./ztest init"); diff --git a/test/model/entry/getlist.php b/test/model/entry/getlist.php new file mode 100755 index 0000000000..e7573edfce --- /dev/null +++ b/test/model/entry/getlist.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +getList(); +cid=1 +pid=1 + +测试获取列表的个数,目前只有一个 >> 1 +测试获取列表某个应用的名称信息 >> 这是应用名称1 + +*/ + +$entry = new entryTest(); +$list = $entry->getListTest(); + +r(count($list)) && p() && e('1'); //测试获取列表的个数,目前只有一个 +r($list) && p('1:name') && e('这是应用名称1'); //测试获取列表某个应用的名称信息 +system("./ztest init"); diff --git a/test/model/entry/getlogs.php b/test/model/entry/getlogs.php new file mode 100755 index 0000000000..026c470f09 --- /dev/null +++ b/test/model/entry/getlogs.php @@ -0,0 +1,26 @@ +#!/usr/bin/env php +getLogs(); +cid=1 +pid=1 + +测试获取列表的个数,ID为1的日志数为1 >> 1 +测试获取列表个数,ID为100001的日志数为0 >> 0 + +*/ + +$entryIDList = array('1', '100001'); + +$entry = new entryTest(); + +$list_1 = $entry->getLogsTest($entryIDList[0]); +$list_1000001 = $entry->getLogsTest($entryIDList[1]); +r(count($list_1)) && p() && e('1'); //测试获取列表的个数,ID为1的日志数为1 +r(count($list_1000001)) && p() && e('0'); //测试获取列表个数,ID为100001的日志数为0 +system("./ztest init"); diff --git a/test/model/entry/savelog.php b/test/model/entry/savelog.php new file mode 100755 index 0000000000..41b113fa99 --- /dev/null +++ b/test/model/entry/savelog.php @@ -0,0 +1,23 @@ +#!/usr/bin/env php +saveLog(); +cid=1 +pid=1 + +测试插入一条日志 >> entry + +*/ + +$e_id = 1; +$e_url = 'http://qcmmi.com'; + +$entry = new entryTest(); + +r($entry->saveLogTest($e_id, $e_url)) && p('objectType') && e('entry'); //测试插入一条日志 +system("./ztest init"); diff --git a/test/model/entry/update.php b/test/model/entry/update.php new file mode 100755 index 0000000000..c0d0628e2c --- /dev/null +++ b/test/model/entry/update.php @@ -0,0 +1,33 @@ +#!/usr/bin/env php +update(); +cid=1 +pid=1 + +测试更新entry名称 >> name,这是应用名称1,这是应用名称2 +测试更新entry代号 >> code,code1,code2 +测试更新entry名称和代号 >> name,这是应用名称2,这是应用名称1;code,code2,code1 +测试不更新name >> 没有数据更新 + +*/ + +$entryID = 1; + +$e_upName = array('name' => '这是应用名称2'); +$e_upCode = array('code' => 'code2'); +$e_upNameAndCode = array('name' => '这是应用名称1', 'code' => 'code1'); +$e_unName = array('name' => '这是应用名称1'); + +$entry = new entryTest(); + +r($entry->updateObject($entryID, $e_upName)) && p('0:field,old,new') && e('name,这是应用名称1,这是应用名称2'); //测试更新entry名称 +r($entry->updateObject($entryID, $e_upCode)) && p('0:field,old,new') && e('code,code1,code2'); //测试更新entry代号 +r($entry->updateObject($entryID, $e_upNameAndCode)) && p('0:field,old,new;1:field,old,new') && e('name,这是应用名称2,这是应用名称1;code,code2,code1'); //测试更新entry名称和代号 +r($entry->updateObject($entryID, $e_unName)) && p() && e('没有数据更新'); //测试不更新name +system("./ztest init"); diff --git a/test/model/entry/updatecalltime.php b/test/model/entry/updatecalltime.php new file mode 100755 index 0000000000..42b9cc1ecd --- /dev/null +++ b/test/model/entry/updatecalltime.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +updateCalledTime(); +cid=1 +pid=1 + +测试更新entry代号存在的情况 >> 这是应用名称1 +测试更新entry代号不存在的情况 >> 0 + +*/ + +$code = array('code1','code2'); +$time = 2; + +$entry = new entryTest(); + +r($entry->updateCalledTimeTest($code[0], $time)) && p('name') && e('这是应用名称1'); //测试更新entry代号存在的情况 +r($entry->updateCalledTimeTest($code[1], $time)) && p() && e('0'); //测试更新entry代号不存在的情况 +system("./ztest init"); diff --git a/test/ztest b/test/ztest index 188e7995af..868edfaf13 100755 --- a/test/ztest +++ b/test/ztest @@ -49,6 +49,9 @@ switch($argv[1]) case 'design': ztfRun('model/design'); break; + case 'entry': + ztfRun('model/entry'); + break; case 'file': ztfRun('model/file'); break; @@ -64,9 +67,6 @@ switch($argv[1]) case 'kanban': ztfRun('model/kanban'); break; - case 'message': - ztfRun('model/message'); - break; case 'model': ztfRun('model'); break; @@ -100,8 +100,6 @@ switch($argv[1]) case 'report': ztfRun('model/report'); break; - case 'sso': - ztfRun('model/sso'); case 'setting': ztfRun('model/setting'); break; @@ -123,8 +121,8 @@ switch($argv[1]) case 'todo': ztfRun('model/todo'); break; - case 'tutorial': - ztfRun('model/tutorial'); + case 'message': + ztfRun('model/message'); break; case 'tree': ztfRun('model/tree'); From 93fc51fa9a48020afaced373ece1522fd1e61fb1 Mon Sep 17 00:00:00 2001 From: liyang <“liyang@easycorp.ltd”> Date: Sat, 7 May 2022 13:07:28 +0800 Subject: [PATCH 30/41] Update doc data --- test/data/doc.yaml | 2 +- test/data/doccontent.yaml | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test/data/doc.yaml b/test/data/doc.yaml index f35cad144e..5219381342 100644 --- a/test/data/doc.yaml +++ b/test/data/doc.yaml @@ -78,7 +78,7 @@ fields: format: "" - field: type note: "文档类型" - range: text,markdown + range: text,markdown,url prefix: "" postfix: "" loop: 0 diff --git a/test/data/doccontent.yaml b/test/data/doccontent.yaml index dd58eec311..0a9d65af62 100644 --- a/test/data/doccontent.yaml +++ b/test/data/doccontent.yaml @@ -33,8 +33,11 @@ fields: format: "" - field: content note: "文档正文" - range: 1-10000 - prefix: "文档正文" + fields: + - field: content1 + range: 文档正文,文档正文,www.baidu.com + - field: content2 + range: 1-2,[] postfix: "" loop: 0 format: "" @@ -47,7 +50,7 @@ fields: format: "" - field: type note: "文档类型" - range: text,markdown + range: text,markdown,html prefix: "" postfix: "" loop: 0 From d9a9b4c978e4aa9d915c418a1170747c40571e5f Mon Sep 17 00:00:00 2001 From: tianshujie Date: Sat, 7 May 2022 13:22:22 +0800 Subject: [PATCH 31/41] * Add a test case for the setting module. --- test/class/setting.class.php | 71 ++++++++++++++++++++++-- test/model/setting/deleteitems.php | 45 +++++++++++++++- test/model/setting/getitem.php | 73 ++++++++++++++++++++++++- test/model/setting/getitems.php | 73 ++++++++++++++++++++++++- test/model/setting/parseitemparam.php | 43 ++++++++++++++- test/model/setting/setitem.php | 60 ++++++++++++++++++++- test/model/setting/setitems.php | 78 ++++++++++++++++++++++++++- 7 files changed, 433 insertions(+), 10 deletions(-) diff --git a/test/class/setting.class.php b/test/class/setting.class.php index 7c6639ea28..a2b6576de4 100644 --- a/test/class/setting.class.php +++ b/test/class/setting.class.php @@ -7,15 +7,30 @@ class settingTest $this->objectModel = $tester->loadModel('setting'); } + /** + * Get value of an item. + * + * @param string $paramString see parseItemParam(); + * @access public + * @return misc + */ public function getItemTest($paramString) { $objects = $this->objectModel->getItem($paramString); if(dao::isError()) return dao::getError(); - return $objects; + if($objects or $objects === 0 or $objects === '0') return true; + return false; } + /** + * Get some items. + * + * @param string $paramString see parseItemParam(); + * @access public + * @return array + */ public function getItemsTest($paramString) { $objects = $this->objectModel->getItems($paramString); @@ -25,15 +40,48 @@ class settingTest return $objects; } + /** + * Set value of an item. + * + * @param string $path system.common.global.sn | system.common.sn | system.common.global.sn@rnd + * @param string $value + * @access public + * @return void + */ public function setItemTest($path, $value = '') { - $objects = $this->objectModel->setItem($path, $value = ''); + $this->objectModel->setItem($path, $value); if(dao::isError()) return dao::getError(); + /* Determine vision of config item. */ + $pathVision = explode('@', $path); + $vision = isset($pathVision[1]) ? $pathVision[1] : ''; + $path = $pathVision[0]; + $level = substr_count($path, '.'); + $section = ''; + + if($level <= 1) return false; + if($level == 2) list($owner, $module, $key) = explode('.', $path); + if($level == 3) list($owner, $module, $section, $key) = explode('.', $path); + $paramString = "vision=$vision&owner=$owner&module=$module§ion=$section&key=$key"; + $objects = $this->objectModel->getItem($paramString); + return $objects; } + /** + * Batch set items, the example: + * + * $path = 'system.mail'; + * $items->turnon = true; + * $items->smtp->host = 'localhost'; + * + * @param string $path like system.mail + * @param array|object $items the items array or object, can be mixed by one level or two levels. + * @access public + * @return bool + */ public function setItemsTest($path, $items) { $objects = $this->objectModel->setItems($path, $items); @@ -43,15 +91,30 @@ class settingTest return $objects; } + /** + * Delete items. + * + * @param string $paramString see parseItemParam(); + * @access public + * @return void + */ public function deleteItemsTest($paramString) { - $objects = $this->objectModel->deleteItems($paramString); + $this->objectModel->deleteItems($paramString); if(dao::isError()) return dao::getError(); - return $objects; + $object = $this->getItemTest($paramString); + return $object; } + /** + * Parse the param string for select or delete items. + * + * @param string $paramString owner=xxx&key=sn and so on. + * @access public + * @return array + */ public function parseItemParamTest($paramString) { $objects = $this->objectModel->parseItemParam($paramString); diff --git a/test/model/setting/deleteitems.php b/test/model/setting/deleteitems.php index f4e098ab30..bffcdaa3fe 100644 --- a/test/model/setting/deleteitems.php +++ b/test/model/setting/deleteitems.php @@ -10,8 +10,51 @@ title=测试 settingModel->deleteItems(); cid=1 pid=1 +删除键是version的common模块下的系统数据 >> 0 +删除键是hourPoint的common模块下的系统数据 >> 0 +删除键是mode的common模块下的系统数据 >> 0 +删除键是CRProduct的common模块下的系统数据 >> 0 +删除键是sn的common模块下的数据 >> 0 +删除键是CRExection的common模块下的数据 >> 0 +删除键是mode、附件条件是safe的数据 >> 0 +删除键是URSR的数据 >> 0 +删除模块是story的数据 >> 0 +删除附加条件是xuanxuan的数据 >> 0 +删除所有者是admin的数据 >> 0 +删除视图是rnd的数据 >> 0 +删除所有的数据 >> 0 + */ $setting = new settingTest(); -r($setting->deleteItemsTest()) && p() && e(); \ No newline at end of file +$params = array(); +$params[0] = "vision=rnd&owner=system&module=common§ion=global&key=version"; +$params[1] = "vision=rnd&owner=system&module=common&key=hourPoint"; +$params[2] = "owner=system&module=common§ion=global&key=mode"; +$params[3] = "owner=system&module=common&key=CRProduct"; +$params[4] = "module=common§ion=global&key=sn"; +$params[5] = "module=common&key=CRExection"; +$params[6] = "section=safe&key=mode"; +$params[7] = "key=URSR"; +$params[8] = "module=story"; +$params[9] = "section=xuanxuan"; +$params[10] = "owner=admin"; +$params[11] = "vision=rnd"; +$params[12] = ""; + +r($setting->deleteItemsTest($params[0])) && p() && e('0'); // 删除键是version的common模块下的系统数据 +r($setting->deleteItemsTest($params[1])) && p() && e('0'); // 删除键是hourPoint的common模块下的系统数据 +r($setting->deleteItemsTest($params[2])) && p() && e('0'); // 删除键是mode的common模块下的系统数据 +r($setting->deleteItemsTest($params[3])) && p() && e('0'); // 删除键是CRProduct的common模块下的系统数据 +r($setting->deleteItemsTest($params[4])) && p() && e('0'); // 删除键是sn的common模块下的数据 +r($setting->deleteItemsTest($params[5])) && p() && e('0'); // 删除键是CRExection的common模块下的数据 +r($setting->deleteItemsTest($params[6])) && p() && e('0'); // 删除键是mode、附件条件是safe的数据 +r($setting->deleteItemsTest($params[7])) && p() && e('0'); // 删除键是URSR的数据 +r($setting->deleteItemsTest($params[8])) && p() && e('0'); // 删除模块是story的数据 +r($setting->deleteItemsTest($params[9])) && p() && e('0'); // 删除附加条件是xuanxuan的数据 +r($setting->deleteItemsTest($params[10])) && p() && e('0'); // 删除所有者是admin的数据 +r($setting->deleteItemsTest($params[11])) && p() && e('0'); // 删除视图是rnd的数据 +r($setting->deleteItemsTest($params[12])) && p() && e('0'); // 删除所有的数据 + +system("./ztest init"); diff --git a/test/model/setting/getitem.php b/test/model/setting/getitem.php index 5f225edb7e..02b4bd84e7 100644 --- a/test/model/setting/getitem.php +++ b/test/model/setting/getitem.php @@ -10,8 +10,79 @@ title=测试 settingModel->getItem(); cid=1 pid=1 +查询所有数据的第一条 >> 1 +查询所有者是系统的第一条数据 >> 1 +查询所有者是系统的第一条数据 >> 1 +查询所属模块是custom的第一条数据 >> 1 +查询附加条件是global的第一条数据 >> 1 +查询值是CRProduct的第一条数据 >> 1 +查询研发界面中所有者是系统的第一条数据 >> 1 +查询研发界面中所属模块是custom的第一条数据 >> 1 +查询研发界面中附加条件是global的第一条数据 >> 1 +查询研发界面中值是CRProduct的第一条数据 >> 1 +查询所有者是系统并且所属模块是custom的第一条数据 >> 1 +查询所有者是系统并且附加条件是global的第一条数据 >> 1 +查询所有者是系统并且值是CRProduct的第一条数据 >> 1 +查询所有者是系统并且所属模块是common、附加条件是global的第一条数据 >> 1 +查询所有者是系统并且所属模块是common、值是CRProduct的第一条数据 >> 1 +查询所有者是系统并且所属模块是common、附加条件是global、值是version的第一条数据 >> 1 +查询所有者是admin并且所属模块是common、值是URSR的第一条数据 >> 1 +查询所有者是admin并且所属模块是common、附加条件是block、值是initVersion的第一条数据 >> 1 +查询不存在的界面配置 >> 0 +查询不存在的所有者配置 >> 0 +查询不存在的模块配置 >> 0 +查询不存在的附加条件配置 >> 0 +查询不存在的值配置 >> 0 + */ $setting = new settingTest(); -r($setting->getItemTest()) && p() && e(); \ No newline at end of file +$items = array(); +$items[0] = ""; +$items[1] = "vision=rnd"; +$items[2] = "owner=system"; +$items[3] = "module=custom"; +$items[4] = "section=global"; +$items[5] = "key=CRProduct"; +$items[6] = "vision=rnd&owner=system"; +$items[7] = "vision=rnd&module=custom"; +$items[8] = "vision=rnd§ion=global"; +$items[9] = "vision=rnd&key=CRProduct"; +$items[10] = "owner=system&module=custom"; +$items[11] = "owner=system§ion=global"; +$items[12] = "owner=system&key=CRProduct"; +$items[13] = "owner=system&module=common§ion=global"; +$items[14] = "owner=system&module=common&key=CRExecution"; +$items[15] = "owner=system&module=common§ion=global&key=version"; +$items[16] = "owner=admin&module=common&key=URSR"; +$items[17] = "owner=admin&module=my§ion=block&key=initVersion"; +$items[18] = "vision=test"; +$items[19] = "owner=test"; +$items[20] = "module=test"; +$items[21] = "section=test"; +$items[22] = "key=test"; + +r($setting->getItemTest($items[0])) && p() && e('1'); // 查询所有数据的第一条 +r($setting->getItemTest($items[1])) && p() && e('1'); // 查询所有者是系统的第一条数据 +r($setting->getItemTest($items[2])) && p() && e('1'); // 查询所有者是系统的第一条数据 +r($setting->getItemTest($items[3])) && p() && e('1'); // 查询所属模块是custom的第一条数据 +r($setting->getItemTest($items[4])) && p() && e('1'); // 查询附加条件是global的第一条数据 +r($setting->getItemTest($items[5])) && p() && e('1'); // 查询值是CRProduct的第一条数据 +r($setting->getItemTest($items[6])) && p() && e('1'); // 查询研发界面中所有者是系统的第一条数据 +r($setting->getItemTest($items[7])) && p() && e('1'); // 查询研发界面中所属模块是custom的第一条数据 +r($setting->getItemTest($items[8])) && p() && e('1'); // 查询研发界面中附加条件是global的第一条数据 +r($setting->getItemTest($items[9])) && p() && e('1'); // 查询研发界面中值是CRProduct的第一条数据 +r($setting->getItemTest($items[10])) && p() && e('1'); // 查询所有者是系统并且所属模块是custom的第一条数据 +r($setting->getItemTest($items[11])) && p() && e('1'); // 查询所有者是系统并且附加条件是global的第一条数据 +r($setting->getItemTest($items[12])) && p() && e('1'); // 查询所有者是系统并且值是CRProduct的第一条数据 +r($setting->getItemTest($items[13])) && p() && e('1'); // 查询所有者是系统并且所属模块是common、附加条件是global的第一条数据 +r($setting->getItemTest($items[14])) && p() && e('1'); // 查询所有者是系统并且所属模块是common、值是CRProduct的第一条数据 +r($setting->getItemTest($items[15])) && p() && e('1'); // 查询所有者是系统并且所属模块是common、附加条件是global、值是version的第一条数据 +r($setting->getItemTest($items[16])) && p() && e('1'); // 查询所有者是admin并且所属模块是common、值是URSR的第一条数据 +r($setting->getItemTest($items[17])) && p() && e('1'); // 查询所有者是admin并且所属模块是my、附加条件是block、值是initVersion的第一条数据 +r($setting->getItemTest($items[18])) && p() && e('0'); // 查询不存在的界面配置 +r($setting->getItemTest($items[19])) && p() && e('0'); // 查询不存在的所有者配置 +r($setting->getItemTest($items[20])) && p() && e('0'); // 查询不存在的模块配置 +r($setting->getItemTest($items[21])) && p() && e('0'); // 查询不存在的附加条件配置 +r($setting->getItemTest($items[22])) && p() && e('0'); // 查询不存在的值配置 diff --git a/test/model/setting/getitems.php b/test/model/setting/getitems.php index 26a599d319..a9850988c5 100644 --- a/test/model/setting/getitems.php +++ b/test/model/setting/getitems.php @@ -10,8 +10,79 @@ title=测试 settingModel->getItems(); cid=1 pid=1 +查询所有数据中的第一条数据 >> 0 +查询所有者是系统的第一条数据 >> 0 +查询所有者是系统的第一条数据 >> 0 +查询所属模块是custom的第一条数据 >> 0 +查询附加条件是global的第一条数据 >> new +查询值是CRProduct的第一条数据 >> 1 +查询研发界面中所有者是系统的第一条数据 >> 1 +查询研发界面中所属模块是custom的第一条数据 >> 0 +查询研发界面中附加条件是global的第一条数据 >> new +查询研发界面中值是CRProduct的第一条数据 >> 1 +查询所有者是系统并且所属模块是custom的第一条数据 >> 0 +查询所有者是系统并且附加条件是global的第一条数据 >> new +查询所有者是系统并且值是CRProduct的第一条数据 >> 1 +查询所有者是系统并且所属模块是common、附加条件是global的第一条数据 >> new +查询所有者是系统并且所属模块是common、值是CRProduct的第一条数据 >> 1 +查询所有者是系统并且所属模块是common、附加条件是global、值是version的第一条数据 >> 16.5 +查询所有者是admin并且所属模块是common、值是URSR的第一条数据 >> 2 +查询所有者是admin并且所属模块是my、附加条件是block、值是initVersion的第一条数据 >> 2 +查询不存在的界面配置 >> 0 +查询不存在的所有者配置 >> 0 +查询不存在的模块配置 >> 0 +查询不存在的附加条件配置 >> 0 +查询不存在的值配置 >> 0 + */ $setting = new settingTest(); -r($setting->getItemsTest()) && p() && e(); \ No newline at end of file +$items = array(); +$items[0] = ""; +$items[1] = "vision=rnd"; +$items[2] = "owner=system"; +$items[3] = "module=custom"; +$items[4] = "section=global"; +$items[5] = "key=CRProduct"; +$items[6] = "vision=rnd&owner=system"; +$items[7] = "vision=rnd&module=custom"; +$items[8] = "vision=rnd§ion=global"; +$items[9] = "vision=rnd&key=CRProduct"; +$items[10] = "owner=system&module=custom"; +$items[11] = "owner=system§ion=global"; +$items[12] = "owner=system&key=CRProduct"; +$items[13] = "owner=system&module=common§ion=global"; +$items[14] = "owner=system&module=common&key=CRExecution"; +$items[15] = "owner=system&module=common§ion=global&key=version"; +$items[16] = "owner=admin&module=common&key=URSR"; +$items[17] = "owner=admin&module=my§ion=block&key=initVersion"; +$items[18] = "vision=test"; +$items[19] = "owner=test"; +$items[20] = "module=test"; +$items[21] = "section=test"; +$items[22] = "key=test"; + +r($setting->getItemsTest($items[0])) && p('1:value') && e('0'); // 查询所有数据中的第一条数据 +r($setting->getItemsTest($items[1])) && p('1:value') && e('0'); // 查询所有者是系统的第一条数据 +r($setting->getItemsTest($items[2])) && p('1:value') && e('0'); // 查询所有者是系统的第一条数据 +r($setting->getItemsTest($items[3])) && p('1:value') && e('0'); // 查询所属模块是custom的第一条数据 +r($setting->getItemsTest($items[4])) && p('9:value') && e('new'); // 查询附加条件是global的第一条数据 +r($setting->getItemsTest($items[5])) && p('2:value') && e('1'); // 查询值是CRProduct的第一条数据 +r($setting->getItemsTest($items[6])) && p('3:value') && e('1'); // 查询研发界面中所有者是系统的第一条数据 +r($setting->getItemsTest($items[7])) && p('1:value') && e('0'); // 查询研发界面中所属模块是custom的第一条数据 +r($setting->getItemsTest($items[8])) && p('9:value') && e('new'); // 查询研发界面中附加条件是global的第一条数据 +r($setting->getItemsTest($items[9])) && p('2:value') && e('1'); // 查询研发界面中值是CRProduct的第一条数据 +r($setting->getItemsTest($items[10])) && p('1:value') && e('0'); // 查询所有者是系统并且所属模块是custom的第一条数据 +r($setting->getItemsTest($items[11])) && p('9:value') && e('new'); // 查询所有者是系统并且附加条件是global的第一条数据 +r($setting->getItemsTest($items[12])) && p('2:value') && e('1'); // 查询所有者是系统并且值是CRProduct的第一条数据 +r($setting->getItemsTest($items[13])) && p('9:value') && e('new'); // 查询所有者是系统并且所属模块是common、附加条件是global的第一条数据 +r($setting->getItemsTest($items[14])) && p('3:value') && e('1'); // 查询所有者是系统并且所属模块是common、值是CRProduct的第一条数据 +r($setting->getItemsTest($items[15])) && p('10:value') && e('16.5'); // 查询所有者是系统并且所属模块是common、附加条件是global、值是version的第一条数据 +r($setting->getItemsTest($items[16])) && p('25:value') && e('2'); // 查询所有者是admin并且所属模块是common、值是URSR的第一条数据 +r($setting->getItemsTest($items[17])) && p('32:value') && e('2'); // 查询所有者是admin并且所属模块是my、附加条件是block、值是initVersion的第一条数据 +r($setting->getItemsTest($items[18])) && p() && e('0'); // 查询不存在的界面配置 +r($setting->getItemsTest($items[19])) && p() && e('0'); // 查询不存在的所有者配置 +r($setting->getItemsTest($items[20])) && p() && e('0'); // 查询不存在的模块配置 +r($setting->getItemsTest($items[21])) && p() && e('0'); // 查询不存在的附加条件配置 +r($setting->getItemsTest($items[22])) && p() && e('0'); // 查询不存在的值配置 diff --git a/test/model/setting/parseitemparam.php b/test/model/setting/parseitemparam.php index a121884eb0..d38369bf72 100644 --- a/test/model/setting/parseitemparam.php +++ b/test/model/setting/parseitemparam.php @@ -10,8 +10,49 @@ title=测试 settingModel->parseItemParam(); cid=1 pid=1 +解析参数包含vision、owner、module、section、key的数据 >> rnd,system,common,global,version +解析参数包含vision、owner、module、key的数据 >> rnd,system,common,,hourPoint +解析参数包含owner、module、section、key的数据 >> ,system,common,global,mode +解析参数包含owner、module、key的数据 >> ,system,common,,CRProduct +解析参数包含module、section、key的数据 >> ,,common,global,sn +解析参数包含module、key的数据 >> ,,common,,CRExection +解析参数包含section、key的数据 >> ,,,safe,mode +解析参数包含key的数据 >> ,,,,URSR +解析参数包含module的数据 >> ,,story,, +解析参数包含section的数据 >> ,,,xuanxuan, +解析参数包含owner的数据 >> ,admin,,, +解析参数包含vision的数据 >> rnd,,,, +解析空数据 >> ,,,, + */ $setting = new settingTest(); -r($setting->parseItemParamTest()) && p() && e(); \ No newline at end of file +$params = array(); +$params[0] = "vision=rnd&owner=system&module=common§ion=global&key=version"; +$params[1] = "vision=rnd&owner=system&module=common&key=hourPoint"; +$params[2] = "owner=system&module=common§ion=global&key=mode"; +$params[3] = "owner=system&module=common&key=CRProduct"; +$params[4] = "module=common§ion=global&key=sn"; +$params[5] = "module=common&key=CRExection"; +$params[6] = "section=safe&key=mode"; +$params[7] = "key=URSR"; +$params[8] = "module=story"; +$params[9] = "section=xuanxuan"; +$params[10] = "owner=admin"; +$params[11] = "vision=rnd"; +$params[12] = ""; + +r($setting->parseItemParamTest($params[0])) && p('vision,owner,module,section,key') && e('rnd,system,common,global,version'); // 解析参数包含vision、owner、module、section、key的数据 +r($setting->parseItemParamTest($params[1])) && p('vision,owner,module,section,key') && e('rnd,system,common,,hourPoint'); // 解析参数包含vision、owner、module、key的数据 +r($setting->parseItemParamTest($params[2])) && p('vision,owner,module,section,key') && e(',system,common,global,mode'); // 解析参数包含owner、module、section、key的数据 +r($setting->parseItemParamTest($params[3])) && p('vision,owner,module,section,key') && e(',system,common,,CRProduct'); // 解析参数包含owner、module、key的数据 +r($setting->parseItemParamTest($params[4])) && p('vision,owner,module,section,key') && e(',,common,global,sn'); // 解析参数包含module、section、key的数据 +r($setting->parseItemParamTest($params[5])) && p('vision,owner,module,section,key') && e(',,common,,CRExection'); // 解析参数包含module、key的数据 +r($setting->parseItemParamTest($params[6])) && p('vision,owner,module,section,key') && e(',,,safe,mode'); // 解析参数包含section、key的数据 +r($setting->parseItemParamTest($params[7])) && p('vision,owner,module,section,key') && e(',,,,URSR'); // 解析参数包含key的数据 +r($setting->parseItemParamTest($params[8])) && p('vision,owner,module,section,key') && e(',,story,,'); // 解析参数包含module的数据 +r($setting->parseitemparamtest($params[9])) && p('vision,owner,module,section,key') && e(',,,xuanxuan,'); // 解析参数包含section的数据 +r($setting->parseitemparamtest($params[10])) && p('vision,owner,module,section,key') && e(',admin,,,'); // 解析参数包含owner的数据 +r($setting->parseitemparamtest($params[11])) && p('vision,owner,module,section,key') && e('rnd,,,,'); // 解析参数包含vision的数据 +r($setting->parseitemparamtest($params[12])) && p('vision,owner,module,section,key') && e(',,,,'); // 解析空数据 diff --git a/test/model/setting/setitem.php b/test/model/setting/setitem.php index 698edea9f0..4109182225 100644 --- a/test/model/setting/setitem.php +++ b/test/model/setting/setitem.php @@ -10,8 +10,66 @@ title=测试 settingModel->setItem(); cid=1 pid=1 +设置没有vision的空数据 >> 0 +设置没有vision的只有视图的数据 >> 0 +设置没有vision的所有者是system的数据 >> 0 +设置没有vision的my模块的系统数据 >> 0 +设置没有vision的project模块的系统数据 >> test4 +设置没有vision的product模块的系统数据 >> test5 +设置没有vision的所有者是admin的数据 >> 0 +设置没有vision的common模块的admin配置数据 >> 0 +设置没有vision的project模块的admin配置数据 >> test8 +设置没有vision的product模块的admin配置数据 >> test9 +设置有vision的所有者是system的数据 >> 0 +设置有vision的my模块的系统数据 >> 0 +设置有vision的project模块的系统数据 >> test12 +设置有vision的product模块的系统数据 >> test13 +设置有vision的所有者是admin的数据 >> 0 +设置有vision的common模块的admin配置数据 >> 0 +设置有vision的project模块的admin配置数据 >> test16 +设置有vision的product模块的admin配置数据 >> test17 + */ $setting = new settingTest(); -r($setting->setItemTest()) && p() && e(); \ No newline at end of file +$pathList = array(); +$pathList[0] = ""; +$pathList[1] = "@rnd"; +$pathList[2] = "system"; +$pathList[3] = "system.my"; +$pathList[4] = "system.project.list"; +$pathList[5] = "system.product.global.story"; +$pathList[6] = "admin"; +$pathList[7] = "admin.common"; +$pathList[8] = "admin.project.list"; +$pathList[9] = "admin.product.global.story"; +$pathList[10] = "system@rnd"; +$pathList[11] = "system.my@rnd"; +$pathList[12] = "system.project.list@rnd"; +$pathList[13] = "system.product.global.story@rnd"; +$pathList[14] = "admin@rnd"; +$pathList[15] = "admin.common@rnd"; +$pathList[16] = "admin.project.list@rnd"; +$pathList[17] = "admin.product.global.story@rnd"; + +r($setting->setItemTest($pathList[0], 'test0')) && p() && e('0'); // 设置没有vision的空数据 +r($setting->setItemTest($pathList[1], 'test1')) && p() && e('0'); // 设置没有vision的只有视图的数据 +r($setting->setItemTest($pathList[2], 'test2')) && p() && e('0'); // 设置没有vision的所有者是system的数据 +r($setting->setItemTest($pathList[3], 'test3')) && p() && e('0'); // 设置没有vision的my模块的系统数据 +r($setting->setItemTest($pathList[4], 'test4')) && p() && e('test4'); // 设置没有vision的project模块的系统数据 +r($setting->setItemTest($pathList[5], 'test5')) && p() && e('test5'); // 设置没有vision的product模块的系统数据 +r($setting->setItemTest($pathList[6], 'test6')) && p() && e('0'); // 设置没有vision的所有者是admin的数据 +r($setting->setItemTest($pathList[7], 'test7')) && p() && e('0'); // 设置没有vision的common模块的admin配置数据 +r($setting->setItemTest($pathList[8], 'test8')) && p() && e('test8'); // 设置没有vision的project模块的admin配置数据 +r($setting->setItemTest($pathList[9], 'test9')) && p() && e('test9'); // 设置没有vision的product模块的admin配置数据 +r($setting->setItemTest($pathList[10], 'test10')) && p() && e('0'); // 设置有vision的所有者是system的数据 +r($setting->setItemTest($pathList[11], 'test11')) && p() && e('0'); // 设置有vision的my模块的系统数据 +r($setting->setItemTest($pathList[12], 'test12')) && p() && e('test12'); // 设置有vision的project模块的系统数据 +r($setting->setItemTest($pathList[13], 'test13')) && p() && e('test13'); // 设置有vision的product模块的系统数据 +r($setting->setItemTest($pathList[14], 'test14')) && p() && e('0'); // 设置有vision的所有者是admin的数据 +r($setting->setItemTest($pathList[15], 'test15')) && p() && e('0'); // 设置有vision的common模块的admin配置数据 +r($setting->setItemTest($pathList[16], 'test16')) && p() && e('test16'); // 设置有vision的project模块的admin配置数据 +r($setting->setItemTest($pathList[17], 'test17')) && p() && e('test17'); // 设置有vision的product模块的admin配置数据 + +system("./ztest init"); diff --git a/test/model/setting/setitems.php b/test/model/setting/setitems.php index 90161bb8d3..ef4c662e38 100644 --- a/test/model/setting/setitems.php +++ b/test/model/setting/setitems.php @@ -10,8 +10,84 @@ title=测试 settingModel->setItems(); cid=1 pid=1 +创建空数据 >> 1 +创建没有vision,只有视图且值为空的数据 >> 1 +创建没有vision,只有所有者且值为空的数据 >> 1 +创建没有vision,my模块且值为空的数据 >> 1 +创建没有vision,只有所有者且值为空的数据 >> 1 +创建没有vision,common模块且值为空的数据 >> 1 +创建有vision,只有所有者且值为空的数据 >> 1 +创建有vision,my模块且值为空的数据 >> 1 +创建有vision,只有所有者且值为空的数据 >> 1 +创建有vision,common模块且值为空的数据 >> 1 +创建没有vision,只有视图且值project的数据 >> 1 +创建没有vision,只有所有者且值为project的数据 >> 1 +创建没有vision,my模块且值为project的数据 >> 1 +创建没有vision,只有所有者且值为project的数据 >> 1 +创建没有vision,common模块且值为project的数据 >> 1 +创建有vision,只有所有者且值为project的数据 >> 1 +创建有vision,my模块且值为project的数据 >> 1 +创建有vision,只有所有者且值为project的数据 >> 1 +创建有vision,common模块且值为project的数据 >> 1 +创建没有vision,只有视图且值project和story的数据 >> 1 +创建没有vision,只有所有者且值为project和story的数据 >> 1 +创建没有vision,my模块且值为project和story的数据 >> 1 +创建没有vision,只有所有者且值为project和story的数据 >> 1 +创建没有vision,common模块且值为project和story的数据 >> 1 +创建有vision,只有所有者且值为project和story的数据 >> 1 +创建有vision,my模块且值为project和story的数据 >> 1 +创建有vision,只有所有者且值为project和story的数据 >> 1 +创建有vision,common模块且值为project和story的数据 >> 1 + */ $setting = new settingTest(); -r($setting->setItemsTest()) && p() && e(); \ No newline at end of file +$pathList = array(); +$pathList[0] = ""; +$pathList[1] = "@rnd"; +$pathList[2] = "system"; +$pathList[3] = "system.my"; +$pathList[4] = "admin"; +$pathList[5] = "admin.common"; +$pathList[6] = "system@rnd"; +$pathList[7] = "system.my@rnd"; +$pathList[8] = "admin@rnd"; +$pathList[9] = "admin.common@rnd"; + +$items = new stdclass(); +r($setting->setItemsTest($pathList[0], $items)) && p() && e('1'); // 创建空数据 +r($setting->setItemsTest($pathList[1], $items)) && p() && e('1'); // 创建没有vision,只有视图且值为空的数据 +r($setting->setItemsTest($pathList[2], $items)) && p() && e('1'); // 创建没有vision,只有所有者且值为空的数据 +r($setting->setItemsTest($pathList[3], $items)) && p() && e('1'); // 创建没有vision,my模块且值为空的数据 +r($setting->setItemsTest($pathList[4], $items)) && p() && e('1'); // 创建没有vision,只有所有者且值为空的数据 +r($setting->setItemsTest($pathList[5], $items)) && p() && e('1'); // 创建没有vision,common模块且值为空的数据 +r($setting->setItemsTest($pathList[6], $items)) && p() && e('1'); // 创建有vision,只有所有者且值为空的数据 +r($setting->setItemsTest($pathList[7], $items)) && p() && e('1'); // 创建有vision,my模块且值为空的数据 +r($setting->setItemsTest($pathList[8], $items)) && p() && e('1'); // 创建有vision,只有所有者且值为空的数据 +r($setting->setItemsTest($pathList[9], $items)) && p() && e('1'); // 创建有vision,common模块且值为空的数据 + +$items->projectList = 'project'; +r($setting->setItemsTest($pathList[1], $items)) && p() && e('1'); // 创建没有vision,只有视图且值project的数据 +r($setting->setItemsTest($pathList[2], $items)) && p() && e('1'); // 创建没有vision,只有所有者且值为project的数据 +r($setting->setItemsTest($pathList[3], $items)) && p() && e('1'); // 创建没有vision,my模块且值为project的数据 +r($setting->setItemsTest($pathList[4], $items)) && p() && e('1'); // 创建没有vision,只有所有者且值为project的数据 +r($setting->setItemsTest($pathList[5], $items)) && p() && e('1'); // 创建没有vision,common模块且值为project的数据 +r($setting->setItemsTest($pathList[6], $items)) && p() && e('1'); // 创建有vision,只有所有者且值为project的数据 +r($setting->setItemsTest($pathList[7], $items)) && p() && e('1'); // 创建有vision,my模块且值为project的数据 +r($setting->setItemsTest($pathList[8], $items)) && p() && e('1'); // 创建有vision,只有所有者且值为project的数据 +r($setting->setItemsTest($pathList[9], $items)) && p() && e('1'); // 创建有vision,common模块且值为project的数据 + +$items->global = new stdclass(); +$items->global->productList = 'story'; +r($setting->setItemsTest($pathList[1], $items)) && p() && e('1'); // 创建没有vision,只有视图且值project和story的数据 +r($setting->setItemsTest($pathList[2], $items)) && p() && e('1'); // 创建没有vision,只有所有者且值为project和story的数据 +r($setting->setItemsTest($pathList[3], $items)) && p() && e('1'); // 创建没有vision,my模块且值为project和story的数据 +r($setting->setItemsTest($pathList[4], $items)) && p() && e('1'); // 创建没有vision,只有所有者且值为project和story的数据 +r($setting->setItemsTest($pathList[5], $items)) && p() && e('1'); // 创建没有vision,common模块且值为project和story的数据 +r($setting->setItemsTest($pathList[6], $items)) && p() && e('1'); // 创建有vision,只有所有者且值为project和story的数据 +r($setting->setItemsTest($pathList[7], $items)) && p() && e('1'); // 创建有vision,my模块且值为project和story的数据 +r($setting->setItemsTest($pathList[8], $items)) && p() && e('1'); // 创建有vision,只有所有者且值为project和story的数据 +r($setting->setItemsTest($pathList[9], $items)) && p() && e('1'); // 创建有vision,common模块且值为project和story的数据 + +system("./ztest init"); From 5d4ffe230a732de5610c1b8304648a1a3f47d4af Mon Sep 17 00:00:00 2001 From: tianshujie Date: Sat, 7 May 2022 13:28:29 +0800 Subject: [PATCH 32/41] * Edit comments. --- test/class/setting.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/class/setting.class.php b/test/class/setting.class.php index a2b6576de4..b87b6ebaaf 100644 --- a/test/class/setting.class.php +++ b/test/class/setting.class.php @@ -12,7 +12,7 @@ class settingTest * * @param string $paramString see parseItemParam(); * @access public - * @return misc + * @return bool */ public function getItemTest($paramString) { @@ -29,7 +29,7 @@ class settingTest * * @param string $paramString see parseItemParam(); * @access public - * @return array + * @return array|string */ public function getItemsTest($paramString) { @@ -46,7 +46,7 @@ class settingTest * @param string $path system.common.global.sn | system.common.sn | system.common.global.sn@rnd * @param string $value * @access public - * @return void + * @return misc */ public function setItemTest($path, $value = '') { @@ -80,15 +80,15 @@ class settingTest * @param string $path like system.mail * @param array|object $items the items array or object, can be mixed by one level or two levels. * @access public - * @return bool + * @return bool|string */ public function setItemsTest($path, $items) { - $objects = $this->objectModel->setItems($path, $items); + $result = $this->objectModel->setItems($path, $items); if(dao::isError()) return dao::getError(); - return $objects; + return $result; } /** @@ -96,7 +96,7 @@ class settingTest * * @param string $paramString see parseItemParam(); * @access public - * @return void + * @return misc */ public function deleteItemsTest($paramString) { From 02a9f4831b96ff72440339a2ec6e6c10d90303a1 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Sat, 7 May 2022 13:44:57 +0800 Subject: [PATCH 33/41] * Add unit test of doc. --- test/class/doc.class.php | 81 +++++++++++++++++++++++++-- test/model/doc/getdoctree.php | 11 +++- test/model/doc/getfileicon.php | 10 +++- test/model/doc/getfilesourcepairs.php | 10 +++- test/model/doc/getlibfiles.php | 17 +++++- test/model/doc/statlibcounts.php | 8 ++- 6 files changed, 126 insertions(+), 11 deletions(-) diff --git a/test/class/doc.class.php b/test/class/doc.class.php index 143e7413aa..d783a52374 100644 --- a/test/class/doc.class.php +++ b/test/class/doc.class.php @@ -298,6 +298,13 @@ class docTest return $objects; } + /** + * Test stat module and document counts of lib. + * + * @param array $idList + * @access public + * @return array + */ public function statLibCountsTest($idList) { $objects = $this->objectModel->statLibCounts($idList); @@ -307,40 +314,102 @@ class docTest return $objects; } + /** + * Test get lib files. + * + * @param string $type + * @param int $objectID + * @param string $orderBy + * @param object $pager + * @access public + * @return string + */ public function getLibFilesTest($type, $objectID, $orderBy, $pager = null) { $objects = $this->objectModel->getLibFiles($type, $objectID, $orderBy, $pager = null); if(dao::isError()) return dao::getError(); - return $objects; + $titles = ''; + foreach($objects as $object) + { + $titles .= "$object->title,"; + } + $titles = trim($titles, ','); + return $titles; } - public function getFileSourcePairsTest($files) + /** + * Test get file source pairs. + * + * @param array $files + * @access public + * @return void + */ + public function getFileSourcePairsTest($type, $objectID) { + $files = $this->objectModel->getLibFiles($type, $objectID, 't1.id_desc', $pager = null); + $objects = $this->objectModel->getFileSourcePairs($files); if(dao::isError()) return dao::getError(); - return $objects; + $counts = ''; + foreach($objects as $type => $items) + { + $counts .= "$type:" . count($items) .';'; + } + return $counts; } - public function getFileIconTest($files) + /** + * Test get file icon. + * + * @param string $type + * @param int $objectID + * @access public + * @return string + */ + public function getFileIconTest($type, $objectID) { + $files = $this->objectModel->getLibFiles($type, $objectID, 't1.id_desc', $pager = null); + $objects = $this->objectModel->getFileIcon($files); if(dao::isError()) return dao::getError(); - return $objects; + $icons = ''; + foreach($objects as $object) + { + preg_match("/icon-[^']*/", $object, $matches); + $icons .= "$matches[0] "; + } + $icons = trim($icons); + return $icons; } + /** + * Test get doc tree. + * + * @param int $libID + * @access public + * @return string + */ public function getDocTreeTest($libID) { $objects = $this->objectModel->getDocTree($libID); if(dao::isError()) return dao::getError(); - return $objects; + $names = ''; + foreach($objects as $object) + { + $names .= "$object->name:"; + foreach($object->children as $children) $names .= (isset($children->name) ? $children->name : $children->title) . ","; + $names = trim($names, ','); + $names .= ";"; + } + return $names; } public function fillDocsInTreeTest($node, $libID) diff --git a/test/model/doc/getdoctree.php b/test/model/doc/getdoctree.php index 247c9b34ec..8970f6e87c 100644 --- a/test/model/doc/getdoctree.php +++ b/test/model/doc/getdoctree.php @@ -14,6 +14,15 @@ pid=1 */ +$libID = array(1, 3, 8, 20, 101, 191, 821, 901); + $doc = new docTest(); -r($doc->getDocTreeTest()) && p() && e(); \ No newline at end of file +r($doc->getDocTreeTest($libID[0])) && p() && e('目录1:文档标题1,子目录1,子目录2;'); // 获取libID 1 的文档树 +r($doc->getDocTreeTest($libID[1])) && p() && e('目录3:子目录5,子目录6;'); // 获取libID 3 的文档树 +r($doc->getDocTreeTest($libID[2])) && p() && e('目录8:子目录15,子目录16;'); // 获取libID 8 的文档树 +r($doc->getDocTreeTest($libID[3])) && p() && e('目录20:子目录39,子目录40;'); // 获取libID 20 的文档树 +r($doc->getDocTreeTest($libID[4])) && p() && e('0'); // 获取libID 101 的文档树 +r($doc->getDocTreeTest($libID[5])) && p() && e('0'); // 获取libID 191 的文档树 +r($doc->getDocTreeTest($libID[6])) && p() && e('0'); // 获取libID 821 的文档树 +r($doc->getDocTreeTest($libID[7])) && p() && e('0'); // 获取libID 901 的文档树 diff --git a/test/model/doc/getfileicon.php b/test/model/doc/getfileicon.php index 7dc8bf3819..0d1e57c4e1 100644 --- a/test/model/doc/getfileicon.php +++ b/test/model/doc/getfileicon.php @@ -14,6 +14,14 @@ pid=1 */ +$type = array('product', 'project', 'execution'); +$objectID = array(1, 2, 11, 12, 101, 102); + $doc = new docTest(); -r($doc->getFileIconTest()) && p() && e(); \ No newline at end of file +r($doc->getFileIconTest($type[0], $objectID[0])) && p() && e('icon-file icon-file-word icon-file-word'); // 测试获取 产品 1 的文件icon +r($doc->getFileIconTest($type[0], $objectID[1])) && p() && e('0'); // 测试获取 产品 2 的文件icon +r($doc->getFileIconTest($type[1], $objectID[2])) && p() && e('icon-file-word icon-file-word icon-file-text'); // 测试获取 项目 11 的文件icon +r($doc->getFileIconTest($type[1], $objectID[3])) && p() && e('0'); // 测试获取 项目 12 的文件icon +r($doc->getFileIconTest($type[2], $objectID[4])) && p() && e('icon-file icon-file-word icon-file-text'); // 测试获取 执行 101 的文件icon +r($doc->getFileIconTest($type[2], $objectID[5])) && p() && e('0'); // 测试获取 执行 102 的文件icon diff --git a/test/model/doc/getfilesourcepairs.php b/test/model/doc/getfilesourcepairs.php index f4f4279d42..00420411d1 100644 --- a/test/model/doc/getfilesourcepairs.php +++ b/test/model/doc/getfilesourcepairs.php @@ -14,6 +14,14 @@ pid=1 */ +$type = array('product', 'project', 'execution'); +$objectID = array(1, 2, 11, 12, 101, 102); + $doc = new docTest(); -r($doc->getFileSourcePairsTest()) && p() && e(); \ No newline at end of file +r($doc->getFileSourcePairsTest($type[0], $objectID[0])) && p() && e('testcase:1;story:1;bug:1;'); // 测试获取 产品 1 的文件类型分组 +r($doc->getFileSourcePairsTest($type[0], $objectID[1])) && p() && e('0'); // 测试获取 产品 2 的文件类型分组 +r($doc->getFileSourcePairsTest($type[1], $objectID[2])) && p() && e('task:2;bug:1;'); // 测试获取 项目 11 的文件类型分组 +r($doc->getFileSourcePairsTest($type[1], $objectID[3])) && p() && e('0'); // 测试获取 项目 12 的文件类型分组 +r($doc->getFileSourcePairsTest($type[2], $objectID[4])) && p() && e('testcase:1;bug:1;task:1;'); // 测试获取 执行 101 的文件类型分组 +r($doc->getFileSourcePairsTest($type[2], $objectID[5])) && p() && e('0'); // 测试获取 执行 102 的文件类型分组 diff --git a/test/model/doc/getlibfiles.php b/test/model/doc/getlibfiles.php index 9c9b825e20..10fc9adacd 100644 --- a/test/model/doc/getlibfiles.php +++ b/test/model/doc/getlibfiles.php @@ -14,6 +14,21 @@ pid=1 */ +$type = array('product', 'project', 'execution'); +$objectID = array(1, 2, 11, 12, 101, 102); +$orderBy = array('t1.id_desc', 't1.id_asc'); + $doc = new docTest(); -r($doc->getLibFilesTest()) && p() && e(); \ No newline at end of file +r($doc->getLibFilesTest($type[0], $objectID[0], $orderBy[0])) && p() && e('这是一个文件名称4.dot,这是一个文件名称3.docx,这是一个文件名称2.doc'); // 获取 产品 1 下文件库id倒序排列的文件 +r($doc->getLibFilesTest($type[0], $objectID[1], $orderBy[0])) && p() && e('0'); // 获取 产品 2 下文件库id倒序排列的文件 +r($doc->getLibFilesTest($type[1], $objectID[2], $orderBy[0])) && p() && e('这是一个文件名称91.docx,这是一个文件名称2.doc,这是一个文件名称1.txt'); // 获取 项目 11 下文件库id倒序排列的文件 +r($doc->getLibFilesTest($type[1], $objectID[3], $orderBy[0])) && p() && e('0'); // 获取 项目 12 下文件库id倒序排列的文件 +r($doc->getLibFilesTest($type[2], $objectID[4], $orderBy[0])) && p() && e('这是一个文件名称4.dot,这是一个文件名称2.doc,这是一个文件名称1.txt'); // 获取 执行 101 下文件库id倒序排列的文件 +r($doc->getLibFilesTest($type[2], $objectID[5], $orderBy[0])) && p() && e('0'); // 获取 执行 102 下文件库id倒序排列的文件 +r($doc->getLibFilesTest($type[0], $objectID[0], $orderBy[1])) && p() && e('这是一个文件名称2.doc,这是一个文件名称3.docx,这是一个文件名称4.dot'); // 获取 产品 1 下文件库id正序排列的文件 +r($doc->getLibFilesTest($type[0], $objectID[1], $orderBy[1])) && p() && e('0'); // 获取 产品 2 下文件库id正序排列的文件 +r($doc->getLibFilesTest($type[1], $objectID[2], $orderBy[1])) && p() && e('这是一个文件名称1.txt,这是一个文件名称2.doc,这是一个文件名称91.docx'); // 获取 项目 11 下文件库id正序排列的文件 +r($doc->getLibFilesTest($type[1], $objectID[3], $orderBy[1])) && p() && e('0'); // 获取 项目 12 下文件库id正序排列的文件 +r($doc->getLibFilesTest($type[2], $objectID[4], $orderBy[1])) && p() && e('这是一个文件名称1.txt,这是一个文件名称2.doc,这是一个文件名称4.dot'); // 获取 执行 101 下文件库id正序排列的文件 +r($doc->getLibFilesTest($type[2], $objectID[5], $orderBy[1])) && p() && e('0'); // 获取 执行 102 下文件库id正序排列的文件 diff --git a/test/model/doc/statlibcounts.php b/test/model/doc/statlibcounts.php index 730df24862..1aa6cd3383 100644 --- a/test/model/doc/statlibcounts.php +++ b/test/model/doc/statlibcounts.php @@ -14,6 +14,12 @@ pid=1 */ +$libIDList = array(array(1, 3, 5), array(2, 4, 6), array(7, 9, 11), array(8, 10, 12), array(13, 14, 15)); + $doc = new docTest(); -r($doc->statLibCountsTest()) && p() && e(); \ No newline at end of file +r($doc->statLibCountsTest($libIDList[0])) && p('1;3;5') && e('3;3;3'); // 测试统计libID 1 3 5 的模块文件数量 +r($doc->statLibCountsTest($libIDList[1])) && p('2;4;6') && e('3;3;3'); // 测试统计libID 2 4 6 的模块文件数量 +r($doc->statLibCountsTest($libIDList[2])) && p('7;9;11') && e('3;3;4'); // 测试统计libID 7 9 11 的模块文件数量 +r($doc->statLibCountsTest($libIDList[3])) && p('8;10;12') && e('3;3;4'); // 测试统计libID 8 10 12 的模块文件数量 +r($doc->statLibCountsTest($libIDList[4])) && p('13;14;15') && e('4;4;4'); // 测试统计libID 13 14 15 的模块文件数量 From 305a4074e4610df444b83f5d75736e6ed995c03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Sat, 7 May 2022 13:50:02 +0800 Subject: [PATCH 34/41] * Rename var. --- module/doc/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/doc/model.php b/module/doc/model.php index 6c1ce17a86..bd6c10c81c 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1196,7 +1196,7 @@ class docModel extends model { $libs = array(); $docLibs = array(); - if($type == 'product' or $type == 'extension') + if($type == 'product' or $type == 'execution') { $nonzeroLibs = array(); if(strpos($this->config->doc->custom->showLibs, 'zero') === false) From 1bb079b8f3118fba36e1fb894a06415b1b26f882 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Sat, 7 May 2022 14:44:27 +0800 Subject: [PATCH 35/41] * Add unit test of doc. --- test/class/doc.class.php | 28 ++++++++++++++++++++++++--- test/model/doc/filldocsintree.php | 20 +++++++++++++++++-- test/model/doc/getdoctree.php | 11 +++++++++-- test/model/doc/getfileicon.php | 9 +++++++-- test/model/doc/getfilesourcepairs.php | 9 +++++++-- test/model/doc/getlibfiles.php | 15 ++++++++++++-- test/model/doc/setlibusers.php | 18 +++++++++++++++-- test/model/doc/statlibcounts.php | 8 ++++++-- 8 files changed, 101 insertions(+), 17 deletions(-) diff --git a/test/class/doc.class.php b/test/class/doc.class.php index d783a52374..d93e293022 100644 --- a/test/class/doc.class.php +++ b/test/class/doc.class.php @@ -412,13 +412,27 @@ class docTest return $names; } + /** + * Test fill docs in tree. + * + * @param object $node + * @param int $libID + * @access public + * @return object + */ public function fillDocsInTreeTest($node, $libID) { - $objects = $this->objectModel->fillDocsInTree($node, $libID); + $object = $this->objectModel->fillDocsInTree($node, $libID); if(dao::isError()) return dao::getError(); - return $objects; + $docsCounts = "$object->name:$object->docsCount;"; + foreach($object->children as $children) + { + if(isset($children->type) and $children->type == 'doc') continue; + $docsCounts .= "$children->name:$children->docsCount;"; + } + return $docsCounts; } public function getProductCrumbTest($productID, $executionID = 0) @@ -430,13 +444,21 @@ class docTest return $objects; } + /** + * Test set lib users. + * + * @param string $type + * @param int $objectID + * @access public + * @return array + */ public function setLibUsersTest($type, $objectID) { $objects = $this->objectModel->setLibUsers($type, $objectID); if(dao::isError()) return dao::getError(); - return $objects; + return implode($objects, ','); } public function getLibIdListByProjectTest($projectID = 0) diff --git a/test/model/doc/filldocsintree.php b/test/model/doc/filldocsintree.php index 28aa89df22..9eb6fdeb5a 100644 --- a/test/model/doc/filldocsintree.php +++ b/test/model/doc/filldocsintree.php @@ -10,10 +10,26 @@ title=测试 docModel->fillDocsInTree(); cid=1 pid=1 - +测试填充libID 1 文档树第一个节点的文档 >> 目录1:3;子目录1:0;子目录2:0; +测试填充libID 2 文档树第一个节点的文档 >> 目录2:2;子目录3:0;子目录4:0; +测试填充libID 3 文档树第一个节点的文档 >> 目录3:2;子目录5:0;子目录6:0; +测试填充libID 11 文档树第一个节点的文档 >> 目录11:2;子目录21:0;子目录22:0; +测试填充libID 12 文档树第一个节点的文档 >> 目录12:2;子目录23:0;子目录24:0; */ +$libID = array(1, 2, 3, 11, 12); + +global $tester; +$fullTree1 = $tester->loadModel('tree')->getTreeStructure($libID[0], 'doc'); +$fullTree2 = $tester->loadModel('tree')->getTreeStructure($libID[1], 'doc'); +$fullTree3 = $tester->loadModel('tree')->getTreeStructure($libID[2], 'doc'); +$fullTree4 = $tester->loadModel('tree')->getTreeStructure($libID[3], 'doc'); +$fullTree5 = $tester->loadModel('tree')->getTreeStructure($libID[4], 'doc'); $doc = new docTest(); -r($doc->fillDocsInTreeTest()) && p() && e(); \ No newline at end of file +r($doc->fillDocsInTreeTest($fullTree1[0], $libID[0])) && p() && e('目录1:3;子目录1:0;子目录2:0;'); // 测试填充libID 1 文档树第一个节点的文档 +r($doc->fillDocsInTreeTest($fullTree2[0], $libID[1])) && p() && e('目录2:2;子目录3:0;子目录4:0;'); // 测试填充libID 2 文档树第一个节点的文档 +r($doc->fillDocsInTreeTest($fullTree3[0], $libID[2])) && p() && e('目录3:2;子目录5:0;子目录6:0;'); // 测试填充libID 3 文档树第一个节点的文档 +r($doc->fillDocsInTreeTest($fullTree4[0], $libID[3])) && p() && e('目录11:2;子目录21:0;子目录22:0;'); // 测试填充libID 11 文档树第一个节点的文档 +r($doc->fillDocsInTreeTest($fullTree5[0], $libID[4])) && p() && e('目录12:2;子目录23:0;子目录24:0;'); // 测试填充libID 12 文档树第一个节点的文档 \ No newline at end of file diff --git a/test/model/doc/getdoctree.php b/test/model/doc/getdoctree.php index 8970f6e87c..c17a168044 100644 --- a/test/model/doc/getdoctree.php +++ b/test/model/doc/getdoctree.php @@ -10,7 +10,14 @@ title=测试 docModel->getDocTree(); cid=1 pid=1 - +获取libID 1 的文档树 >> 目录1:文档标题1,子目录1,子目录2; +获取libID 3 的文档树 >> 目录3:子目录5,子目录6; +获取libID 8 的文档树 >> 目录8:子目录15,子目录16; +获取libID 20 的文档树 >> 目录20:子目录39,子目录40; +获取libID 101 的文档树 >> 0 +获取libID 191 的文档树 >> 0 +获取libID 821 的文档树 >> 0 +获取libID 901 的文档树 >> 0 */ @@ -25,4 +32,4 @@ r($doc->getDocTreeTest($libID[3])) && p() && e('目录20:子目录39,子目录40 r($doc->getDocTreeTest($libID[4])) && p() && e('0'); // 获取libID 101 的文档树 r($doc->getDocTreeTest($libID[5])) && p() && e('0'); // 获取libID 191 的文档树 r($doc->getDocTreeTest($libID[6])) && p() && e('0'); // 获取libID 821 的文档树 -r($doc->getDocTreeTest($libID[7])) && p() && e('0'); // 获取libID 901 的文档树 +r($doc->getDocTreeTest($libID[7])) && p() && e('0'); // 获取libID 901 的文档树 \ No newline at end of file diff --git a/test/model/doc/getfileicon.php b/test/model/doc/getfileicon.php index 0d1e57c4e1..6b90b210d0 100644 --- a/test/model/doc/getfileicon.php +++ b/test/model/doc/getfileicon.php @@ -10,7 +10,12 @@ title=测试 docModel->getFileIcon(); cid=1 pid=1 - +测试获取 产品 1 的文件icon >> icon-file icon-file-word icon-file-word +测试获取 产品 2 的文件icon >> 0 +测试获取 项目 11 的文件icon >> icon-file-word icon-file-word icon-file-text +测试获取 项目 12 的文件icon >> 0 +测试获取 执行 101 的文件icon >> icon-file icon-file-word icon-file-text +测试获取 执行 102 的文件icon >> 0 */ @@ -24,4 +29,4 @@ r($doc->getFileIconTest($type[0], $objectID[1])) && p() && e('0'); r($doc->getFileIconTest($type[1], $objectID[2])) && p() && e('icon-file-word icon-file-word icon-file-text'); // 测试获取 项目 11 的文件icon r($doc->getFileIconTest($type[1], $objectID[3])) && p() && e('0'); // 测试获取 项目 12 的文件icon r($doc->getFileIconTest($type[2], $objectID[4])) && p() && e('icon-file icon-file-word icon-file-text'); // 测试获取 执行 101 的文件icon -r($doc->getFileIconTest($type[2], $objectID[5])) && p() && e('0'); // 测试获取 执行 102 的文件icon +r($doc->getFileIconTest($type[2], $objectID[5])) && p() && e('0'); // 测试获取 执行 102 的文件icon \ No newline at end of file diff --git a/test/model/doc/getfilesourcepairs.php b/test/model/doc/getfilesourcepairs.php index 00420411d1..d47fc8a828 100644 --- a/test/model/doc/getfilesourcepairs.php +++ b/test/model/doc/getfilesourcepairs.php @@ -10,7 +10,12 @@ title=测试 docModel->getFileSourcePairs(); cid=1 pid=1 - +测试获取 产品 1 的文件类型分组 >> testcase:1;story:1;bug:1; +测试获取 产品 2 的文件类型分组 >> 0 +测试获取 项目 11 的文件类型分组 >> task:2;bug:1; +测试获取 项目 12 的文件类型分组 >> 0 +测试获取 执行 101 的文件类型分组 >> testcase:1;bug:1;task:1; +测试获取 执行 102 的文件类型分组 >> 0 */ @@ -24,4 +29,4 @@ r($doc->getFileSourcePairsTest($type[0], $objectID[1])) && p() && e('0'); r($doc->getFileSourcePairsTest($type[1], $objectID[2])) && p() && e('task:2;bug:1;'); // 测试获取 项目 11 的文件类型分组 r($doc->getFileSourcePairsTest($type[1], $objectID[3])) && p() && e('0'); // 测试获取 项目 12 的文件类型分组 r($doc->getFileSourcePairsTest($type[2], $objectID[4])) && p() && e('testcase:1;bug:1;task:1;'); // 测试获取 执行 101 的文件类型分组 -r($doc->getFileSourcePairsTest($type[2], $objectID[5])) && p() && e('0'); // 测试获取 执行 102 的文件类型分组 +r($doc->getFileSourcePairsTest($type[2], $objectID[5])) && p() && e('0'); // 测试获取 执行 102 的文件类型分组 \ No newline at end of file diff --git a/test/model/doc/getlibfiles.php b/test/model/doc/getlibfiles.php index 10fc9adacd..d74c3bee76 100644 --- a/test/model/doc/getlibfiles.php +++ b/test/model/doc/getlibfiles.php @@ -10,7 +10,18 @@ title=测试 docModel->getLibFiles(); cid=1 pid=1 - +获取 产品 1 下文件库id倒序排列的文件 >> 这是一个文件名称4.dot,这是一个文件名称3.docx,这是一个文件名称2.doc +获取 产品 2 下文件库id倒序排列的文件 >> 0 +获取 项目 11 下文件库id倒序排列的文件 >> 这是一个文件名称91.docx,这是一个文件名称2.doc,这是一个文件名称1.txt +获取 项目 12 下文件库id倒序排列的文件 >> 0 +获取 执行 101 下文件库id倒序排列的文件 >> 这是一个文件名称4.dot,这是一个文件名称2.doc,这是一个文件名称1.txt +获取 执行 102 下文件库id倒序排列的文件 >> 0 +获取 产品 1 下文件库id正序排列的文件 >> 这是一个文件名称2.doc,这是一个文件名称3.docx,这是一个文件名称4.dot +获取 产品 2 下文件库id正序排列的文件 >> 0 +获取 项目 11 下文件库id正序排列的文件 >> 这是一个文件名称1.txt,这是一个文件名称2.doc,这是一个文件名称91.docx +获取 项目 12 下文件库id正序排列的文件 >> 0 +获取 执行 101 下文件库id正序排列的文件 >> 这是一个文件名称1.txt,这是一个文件名称2.doc,这是一个文件名称4.dot +获取 执行 102 下文件库id正序排列的文件 >> 0 */ @@ -31,4 +42,4 @@ r($doc->getLibFilesTest($type[0], $objectID[1], $orderBy[1])) && p() && e('0'); r($doc->getLibFilesTest($type[1], $objectID[2], $orderBy[1])) && p() && e('这是一个文件名称1.txt,这是一个文件名称2.doc,这是一个文件名称91.docx'); // 获取 项目 11 下文件库id正序排列的文件 r($doc->getLibFilesTest($type[1], $objectID[3], $orderBy[1])) && p() && e('0'); // 获取 项目 12 下文件库id正序排列的文件 r($doc->getLibFilesTest($type[2], $objectID[4], $orderBy[1])) && p() && e('这是一个文件名称1.txt,这是一个文件名称2.doc,这是一个文件名称4.dot'); // 获取 执行 101 下文件库id正序排列的文件 -r($doc->getLibFilesTest($type[2], $objectID[5], $orderBy[1])) && p() && e('0'); // 获取 执行 102 下文件库id正序排列的文件 +r($doc->getLibFilesTest($type[2], $objectID[5], $orderBy[1])) && p() && e('0'); // 获取 执行 102 下文件库id正序排列的文件 \ No newline at end of file diff --git a/test/model/doc/setlibusers.php b/test/model/doc/setlibusers.php index 0485e11ee1..3b3689fc84 100644 --- a/test/model/doc/setlibusers.php +++ b/test/model/doc/setlibusers.php @@ -10,10 +10,24 @@ title=测试 docModel->setLibUsers(); cid=1 pid=1 - +测试获取 产品 1 的团队成员 >> po82,user92,po92,test2,test82,test92,pm72,pm82 +测试获取 产品 2 的团队成员 >> po83,user93,po93,test3,test83,test93,pm73,pm83 +测试获取 产品 3 的团队成员 >> po84,user94,po94,test4,test84,test94,pm74,pm84 +测试获取 执行 101 的团队成员 >> po82,user92 +测试获取 执行 102 的团队成员 >> po83,user93 +测试获取 执行 103 的团队成员 >> po84,user94 +测试获取 项目 11 的团队成员 >> 0 */ +$type = array('product', 'execution', 'project'); +$objectID = array(1, 2, 3, 101, 102, 103, 11); $doc = new docTest(); -r($doc->setLibUsersTest()) && p() && e(); \ No newline at end of file +r($doc->setLibUsersTest($type[0], $objectID[0])) && p() && e('po82,user92,po92,test2,test82,test92,pm72,pm82'); // 测试获取 产品 1 的团队成员 +r($doc->setLibUsersTest($type[0], $objectID[1])) && p() && e('po83,user93,po93,test3,test83,test93,pm73,pm83'); // 测试获取 产品 2 的团队成员 +r($doc->setLibUsersTest($type[0], $objectID[2])) && p() && e('po84,user94,po94,test4,test84,test94,pm74,pm84'); // 测试获取 产品 3 的团队成员 +r($doc->setLibUsersTest($type[1], $objectID[3])) && p() && e('po82,user92'); // 测试获取 执行 101 的团队成员 +r($doc->setLibUsersTest($type[1], $objectID[4])) && p() && e('po83,user93'); // 测试获取 执行 102 的团队成员 +r($doc->setLibUsersTest($type[1], $objectID[5])) && p() && e('po84,user94'); // 测试获取 执行 103 的团队成员 +r($doc->setLibUsersTest($type[2], $objectID[6])) && p() && e('0'); // 测试获取 项目 11 的团队成员 \ No newline at end of file diff --git a/test/model/doc/statlibcounts.php b/test/model/doc/statlibcounts.php index 1aa6cd3383..006e801d99 100644 --- a/test/model/doc/statlibcounts.php +++ b/test/model/doc/statlibcounts.php @@ -10,7 +10,11 @@ title=测试 docModel->statLibCounts(); cid=1 pid=1 - +测试统计libID 1 3 5 的模块文件数量 >> 3;3;3 +测试统计libID 2 4 6 的模块文件数量 >> 3;3;3 +测试统计libID 7 9 11 的模块文件数量 >> 3;3;4 +测试统计libID 8 10 12 的模块文件数量 >> 3;3;4 +测试统计libID 13 14 15 的模块文件数量 >> 4;4;4 */ @@ -22,4 +26,4 @@ r($doc->statLibCountsTest($libIDList[0])) && p('1;3;5') && e('3;3;3'); // 测 r($doc->statLibCountsTest($libIDList[1])) && p('2;4;6') && e('3;3;3'); // 测试统计libID 2 4 6 的模块文件数量 r($doc->statLibCountsTest($libIDList[2])) && p('7;9;11') && e('3;3;4'); // 测试统计libID 7 9 11 的模块文件数量 r($doc->statLibCountsTest($libIDList[3])) && p('8;10;12') && e('3;3;4'); // 测试统计libID 8 10 12 的模块文件数量 -r($doc->statLibCountsTest($libIDList[4])) && p('13;14;15') && e('4;4;4'); // 测试统计libID 13 14 15 的模块文件数量 +r($doc->statLibCountsTest($libIDList[4])) && p('13;14;15') && e('4;4;4'); // 测试统计libID 13 14 15 的模块文件数量 \ No newline at end of file From 05a8756da50844e9477b263a9032493c369581f6 Mon Sep 17 00:00:00 2001 From: zenggang Date: Sat, 7 May 2022 06:51:54 +0000 Subject: [PATCH 36/41] * Datatable unit --- test/class/datatable.class.php | 44 +++++++++++++++++++++ test/model/datatable/getFieldList.php | 25 ++++++++++++ test/model/datatable/getSetting.php | 25 ++++++++++++ test/model/datatable/printHead.php | 31 +++++++++++++++ test/model/datatable/setFixedFieldWidth.php | 29 ++++++++++++++ test/ztest | 3 ++ 6 files changed, 157 insertions(+) create mode 100644 test/class/datatable.class.php create mode 100644 test/model/datatable/getFieldList.php create mode 100644 test/model/datatable/getSetting.php create mode 100644 test/model/datatable/printHead.php create mode 100644 test/model/datatable/setFixedFieldWidth.php diff --git a/test/class/datatable.class.php b/test/class/datatable.class.php new file mode 100644 index 0000000000..7e354de529 --- /dev/null +++ b/test/class/datatable.class.php @@ -0,0 +1,44 @@ +objectModel = $tester->loadModel('datatable'); + } + + public function getFieldListTest($module, $method) + { + $module = zget($this->objectModel->config->datatable->moduleAlias, "$module-$method", $module); + $result = $this->objectModel->getFieldList($module); + return $result; + } + + public function getSettingTest($module, $method) + { + $this->objectModel->app->methodName = $method; + $result = $this->objectModel->getSetting($module); + return $result; + } + + public function printHeadTest($data) + { + ob_start(); + $this->objectModel->printHead($data['cols'], $data['orderBy'], $data['vars'], $data['checkBox']); + $head = ob_get_clean(); + + $isTh = strpos($head, '
objectModel->setFixedFieldWidth($setting); + return $result; + } +} diff --git a/test/model/datatable/getFieldList.php b/test/model/datatable/getFieldList.php new file mode 100644 index 0000000000..4cd4b79116 --- /dev/null +++ b/test/model/datatable/getFieldList.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +> ID +获取项目模块browse方法自定义列 >> 项目名称 +获取执行模块task方法自定义列 >> 70 +获取测试用例模块browse方法自定义列 >> auto + +*/ + + +$datatable = new datatableTest(); +r($datatable->getFieldListTest('product', 'browse')) && p('id:title') && e('ID'); //获取产品模块browse方法自定义列 +r($datatable->getFieldListTest('project', 'browse')) && p('name:title') && e('项目名称'); //获取项目模块browse方法自定义列 +r($datatable->getFieldListTest('execution', 'task')) && p('id:width') && e('70'); //获取执行模块task方法自定义列 +r($datatable->getFieldListTest('testcase', 'browse')) && p('title:width') && e('auto'); //获取测试用例模块browse方法自定义列 diff --git a/test/model/datatable/getSetting.php b/test/model/datatable/getSetting.php new file mode 100644 index 0000000000..b650e9686c --- /dev/null +++ b/test/model/datatable/getSetting.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +> ID +获取项目模块browse方法设置 >> 项目名称 +获取执行模块task方法设置 >> 70 +获取测试用例模块browse方法设置 >> auto + +*/ + + +$datatable = new datatableTest(); +r($datatable->getSettingTest('product', 'browse')) && p('0:title') && e('ID'); //获取产品模块browse方法设置 +r($datatable->getSettingTest('project', 'browse')) && p('1:title') && e('项目名称'); //获取项目模块browse方法设置 +r($datatable->getSettingTest('execution', 'task')) && p('0:width') && e('70'); //获取执行模块task方法设置 +r($datatable->getSettingTest('testcase', 'browse')) && p('2:width') && e('auto'); //获取测试用例模块browse方法设置 diff --git a/test/model/datatable/printHead.php b/test/model/datatable/printHead.php new file mode 100644 index 0000000000..e48162d59f --- /dev/null +++ b/test/model/datatable/printHead.php @@ -0,0 +1,31 @@ +#!/usr/bin/env php +> 1 +获取产品模块browse方法头部html带排序 >> 1 +获取产品模块browse方法头部html带参数 >> 1 +获取产品模块browse方法头部html带checkbox >> 1 + +*/ + +$datatable = new datatableTest(); +$productSetting = $datatable->getSettingTest('product', 'browse'); + +$data = array('cols' => $productSetting[0], 'orderBy' => '', 'vars' => '', 'checkBox' => false); +$data_order = array('cols' => $productSetting[0], 'orderBy' => 'id_asc', 'vars' => '', 'checkBox' => false); +$data_vars = array('cols' => $productSetting[0], 'orderBy' => 'id_asc', 'vars' => 'productID=1', 'checkBox' => false); +$data_check = array('cols' => $productSetting[0], 'orderBy' => 'id_asc', 'vars' => 'productID=1', 'checkBox' => true); + +r($datatable->printHeadTest($data)) && p() && e(1); //获取产品模块browse方法头部html +r($datatable->printHeadTest($data_order)) && p() && e(1); //获取产品模块browse方法头部html带排序 +r($datatable->printHeadTest($data_vars)) && p() && e(1); //获取产品模块browse方法头部html带参数 +r($datatable->printHeadTest($data_check)) && p() && e(1); //获取产品模块browse方法头部html带checkbox diff --git a/test/model/datatable/setFixedFieldWidth.php b/test/model/datatable/setFixedFieldWidth.php new file mode 100644 index 0000000000..f615831913 --- /dev/null +++ b/test/model/datatable/setFixedFieldWidth.php @@ -0,0 +1,29 @@ +#!/usr/bin/env php +> 550 +获取项目模块browse方法设置宽度 >> 180 +获取执行模块task方法设置宽度 >> 550 +获取测试用例模块browse方法设置宽度 >> 150 + +*/ + +$datatable = new datatableTest(); +$productSetting = $datatable->getSettingTest('product', 'browse'); +$projectSetting = $datatable->getSettingTest('project', 'browse'); +$executionSetting = $datatable->getSettingTest('execution', 'task'); +$testcaseSetting = $datatable->getSettingTest('testcase', 'browse'); + +r($datatable->setFixedFieldWidthTest($productSetting)) && p('leftWidth') && e('550'); //获取产品模块browse方法设置宽度 +r($datatable->setFixedFieldWidthTest($projectSetting)) && p('rightWidth') && e('180'); //获取项目模块browse方法设置宽度 +r($datatable->setFixedFieldWidthTest($executionSetting)) && p('leftWidth') && e('550'); //获取执行模块browse方法设置宽度 +r($datatable->setFixedFieldWidthTest($testcaseSetting)) && p('rightWidth') && e('150'); //获取测试用例模块browse方法设置宽度 diff --git a/test/ztest b/test/ztest index 188e7995af..5c853ac07d 100755 --- a/test/ztest +++ b/test/ztest @@ -43,6 +43,9 @@ switch($argv[1]) case 'cron': ztfRun('model/cron'); break; + case 'datatable': + ztfRun('model/datatable'); + break; case 'dept': ztfRun('model/dept'); break; From 9303994da99a86455c45350c2bac83e36cdd8e44 Mon Sep 17 00:00:00 2001 From: zenggang Date: Sat, 7 May 2022 06:54:18 +0000 Subject: [PATCH 37/41] * Adjust code --- test/model/datatable/getFieldList.php | 1 - test/model/datatable/getSetting.php | 1 - 2 files changed, 2 deletions(-) diff --git a/test/model/datatable/getFieldList.php b/test/model/datatable/getFieldList.php index 4cd4b79116..ef6183a769 100644 --- a/test/model/datatable/getFieldList.php +++ b/test/model/datatable/getFieldList.php @@ -17,7 +17,6 @@ pid=1 */ - $datatable = new datatableTest(); r($datatable->getFieldListTest('product', 'browse')) && p('id:title') && e('ID'); //获取产品模块browse方法自定义列 r($datatable->getFieldListTest('project', 'browse')) && p('name:title') && e('项目名称'); //获取项目模块browse方法自定义列 diff --git a/test/model/datatable/getSetting.php b/test/model/datatable/getSetting.php index b650e9686c..dcb3c87da8 100644 --- a/test/model/datatable/getSetting.php +++ b/test/model/datatable/getSetting.php @@ -17,7 +17,6 @@ pid=1 */ - $datatable = new datatableTest(); r($datatable->getSettingTest('product', 'browse')) && p('0:title') && e('ID'); //获取产品模块browse方法设置 r($datatable->getSettingTest('project', 'browse')) && p('1:title') && e('项目名称'); //获取项目模块browse方法设置 From c82550c55c6357dcffe54d6ad87f71f961867aed Mon Sep 17 00:00:00 2001 From: wangyidong Date: Sat, 7 May 2022 14:57:44 +0800 Subject: [PATCH 38/41] * Finish jenkins test. --- test/class/git.class.php | 24 ++------ test/class/jenkins.class.php | 102 ++++++++++++++++++++++++++++++++ test/model/git/getrepologs.php | 3 - test/model/git/getrepos.php | 5 +- test/model/git/updatecommit.php | 3 - test/model/jenkins/create.php | 37 ++++++++++++ test/model/jenkins/getbyid.php | 30 ++++++++++ test/model/jenkins/getlist.php | 22 +++++++ test/model/jenkins/getpairs.php | 21 +++++++ test/model/jenkins/gettasks.php | 30 ++++++++++ test/model/jenkins/update.php | 39 ++++++++++++ test/ztest | 3 + 12 files changed, 291 insertions(+), 28 deletions(-) create mode 100644 test/class/jenkins.class.php create mode 100644 test/model/jenkins/create.php create mode 100755 test/model/jenkins/getbyid.php create mode 100755 test/model/jenkins/getlist.php create mode 100755 test/model/jenkins/getpairs.php create mode 100755 test/model/jenkins/gettasks.php create mode 100644 test/model/jenkins/update.php diff --git a/test/class/git.class.php b/test/class/git.class.php index 6478e17bb5..d667572f9c 100644 --- a/test/class/git.class.php +++ b/test/class/git.class.php @@ -10,17 +10,6 @@ class gitTest $this->gitModel = $this->tester->loadModel('git'); } - /** - * Run - * - * @access public - * @return void - */ - public function run() - { - return $this->gitModel->run(); - } - /** * Update commit. * @@ -28,7 +17,7 @@ class gitTest * @param array $commentGroup * @param bool $printLog * @access public - * @return string + * @return bool */ public function updateCommit($repo) { @@ -44,7 +33,7 @@ class gitTest * Set the repos. * * @access public - * @return mixed + * @return object */ public function setRepos() { @@ -57,7 +46,7 @@ class gitTest * Get repos. * * @access public - * @return array + * @return string */ public function getRepos() { @@ -70,7 +59,7 @@ class gitTest * * @param object $repo * @access public - * @return bool + * @return object */ public function setRepo($repo) { @@ -91,7 +80,7 @@ class gitTest * * @param object $repo * @access public - * @return mixed + * @return int */ public function getRepoTags($repo) { @@ -104,9 +93,8 @@ class gitTest * Get repo logs. * * @param object $repo - * @param int $fromRevision * @access public - * @return array + * @return int */ public function getRepoLogs($repo) { diff --git a/test/class/jenkins.class.php b/test/class/jenkins.class.php new file mode 100644 index 0000000000..7d75f0c5f1 --- /dev/null +++ b/test/class/jenkins.class.php @@ -0,0 +1,102 @@ +tester = $tester; + $this->jenkins = $this->tester->loadModel('jenkins'); + } + + /** + * Get by id. + * + * @param int $id + * @access public + * @return object + */ + public function getByID($id) + { + $jenkins = $this->jenkins->getByID($id); + if(empty($jenkins)) return 0; + return $jenkins; + } + + /** + * Get jenkins list. + * + * @param string $orderBy + * @access public + * @return object + */ + public function getList($orderBy = 'id_desc') + { + $jenkins = $this->jenkins->getList($orderBy); + if(empty($jenkins)) return 0; + return array_shift($jenkins); + } + + /** + * Get jenkins pairs + * + * @return string + */ + public function getPairs() + { + $pairs = $this->jenkins->getPairs(); + return key($pairs); + } + + /** + * Get jenkins tasks. + * + * @param int $id + * @access public + * @return array + */ + public function getTasks($id) + { + $tasks = $this->jenkins->getTasks($id); + if(empty($tasks)) return 0; + return $tasks; + } + + /** + * Create a jenkins. + * + * @access public + * @return object|string + */ + public function create() + { + $jenkinsID = $this->jenkins->create(); + if(dao::isError()) + { + $errors = dao::getError(); + return key($errors); + } + + return $this->jenkins->getById($jenkinsID); + } + + /** + * Update a jenkins. + * + * @param int $id + * @access public + * @return object|string + */ + public function update($id) + { + $this->jenkins->update($id); + if(dao::isError()) + { + $errors = dao::getError(); + return key($errors); + } + + return $this->jenkins->getById($id); + } +} diff --git a/test/model/git/getrepologs.php b/test/model/git/getrepologs.php index b2e1dac8c9..2cd796f534 100755 --- a/test/model/git/getrepologs.php +++ b/test/model/git/getrepologs.php @@ -18,9 +18,6 @@ pid=1 $git = new gitTest(); -/* Fix error Gitlab url. */ -$tester->dao->update(TABLE_PIPELINE)->set('url')->eq('http://10.0.1.161:51080')->where('id')->eq(1)->exec(); - $repo = $tester->dao->select('*')->from(TABLE_REPO)->limit(1)->fetch(); if(strtolower($repo->SCM) == 'gitlab') $repo = $tester->loadModel('repo')->processGitlab($repo); r($git->getRepoLogs($repo)) && p() && e(1); // 获取版本库的tags diff --git a/test/model/git/getrepos.php b/test/model/git/getrepos.php index 0d7260bc9f..dc568ac8d1 100755 --- a/test/model/git/getrepos.php +++ b/test/model/git/getrepos.php @@ -16,10 +16,7 @@ pid=1 $git = new gitTest(); -/* Fix error Gitlab url. */ -$tester->dao->update(TABLE_PIPELINE)->set('url')->eq('http://10.0.1.161:51080')->where('id')->eq(1)->exec(); - $tester->dao->update(TABLE_REPO)->set('synced')->eq(1)->where('id')->eq(1)->exec(); -r($git->getRepos()) && p() && e('http://192.168.1.161:51080/api/v4/projects/42/repository/'); // 获取版本库 +r($git->getRepos()) && p() && e('http://10.0.1.161:51080/api/v4/projects/42/repository/'); // 获取版本库 system("./ztest init"); diff --git a/test/model/git/updatecommit.php b/test/model/git/updatecommit.php index 6e75cb6323..213b8fb322 100755 --- a/test/model/git/updatecommit.php +++ b/test/model/git/updatecommit.php @@ -17,9 +17,6 @@ pid=1 $git = new gitTest(); -/* Fix error Gitlab url. */ -$tester->dao->update(TABLE_PIPELINE)->set('url')->eq('http://10.0.1.161:51080')->where('id')->eq(1)->exec(); - $repo = $tester->dao->select('*')->from(TABLE_REPO)->limit(1)->fetch(); if(strtolower($repo->SCM) == 'gitlab') $repo = $tester->loadModel('repo')->processGitlab($repo); r($git->updateCommit($repo)) && p() && e(1); // 测试正常的版本库 diff --git a/test/model/jenkins/create.php b/test/model/jenkins/create.php new file mode 100644 index 0000000000..627d27b13c --- /dev/null +++ b/test/model/jenkins/create.php @@ -0,0 +1,37 @@ +#!/usr/bin/env php +create(); +cid=1 +pid=1 + +Jenkins名称为空 >> name +服务器地址为空 >> url +正确Jenkins数据 >> Jenkins,http://10.0.1.161:58080,1196c85ba525a268570df9da627e3a7b2d + +*/ + +$jenkins = new jenkinsTest(); + +$_POST = array(); +$_POST['name'] = ''; +$_POST['url'] = 'http://10.0.1.161:58080'; +$_POST['account'] = 'admin'; +$_POST['token'] = '1196c85ba525a268570df9da627e3a7b2d'; +$_POST['password'] = ''; + +r($jenkins->create()) && p() && e('name'); // Jenkins名称为空 + +$_POST['name'] = 'Jenkins'; +$_POST['url'] = ''; +r($jenkins->create()) && p() && e('url'); // 服务器地址为空 + +$_POST['url'] = 'http://10.0.1.161:58080'; +r($jenkins->create()) && p('name,url,token') && e('Jenkins,http://10.0.1.161:58080,1196c85ba525a268570df9da627e3a7b2d'); // 正确Jenkins数据 + +system("./ztest init"); diff --git a/test/model/jenkins/getbyid.php b/test/model/jenkins/getbyid.php new file mode 100755 index 0000000000..f04d0bcdaf --- /dev/null +++ b/test/model/jenkins/getbyid.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +gitById(); +cid=1 +pid=1 + +使用存在的ID >> 3 +使用空的ID >> 0 +使用不存在的ID >> 0 + +*/ + +$jenkins = new jenkinsTest(); + +$jenkinsID = 3; +r($jenkins->getById($jenkinsID)) && p('id') && e('3'); // 使用存在的ID + +$jenkinsID = 0; +r($jenkins->getById($jenkinsID)) && p() && e(0); // 使用空的ID + +$jenkinsID = 111; +r($jenkins->getById($jenkinsID)) && p() && e(0); // 使用不存在的ID + +system("./ztest init"); diff --git a/test/model/jenkins/getlist.php b/test/model/jenkins/getlist.php new file mode 100755 index 0000000000..e799dd54ae --- /dev/null +++ b/test/model/jenkins/getlist.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +gitList(); +cid=1 +pid=1 + +获取Jenkins列表 >> 3 + +*/ + +$jenkins = new jenkinsTest(); + +$orderBy = 'id_desc'; +r($jenkins->getList($orderBy)) && p('id') && e('3'); // 获取Jenkins列表 + +system("./ztest init"); diff --git a/test/model/jenkins/getpairs.php b/test/model/jenkins/getpairs.php new file mode 100755 index 0000000000..f6b86224d7 --- /dev/null +++ b/test/model/jenkins/getpairs.php @@ -0,0 +1,21 @@ +#!/usr/bin/env php +gitPairs(); +cid=1 +pid=1 + +获取Jenkins >> 3 + +*/ + +$jenkins = new jenkinsTest(); + +r($jenkins->getPairs()) && p() && e('3'); // 获取Jenkins + +system("./ztest init"); diff --git a/test/model/jenkins/gettasks.php b/test/model/jenkins/gettasks.php new file mode 100755 index 0000000000..d2cb8aef85 --- /dev/null +++ b/test/model/jenkins/gettasks.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +gitTasks(); +cid=1 +pid=1 + +使用存在的Jenkins >> zentao-test +使用空的Jenkins >> 0 +使用不存在的Jenkins >> 0 + +*/ + +$jenkins = new jenkinsTest(); + +$id = 3; +r($jenkins->getTasks($id)) && p('zentao-test') && e('zentao-test'); // 使用存在的Jenkins + +$id = 0; +r($jenkins->getTasks($id)) && p() && e('0'); // 使用空的Jenkins + +$id = 111; +r($jenkins->getTasks($id)) && p() && e('0'); // 使用不存在的Jenkins + +system("./ztest init"); diff --git a/test/model/jenkins/update.php b/test/model/jenkins/update.php new file mode 100644 index 0000000000..e3b39dea82 --- /dev/null +++ b/test/model/jenkins/update.php @@ -0,0 +1,39 @@ +#!/usr/bin/env php +update(); +cid=1 +pid=1 + +Jenkins名称为空 >> name +服务器地址为空 >> url +正确Jenkins数据 >> Changed Jenkins + +*/ + +$jenkins = new jenkinsTest(); + +$jenkinsID = 3; + +$_POST = array(); +$_POST['name'] = ''; +$_POST['url'] = 'http://10.0.1.161:58080'; +$_POST['account'] = 'admin'; +$_POST['token'] = '1196c85ba525a268570df9da627e3a7b2d'; +$_POST['password'] = ''; + +r($jenkins->update($jenkinsID)) && p() && e('name'); // Jenkins名称为空 + +$_POST['name'] = 'Changed Jenkins'; +$_POST['url'] = ''; +r($jenkins->update($jenkinsID)) && p() && e('url'); // 服务器地址为空 + +$_POST['url'] = 'http://10.0.1.161:58080'; +r($jenkins->update($jenkinsID)) && p('name') && e('Changed Jenkins'); // 正确Jenkins数据 + +system("./ztest init"); diff --git a/test/ztest b/test/ztest index 188e7995af..226f270c20 100755 --- a/test/ztest +++ b/test/ztest @@ -61,6 +61,9 @@ switch($argv[1]) case 'group': ztfRun('model/group'); break; + case 'jenkins': + ztfRun('model/jenkins'); + break; case 'kanban': ztfRun('model/kanban'); break; From 7784f07677a2c563315f87344719db64fb30fe15 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Sat, 7 May 2022 15:07:56 +0800 Subject: [PATCH 39/41] * Add test case for doc. --- test/class/doc.class.php | 14 +++++++++++ test/model/doc/getpreandnextdoc.php | 37 +++++++++++++++++++++++++++-- test/model/doc/getstatisticinfo.php | 5 ++-- test/ztest | 3 +++ 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/test/class/doc.class.php b/test/class/doc.class.php index d783a52374..db2d6326de 100644 --- a/test/class/doc.class.php +++ b/test/class/doc.class.php @@ -448,6 +448,12 @@ class docTest return $objects; } + /** + * Get statistic information. + * + * @access public + * @return object + */ public function getStatisticInfoTest() { $objects = $this->objectModel->getStatisticInfo(); @@ -457,6 +463,14 @@ class docTest return $objects; } + /** + * Get the previous and next doc. + * + * @param int $docID + * @param int $libID + * @access public + * @return object + */ public function getPreAndNextDocTest($docID, $libID) { $objects = $this->objectModel->getPreAndNextDoc($docID, $libID); diff --git a/test/model/doc/getpreandnextdoc.php b/test/model/doc/getpreandnextdoc.php index 0e9019503d..4a635940d4 100644 --- a/test/model/doc/getpreandnextdoc.php +++ b/test/model/doc/getpreandnextdoc.php @@ -10,10 +10,43 @@ title=测试 docModel->getPreAndNextDoc(); cid=1 pid=1 - +查询空数据 >> , +查询文档ID为空的数据 >> , +查询文档ID为空的数据 >> , +查询文档ID为空的数据 >> , +查询文档库ID为空的数据 >> , +查询文档库ID为空的数据 >> , +查询文档库ID为空的数据 >> , +查询文档ID为1并且文档库ID为1的数据 >> , +查询文档ID为2并且文档库ID为1的数据 >> , +查询文档ID不存在并且文档库ID为1的数据 >> , +查询文档ID为1并且文档库ID为2的数据 >> , +查询文档ID为2并且文档库ID为2的数据 >> , +查询文档ID不存在并且文档库ID为2的数据 >> , +查询文档ID为1并且文档库ID不存在的数据 >> , +查询文档ID为2并且文档库ID不存在的数据 >> , +查询文档ID不存在并且文档库ID不存在的数据 >> , */ $doc = new docTest(); -r($doc->getPreAndNextDocTest()) && p() && e(); \ No newline at end of file +$docIDList = array(0, 1, 2, 1000); +$libIDList = array(0, 1, 2, 1000); + +r($doc->getPreAndNextDocTest($docIDList[0], $libIDList[0])) && p('pre,next') && e(','); // 查询空数据 +r($doc->getPreAndNextDocTest($docIDList[0], $libIDList[1])) && p('pre,next') && e(','); // 查询文档ID为空的数据 +r($doc->getPreAndNextDocTest($docIDList[0], $libIDList[2])) && p('pre,next') && e(','); // 查询文档ID为空的数据 +r($doc->getPreAndNextDocTest($docIDList[0], $libIDList[3])) && p('pre,next') && e(','); // 查询文档ID为空的数据 +r($doc->getPreAndNextDocTest($docIDList[1], $libIDList[0])) && p('pre,next') && e(','); // 查询文档库ID为空的数据 +r($doc->getPreAndNextDocTest($docIDList[2], $libIDList[0])) && p('pre,next') && e(','); // 查询文档库ID为空的数据 +r($doc->getPreAndNextDocTest($docIDList[3], $libIDList[0])) && p('pre,next') && e(','); // 查询文档库ID为空的数据 +r($doc->getPreAndNextDocTest($docIDList[1], $libIDList[1])) && p('pre,next') && e(','); // 查询文档ID为1并且文档库ID为1的数据 +r($doc->getPreAndNextDocTest($docIDList[2], $libIDList[1])) && p('pre,next') && e(','); // 查询文档ID为2并且文档库ID为1的数据 +r($doc->getPreAndNextDocTest($docIDList[3], $libIDList[1])) && p('pre,next') && e(','); // 查询文档ID不存在并且文档库ID为1的数据 +r($doc->getPreAndNextDocTest($docIDList[1], $libIDList[2])) && p('pre,next') && e(','); // 查询文档ID为1并且文档库ID为2的数据 +r($doc->getPreAndNextDocTest($docIDList[2], $libIDList[2])) && p('pre,next') && e(','); // 查询文档ID为2并且文档库ID为2的数据 +r($doc->getPreAndNextDocTest($docIDList[3], $libIDList[2])) && p('pre,next') && e(','); // 查询文档ID不存在并且文档库ID为2的数据 +r($doc->getPreAndNextDocTest($docIDList[1], $libIDList[3])) && p('pre,next') && e(','); // 查询文档ID为1并且文档库ID不存在的数据 +r($doc->getPreAndNextDocTest($docIDList[2], $libIDList[3])) && p('pre,next') && e(','); // 查询文档ID为2并且文档库ID不存在的数据 +r($doc->getPreAndNextDocTest($docIDList[3], $libIDList[3])) && p('pre,next') && e(','); // 查询文档ID不存在并且文档库ID不存在的数据 diff --git a/test/model/doc/getstatisticinfo.php b/test/model/doc/getstatisticinfo.php index 26ceba1733..c095600292 100644 --- a/test/model/doc/getstatisticinfo.php +++ b/test/model/doc/getstatisticinfo.php @@ -10,10 +10,9 @@ title=测试 docModel->getStatisticInfo(); cid=1 pid=1 - - +测试正常查询 >> 900,0,0,900,0,900,900 */ $doc = new docTest(); -r($doc->getStatisticInfoTest()) && p() && e(); \ No newline at end of file +r($doc->getStatisticInfoTest()) && p('totalDocs,todayEditedDocs,lastEditedDocs,lastAddedDocs,myCollection,myDocs,pastEditedDocs') && e('900,0,0,900,0,900,900'); //测试正常查询 diff --git a/test/ztest b/test/ztest index 188e7995af..d8da371a22 100755 --- a/test/ztest +++ b/test/ztest @@ -49,6 +49,9 @@ switch($argv[1]) case 'design': ztfRun('model/design'); break; + case 'doc': + ztfRun('model/doc'); + break; case 'file': ztfRun('model/file'); break; From f7891a08a3a716d7337142dff0a695c1bdc2a096 Mon Sep 17 00:00:00 2001 From: lanzongjun Date: Sat, 7 May 2022 15:23:33 +0800 Subject: [PATCH 40/41] * unit test entry --- test/class/entry.class.php | 113 ++++++++++++----------------------- test/model/entry/getbyid.php | 6 +- 2 files changed, 40 insertions(+), 79 deletions(-) diff --git a/test/class/entry.class.php b/test/class/entry.class.php index d1e41f7de9..9d7c4b1266 100644 --- a/test/class/entry.class.php +++ b/test/class/entry.class.php @@ -17,14 +17,10 @@ class entryTest public function getByIdTest($entryID) { $object = $this->objectModel->getById($entryID); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } + + if(dao::isError()) return dao::getError(); + + return $object; } /** @@ -37,14 +33,10 @@ class entryTest public function getByCodeTest($code) { $object = $this->objectModel->getByCode($code); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } + + if(dao::isError()) return dao::getError(); + + return $object; } /** @@ -57,14 +49,10 @@ class entryTest public function getByKeyTest($key) { $object = $this->objectModel->getByKey($key); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } + + if(dao::isError()) return dao::getError(); + + return $object; } /** @@ -78,14 +66,10 @@ class entryTest public function getListTest($orderBy = 'id_desc', $pager = null) { $objects = $this->objectModel->getList($orderBy, $pager); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $objects; - } + + if(dao::isError()) return dao::getError(); + + return $objects; } /** @@ -100,14 +84,10 @@ class entryTest public function getLogsTest($id, $orderBy = 'date_desc', $pager = null) { $object = $this->objectModel->getLogs($id, $orderBy, $paper); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $object; - } + + if(dao::isError()) return dao::getError(); + + return $object; } /** @@ -131,15 +111,11 @@ class entryTest $objectID = $this->objectModel->create(); unset($_POST); - if(dao::isError()) - { - return dao::getError(); - } - else - { - $object = $this->objectModel->getById($objectID); - return $object; - } + + if(dao::isError()) return dao::getError(); + + $object = $this->objectModel->getById($objectID); + return $object; } /** @@ -172,14 +148,8 @@ class entryTest if($change == array()) $change = '没有数据更新'; unset($_POST); - if(dao::isError()) - { - return dao::getError(); - } - else - { - return $change; - } + if(dao::isError()) return dao::getError(); + return $change; } /** @@ -193,15 +163,11 @@ class entryTest public function updateCalledTimeTest($code, $time) { $this->objectModel->updateCalledTime($code, $time); - if(dao::isError()) - { - return dao::getError(); - } - else - { - $object = $this->objectModel->getByCode($code); - return $object; - } + + if(dao::isError()) return dao::getError(); + + $object = $this->objectModel->getByCode($code); + return $object; } /** @@ -215,17 +181,12 @@ class entryTest public function saveLogTest($entryID, $url) { $this->objectModel->saveLog($entryID, $url); - if(dao::isError()) - { - return dao::getError(); - } - else - { - global $tester; - $object = $tester->dbh->query("SELECT * FROM " . TABLE_LOG ." WHERE objectID = $entryID AND objectType = 'entry'")->fetch(); - return $object; - } + if(dao::isError()) return dao::getError(); + + global $tester; + $object = $tester->dbh->query("SELECT * FROM " . TABLE_LOG ." WHERE objectID = $entryID AND objectType = 'entry'")->fetch(); + return $object; } } diff --git a/test/model/entry/getbyid.php b/test/model/entry/getbyid.php index 7794a439dd..5e83b46f5a 100755 --- a/test/model/entry/getbyid.php +++ b/test/model/entry/getbyid.php @@ -21,8 +21,8 @@ $entryIDList = array('1', '1000001'); $entry = new entryTest(); -r($entry->getByIdTest($entryIDList[0])) && p('name') && e('这是应用名称1'); // 查询id为1的entry的name +r($entry->getByIdTest($entryIDList[0])) && p('name') && e('这是应用名称1'); // 查询id为1的entry的name r($entry->getByIdTest($entryIDList[0])) && p('account') && e('accountadmin'); // 查询id为1的entry的account -r($entry->getByIdTest($entryIDList[1])) && p('name') && e('0'); // 查询id为1000001的entry的name -r($entry->getByIdTest($entryIDList[1])) && p('account') && e('0'); // 查询id为1000001的entry的account +r($entry->getByIdTest($entryIDList[1])) && p('name') && e('0'); // 查询id为1000001的entry的name +r($entry->getByIdTest($entryIDList[1])) && p('account') && e('0'); // 查询id为1000001的entry的account system("./ztest init"); From 400ca9e1f6b1029558d54540a6cfb9b918611c72 Mon Sep 17 00:00:00 2001 From: zhouxin Date: Sat, 7 May 2022 07:32:42 +0000 Subject: [PATCH 41/41] * Add testcase. --- test/api/bugs/browse.php | 2 +- test/class/holiday.class.php | 90 +++++++++++++------ .../holiday/updateprogramplanduration.php | 41 +++++++++ .../holiday/updateprojectrealduration.php | 51 +++++++++++ test/model/holiday/updatetaskplanduration.php | 30 +++++++ 5 files changed, 188 insertions(+), 26 deletions(-) create mode 100755 test/model/holiday/updateprogramplanduration.php create mode 100755 test/model/holiday/updateprojectrealduration.php create mode 100755 test/model/holiday/updatetaskplanduration.php diff --git a/test/api/bugs/browse.php b/test/api/bugs/browse.php index 51c4b57967..35fd5785a9 100644 --- a/test/api/bugs/browse.php +++ b/test/api/bugs/browse.php @@ -129,4 +129,4 @@ r($admin->put($modifyBug2)) && c(200) && p($fields) && e('Bug3'); /* Test delete*/ r($admin->delete($bug->id)) && c(201) && p() && e(''); -r($admin->get($bug->id)) && c(200) && p('bug:deleted') && e('true'); +r($admin->get($bug->id)) && c(200) && p('bug:deleted') && e('true'); \ No newline at end of file diff --git a/test/class/holiday.class.php b/test/class/holiday.class.php index d3c59768ae..f4cd2c1df5 100644 --- a/test/class/holiday.class.php +++ b/test/class/holiday.class.php @@ -10,7 +10,7 @@ class holidayTest /** * Test getById method. * - * @param string $id + * @param int $id * @access public * @return object */ @@ -143,6 +143,14 @@ class holidayTest return $objects; } + /** + * Test getWorkingDays method. + * + * @param string $begin + * @param string $end + * @access public + * @return int + */ public function getWorkingDaysTest($begin, $end) { $objects = $this->objectModel->getWorkingDays($begin, $end); @@ -152,6 +160,14 @@ class holidayTest return count($objects); } + /** + * Test getActualWorkingDays method. + * + * @param string $begin + * @param string $end + * @access public + * @return int + */ public function getActualWorkingDaysTest($begin, $end) { $objects = $this->objectModel->getActualWorkingDays($begin, $end); @@ -213,68 +229,92 @@ class holidayTest /** * Test updateProgramPlanDuration method. * - * @param string $beginDate - * @param string $endDate + * @param int $testProjectID + * @param object $holiday * @access public - * @return object + * @return int */ - public function updateProgramPlanDurationTest($beginDate, $endDate) + public function updateProgramPlanDurationTest($testProjectID, $holidayID) { - $objects = $this->objectModel->updateProgramPlanDuration($beginDate, $endDate); + global $tester; + + $holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch(); + + $this->objectModel->updateProgramPlanDuration($holiday->begin, $holiday->end); + + $project = $tester->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($testProjectID)->fetch(); if(dao::isError()) return dao::getError(); - return $objects; + return $project->planDuration; } /** * Test updateProjectRealDuration method. * - * @param string $beginDate - * @param string $endDate + * @param int $testProjectID + * @param object $holiday * @access public - * @return object + * @return int */ - public function updateProjectRealDurationTest($beginDate, $endDate) + public function updateProjectRealDurationTest($testProjectID, $holidayID) { - $objects = $this->objectModel->updateProjectRealDuration($beginDate, $endDate); + global $tester; + + $holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch(); + + $this->objectModel->updateProjectRealDuration($holiday->begin, $holiday->end); + + $project = $tester->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($testProjectID)->fetch(); if(dao::isError()) return dao::getError(); - return $objects; + return $project->realDuration; } /** * Test updateTaskPlanDuration method. * - * @param string $beginDate - * @param string $endDate + * @param int $testTaskID + * @param object $holiday * @access public - * @return object + * @return int */ - public function updateTaskPlanDurationTest($beginDate, $endDate) + public function updateTaskPlanDurationTest($testTaskID, $holidayID) { - $objects = $this->objectModel->updateTaskPlanDuration($beginDate, $endDate); + global $tester; + + $holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch(); + + $this->objectModel->updateTaskPlanDuration($holiday->begin, $holiday->end); + + $task = $tester->dao->select('*')->from(TABLE_TASK)->where('id')->eq($testTaskID)->fetch(); if(dao::isError()) return dao::getError(); - return $objects; + return $task->planDuration; } /** * Test updateTaskRealDuration method. * - * @param string $beginDate - * @param string $endDate + * @param int $testTaskID + * @param object $holiday * @access public - * @return object + * @return int */ - public function updateTaskRealDurationTest($beginDate, $endDate) + public function updateTaskRealDurationTest($testTaskID, $holidayID) { - $objects = $this->objectModel->updateTaskRealDuration($beginDate, $endDate); + global $tester; + + $holiday = $tester->dao->select('*')->from(TABLE_HOLIDAY)->where('id')->eq($holidayID)->fetch(); + + $this->objectModel->updateTaskRealDuration($holiday->begin, $holiday->end); + + $task = $tester->dao->select('*')->from(TABLE_TASK)->where('id')->eq($testTaskID)->fetch(); if(dao::isError()) return dao::getError(); - return $objects; + return $task->realDuration; } } diff --git a/test/model/holiday/updateprogramplanduration.php b/test/model/holiday/updateprogramplanduration.php new file mode 100755 index 0000000000..bbc2d1eba7 --- /dev/null +++ b/test/model/holiday/updateprogramplanduration.php @@ -0,0 +1,41 @@ +#!/usr/bin/env php +updateProgramPlanDuration(); +cid=1 +pid=1 + +测试插入id为1的节假日时迭代101项目的planDuration >> 59 +测试插入id为3的节假日时迭代101项目的planDuration >> 59 +测试插入id为1的节假日时迭代102项目的planDuration >> 58 +测试插入id为3的节假日时迭代102项目的planDuration >> 58 +测试插入id为1的节假日时迭代750项目的planDuration >> 58 +测试插入id为3的节假日时迭代750项目的planDuration >> 58 +测试插入id为1的节假日时迭代1项目的planDuration >> 59 +测试插入id为3的节假日时迭代1项目的planDuration >> 59 +测试插入id为1的节假日时迭代11项目的planDuration >> 59 +测试插入id为3的节假日时迭代11项目的planDuration >> 59 + +*/ +$holidayIDList = array('1', '3', '99', '100'); + +$holiday = new holidayTest(); + +r($holiday->updateProgramPlanDurationTest(101, $holidayIDList[0])) && p() && e('59'); //测试插入id为1的节假日时迭代101项目的planDuration +r($holiday->updateProgramPlanDurationTest(101, $holidayIDList[1])) && p() && e('59'); //测试插入id为3的节假日时迭代101项目的planDuration +r($holiday->updateProgramPlanDurationTest(102, $holidayIDList[0])) && p() && e('58'); //测试插入id为1的节假日时迭代102项目的planDuration +r($holiday->updateProgramPlanDurationTest(102, $holidayIDList[1])) && p() && e('58'); //测试插入id为3的节假日时迭代102项目的planDuration +r($holiday->updateProgramPlanDurationTest(750, $holidayIDList[0])) && p() && e('58'); //测试插入id为1的节假日时迭代750项目的planDuration +r($holiday->updateProgramPlanDurationTest(750, $holidayIDList[1])) && p() && e('58'); //测试插入id为3的节假日时迭代750项目的planDuration +r($holiday->updateProgramPlanDurationTest(1, $holidayIDList[0])) && p() && e('59'); //测试插入id为1的节假日时迭代1项目的planDuration +r($holiday->updateProgramPlanDurationTest(1, $holidayIDList[1])) && p() && e('59'); //测试插入id为3的节假日时迭代1项目的planDuration +r($holiday->updateProgramPlanDurationTest(11, $holidayIDList[0])) && p() && e('59'); //测试插入id为1的节假日时迭代11项目的planDuration +r($holiday->updateProgramPlanDurationTest(11, $holidayIDList[1])) && p() && e('59'); //测试插入id为3的节假日时迭代11项目的planDuration + +system("./ztest init"); +system("../../ztest init"); \ No newline at end of file diff --git a/test/model/holiday/updateprojectrealduration.php b/test/model/holiday/updateprojectrealduration.php new file mode 100755 index 0000000000..e3da96a16e --- /dev/null +++ b/test/model/holiday/updateprojectrealduration.php @@ -0,0 +1,51 @@ +#!/usr/bin/env php +updateProjectRealDuration(); +cid=1 +pid=1 + +测试新插入holiday1时项目的realDuration字段 >> 29 +测试新插入holiday3时项目的realDuration字段 >> 29 +测试新插入holiday99时项目的realDuration字段 >> 29 +测试新插入holiday100时项目的realDuration字段 >> 29 + +*/ + +$project = new Project(); + +$insertNewProject = array( + 'parent' => 1, + 'name' => '用于测试holiday的项目', + 'budget' => '', + 'budgetUnit' => 'CNY', + 'begin' => '2022-03-07', + 'end' => '2022-03-10', + 'realBegan' => '2022-04-01', + 'realEnd' => '2022-05-01', + 'desc' => '测试项目描述', + 'acl' => 'private', + 'whitelist' => '', + 'PM' => '', + 'products' => array(1), +); + +$newProject = $project->create($insertNewProject); +$newProjectID = $newProject->id; + +$holidayIDList = array('1', '3', '99', '100'); + +$holiday = new holidayTest(); + +r($holiday->updateProjectRealDurationTest($newProjectID, $holidayIDList[0])) && p() && e('29'); //测试新插入holiday1时项目的realDuration字段 +r($holiday->updateProjectRealDurationTest($newProjectID, $holidayIDList[1])) && p() && e('29'); //测试新插入holiday3时项目的realDuration字段 +r($holiday->updateProjectRealDurationTest($newProjectID, $holidayIDList[2])) && p() && e('29'); //测试新插入holiday99时项目的realDuration字段 +r($holiday->updateProjectRealDurationTest($newProjectID, $holidayIDList[3])) && p() && e('29'); //测试新插入holiday100时项目的realDuration字段 + +system("../../ztest init"); \ No newline at end of file diff --git a/test/model/holiday/updatetaskplanduration.php b/test/model/holiday/updatetaskplanduration.php new file mode 100755 index 0000000000..79c8728ae2 --- /dev/null +++ b/test/model/holiday/updatetaskplanduration.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +updateTaskPlanDurationTest(); +cid=1 +pid=1 + +测试插入id为1的holiday时任务1的planDuration >> 6 +测试插入id为3的holiday时任务1的planDuration >> 6 +测试插入id为1的holiday时任务2的planDuration >> 6 +测试插入id为3的holiday时任务2的planDuration >> 6 +测试插入id为1的holiday时任务11的planDuration >> 0 +测试插入id为3的holiday时任务11的planDuration >> 0 + +*/ +$holidayIDList = array('1', '3', '99', '100'); + +$holiday = new holidayTest(); + +r($holiday->updateTaskPlanDurationTest(1, $holidayIDList[0])) && p() && e('6'); //测试插入id为1的holiday时任务1的planDuration +r($holiday->updateTaskPlanDurationTest(1, $holidayIDList[1])) && p() && e('6'); //测试插入id为3的holiday时任务1的planDuration +r($holiday->updateTaskPlanDurationTest(2, $holidayIDList[0])) && p() && e('6'); //测试插入id为1的holiday时任务2的planDuration +r($holiday->updateTaskPlanDurationTest(2, $holidayIDList[1])) && p() && e('6'); //测试插入id为3的holiday时任务2的planDuration +r($holiday->updateTaskPlanDurationTest(11, $holidayIDList[0])) && p() && e('0'); //测试插入id为1的holiday时任务11的planDuration +r($holiday->updateTaskPlanDurationTest(11, $holidayIDList[1])) && p() && e('0'); //测试插入id为3的holiday时任务11的planDuration \ No newline at end of file