From 717aad17981d4ae095f35be9eef9dba9ffc71f12 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Fri, 6 May 2022 14:29:23 +0800 Subject: [PATCH 01/14] * 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/14] * 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 11a6f3353ce95cc1b65eef66e3a67494b3b3b289 Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Sat, 7 May 2022 10:32:27 +0800 Subject: [PATCH 03/14] * 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 ba659545554b568cf66475ab66dc764fb0150cdb Mon Sep 17 00:00:00 2001 From: tanghucheng Date: Sat, 7 May 2022 10:42:34 +0800 Subject: [PATCH 04/14] * 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 93fc51fa9a48020afaced373ece1522fd1e61fb1 Mon Sep 17 00:00:00 2001 From: liyang <“liyang@easycorp.ltd”> Date: Sat, 7 May 2022 13:07:28 +0800 Subject: [PATCH 05/14] 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 06/14] * 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 07/14] * 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 08/14] * 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 09/14] * 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 10/14] * 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 11/14] * 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 12/14] * 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 13/14] * 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 14/14] * 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;