From b640578eba52a244bca5aa5acfaa0dbd356e16c8 Mon Sep 17 00:00:00 2001 From: xushenjie Date: Sat, 6 May 2023 07:51:07 +0000 Subject: [PATCH] * Added the todoModel::getPriByTodoType() unit test script. --- module/todo/test/model/getpribytodotype.php | 40 +++++++++++++++++++ .../model/yaml/getpribytodotype/todo.yaml | 35 ++++++++++++++++ module/todo/test/todo.class.php | 34 ++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100755 module/todo/test/model/getpribytodotype.php create mode 100644 module/todo/test/model/yaml/getpribytodotype/todo.yaml diff --git a/module/todo/test/model/getpribytodotype.php b/module/todo/test/model/getpribytodotype.php new file mode 100755 index 0000000000..3f710d44a7 --- /dev/null +++ b/module/todo/test/model/getpribytodotype.php @@ -0,0 +1,40 @@ +#!/usr/bin/env php +config('todo')->gen(10); + zdTable('bug')->gen(10); + zdTable('task')->gen(10); + zdTable('story')->gen(10); + zdTable('testtask')->gen(10); +} + +/** + +title=测试 todoModel->create(); +timeout=0 +cid=1 + +- 执行todoTest模块的getPriByTodoTypeTest方法,参数是$type, $objectID @1 + +- 执行todoTest模块的getPriByTodoTypeTest方法,参数是$inValidType, $inValidObjectID @1 + +*/ + +initData(); + +$validTypeList = array('bug','task','story','testtask'); +$validObjectIdList = array_combine(range(1,10), range(1,10)); +$type = $validTypeList[array_rand($validTypeList, 1)]; +$objectID = $validObjectIdList[array_rand($validObjectIdList, 1)]; +$inValidType = 'invalidType'; +$inValidObjectID = 0; + +$todoTest = new todoTest(); +r($todoTest->getPriByTodoTypeTest($type, $objectID)) && p() && e('1'); +r($todoTest->getPriByTodoTypeTest($inValidType, $inValidObjectID)) && p() && e('1'); diff --git a/module/todo/test/model/yaml/getpribytodotype/todo.yaml b/module/todo/test/model/yaml/getpribytodotype/todo.yaml new file mode 100644 index 0000000000..abeacbb74b --- /dev/null +++ b/module/todo/test/model/yaml/getpribytodotype/todo.yaml @@ -0,0 +1,35 @@ +title: Get pri for todoModel::getPriByTodoType UTC. +desc: Get pri for todoModel::getPriByTodoType UTC. +author: xushenjie +version: 1.0.0 + +fields: + - field: account + range: 'admin' + - field: name + range: 1-10 + prefix: '待办' + - field: date + range: 1-9 + prefix: '2023-05-0' + - field: type + range: 'custom' + - field: begin + range: 1000-1100 + - field: end + range: 1200-1300 + - field: assignedTo + range: 'admin' + - field: desc + range: 1-100 + prefix: '待办描述' + - field: status + range: 'wait,doing,doing,doing,wait' + - field: objectID + range: 0 + - field: assignedBy + range: 'admin' + - field: type + range: 'custom,bug,task,story,testtask' + - field: objectID + range: 1-10 diff --git a/module/todo/test/todo.class.php b/module/todo/test/todo.class.php index 750566487b..c9d9cc4c4f 100755 --- a/module/todo/test/todo.class.php +++ b/module/todo/test/todo.class.php @@ -379,4 +379,38 @@ class todoTest { return $this->objectModel->getByExportList($orderBy, $formData, $queryCondition, $checkedItem); } + + /** + * 获取导出的待办数据。 + * Get data for export todo. + * + * @param string $orderBy + * @param object $formData + * @param string $queryCondition + * @param string $checkedItem + * @access public + * @return array + */ + public function getByExportListTest(string $orderBy, object $formData, string $queryCondition , string $checkedItem): array + { + return $this->objectModel->getByExportList($orderBy, $formData, $queryCondition, $checkedItem); + } + + /** + * 根据待办类型,对象ID获取优先级。 + * Get pri by todo type and object id. + * + * @param string $todoType + * @param int $objectID + * @access public + * @return string + */ + public function getPriByTodoTypeTest(string $todoType, int $objectID): int + { + $pri = $this->objectModel->getPriByTodoType($todoType, $objectID); + + if(dao::isError()) return 0; + + return $pri ? 1 : 0; + } }