diff --git a/module/doc/model.php b/module/doc/model.php index b791c28302..f15c872799 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -3870,6 +3870,8 @@ class docModel extends model */ public function delete(string $table, int $id): bool { + if($table != TABLE_DOC) return false; + $this->dao->update($table)->set('deleted')->eq('1')->where('id')->eq($id)->exec(); $doc = $this->getByID($id); diff --git a/module/doc/test/lib/doc.unittest.class.php b/module/doc/test/lib/doc.unittest.class.php index ab828995a9..ab0a3298f7 100644 --- a/module/doc/test/lib/doc.unittest.class.php +++ b/module/doc/test/lib/doc.unittest.class.php @@ -1580,4 +1580,55 @@ class docTest $this->objectModel->batchMoveDoc($docData, $docIdList); return $this->objectModel->dao->select('*')->from(TABLE_DOC)->where('id')->in($docIdList)->fetchAll('id'); } + + /** + * 删除文档。 + * Delete document. + * + * @param string $table + * @param int $id + * @access public + * @return bool + */ + public function deleteTest(string $table, int $id): bool + { + $result = $this->objectModel->delete($table, $id); + if(!$result) return false; + + $deleted = $this->objectModel->dao->select('deleted')->from($table)->where('id')->eq($id)->fetch('deleted'); + return $deleted == 1; + } + + /** + * 更新文档顺序。 + * Update doc order. + * + * @param array $sortedIdList + * @access public + * @return array|bool + */ + public function updateDocOrderTest(array $sortedIdList): array|bool + { + $this->objectModel->updateDocOrder($sortedIdList); + + if(dao::isError()) return dao::getError(); + return $this->objectModel->dao->select('id,`order`')->from(TABLE_DOC)->where('id')->in($sortedIdList)->fetchPairs(); + } + + /** + * 更新文档库顺序。 + * Update doclib order. + * + * @param int $catalogID + * @param int $order + * @access public + * @return int|bool + */ + public function updateDoclibOrderTest(int $id, int $order): int|bool + { + $this->objectModel->updateDoclibOrder($id, $order); + + if(dao::isError()) return dao::getError(); + return $this->objectModel->dao->select('`order`')->from(TABLE_DOCLIB)->where('id')->eq($id)->fetch('order'); + } } diff --git a/module/doc/test/model/delete.php b/module/doc/test/model/delete.php new file mode 100644 index 0000000000..82ecbf862c --- /dev/null +++ b/module/doc/test/model/delete.php @@ -0,0 +1,30 @@ +#!/usr/bin/env php +delete(); +cid=1 + +- 测试删除ID为0的文档 @0 +- 测试删除ID为1的文档 @1 +- 测试删除ID不存在的文档 @0 +- 测试删除表不是文档表且ID为0的文档 @0 +- 测试删除表不是文档表且ID不存在的文档 @0 + +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/doc.unittest.class.php'; + +zenData('doc')->loadYaml('doc')->gen(10); +zenData('user')->gen(5); +su('admin'); + +$tableList = array(TABLE_DOC, TABLE_DOCLIB); +$docIdList = array(0, 1, 11); + +$docTester = new docTest(); +r($docTester->deleteTest($tableList[0], $docIdList[0])) && p() && e('0'); // 测试删除ID为0的文档 +r($docTester->deleteTest($tableList[0], $docIdList[1])) && p() && e('1'); // 测试删除ID为1的文档 +r($docTester->deleteTest($tableList[0], $docIdList[2])) && p() && e('0'); // 测试删除ID不存在的文档 +r($docTester->deleteTest($tableList[1], $docIdList[0])) && p() && e('0'); // 测试删除表不是文档表且ID为0的文档 +r($docTester->deleteTest($tableList[1], $docIdList[2])) && p() && e('0'); // 测试删除表不是文档表且ID不存在的文档 diff --git a/module/doc/test/model/getspaces.php b/module/doc/test/model/getspaces.php new file mode 100644 index 0000000000..1b350bc45e --- /dev/null +++ b/module/doc/test/model/getspaces.php @@ -0,0 +1,38 @@ +#!/usr/bin/env php +getSpaces(); +cid=1 + +- 测试获取不存在类型的空间 @0 +- 测试获取我的空间数据第0条的type属性 @mine +- 测试获取自定义空间数据第0条的type属性 @custom +- 测试获取产品空间数据第0条的type属性 @product +- 测试获取项目空间数据第0条的type属性 @project +- 测试获取执行空间数据第0条的name属性 @迭代5 + +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/doc.unittest.class.php'; + +$docLibData = zenData('doclib')->loadYaml('doclib'); +$docLibData->type->range('mine,custom,product,project,execution'); +$docLibData->parent->range('0'); +$docLibData->gen(10); + +zenData('product')->loadYaml('product')->gen(10); +zenData('project')->loadYaml('execution')->gen(10); +zenData('user')->gen(5); +su('admin'); + +$typeList = array('all', 'mine', 'custom', 'product', 'project', 'execution'); +$spaceIdList = array(0, 1, 2, 3, 4, 101); + +$docTester = new docTest(); +r($docTester->objectModel->getSpaces($typeList[0], $spaceIdList[0])[0]) && p('0') && e('0'); // 测试获取不存在类型的空间 +r($docTester->objectModel->getSpaces($typeList[1], $spaceIdList[1])[0]) && p('0:type') && e('mine'); // 测试获取我的空间数据 +r($docTester->objectModel->getSpaces($typeList[2], $spaceIdList[2])[0]) && p('0:type') && e('custom'); // 测试获取自定义空间数据 +r($docTester->objectModel->getSpaces($typeList[3], $spaceIdList[3])[0]) && p('0:type') && e('product'); // 测试获取产品空间数据 +r($docTester->objectModel->getSpaces($typeList[4], $spaceIdList[4])[0]) && p('0:type') && e('project'); // 测试获取项目空间数据 +r($docTester->objectModel->getSpaces($typeList[5], $spaceIdList[5])[0]) && p('0:name') && e('迭代5'); // 测试获取执行空间数据 diff --git a/module/doc/test/model/updatedocliborder.php b/module/doc/test/model/updatedocliborder.php new file mode 100644 index 0000000000..28abb3e166 --- /dev/null +++ b/module/doc/test/model/updatedocliborder.php @@ -0,0 +1,36 @@ +#!/usr/bin/env php +updateDocLibOrder(); +cid=1 + +- 测试更新ID为0的文档库顺序为2 @0 +- 测试更新ID为1的文档库顺序为5 @5 +- 测试更新ID为2的文档库顺序为1 @1 +- 测试更新ID为3的文档库顺序为10 @10 +- 测试更新ID为4的文档库顺序为7 @7 +- 测试更新ID为5的文档库顺序为9 @9 +- 测试更新ID不存在的文档库顺序为8 @0 + +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/doc.unittest.class.php'; + +$docLibData = zenData('doclib')->loadYaml('doclib'); +$docLibData->order->range('1-5'); +$docLibData->gen(5); +zenData('user')->gen(5); +su('admin'); + +$idList = array(0, 1, 2, 3, 4, 5, 6); +$orderList = array(2, 5, 1, 10, 7, 9, 8); + +$docLibTester = new docTest(); +r($docLibTester->updateDoclibOrderTest($idList[0], $orderList[0])) && p() && e('0'); // 测试更新ID为0的文档库顺序为2 +r($docLibTester->updateDoclibOrderTest($idList[1], $orderList[1])) && p() && e('5'); // 测试更新ID为1的文档库顺序为5 +r($docLibTester->updateDoclibOrderTest($idList[2], $orderList[2])) && p() && e('1'); // 测试更新ID为2的文档库顺序为1 +r($docLibTester->updateDoclibOrderTest($idList[3], $orderList[3])) && p() && e('10'); // 测试更新ID为3的文档库顺序为10 +r($docLibTester->updateDoclibOrderTest($idList[4], $orderList[4])) && p() && e('7'); // 测试更新ID为4的文档库顺序为7 +r($docLibTester->updateDoclibOrderTest($idList[5], $orderList[5])) && p() && e('9'); // 测试更新ID为5的文档库顺序为9 +r($docLibTester->updateDoclibOrderTest($idList[6], $orderList[6])) && p() && e('0'); // 测试更新ID不存在的文档库顺序为8 diff --git a/module/doc/test/model/updatedocorder.php b/module/doc/test/model/updatedocorder.php new file mode 100644 index 0000000000..bfa6d542b4 --- /dev/null +++ b/module/doc/test/model/updatedocorder.php @@ -0,0 +1,42 @@ +#!/usr/bin/env php +updateDocOrder(); +cid=1 + +- 检查ID为1的文档顺序 @3 +- 检查ID为2的文档顺序 @1 +- 检查ID为3的文档顺序 @8 +- 检查ID为4的文档顺序 @9 +- 检查ID为5的文档顺序 @2 +- 检查ID为6的文档顺序 @10 +- 检查ID为7的文档顺序 @5 +- 检查ID为8的文档顺序 @7 +- 检查ID为9的文档顺序 @6 +- 检查ID为10的文档顺序 @4 + +*/ +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/doc.unittest.class.php'; + +$docData = zenData('doc')->loadYaml('doc'); +$docData->order->range('1-10'); +$docData->gen(10); +zenData('user')->gen(5); +su('admin'); + +$sortedIdList = array(2, 5, 1, 10, 7, 9, 8, 3, 4, 6); + +$docTester = new docTest(); +$sortedDocList = $docTester->updateDocOrderTest($sortedIdList); +r($sortedDocList[1]) && p() && e('3'); // 检查ID为1的文档顺序 +r($sortedDocList[2]) && p() && e('1'); // 检查ID为2的文档顺序 +r($sortedDocList[3]) && p() && e('8'); // 检查ID为3的文档顺序 +r($sortedDocList[4]) && p() && e('9'); // 检查ID为4的文档顺序 +r($sortedDocList[5]) && p() && e('2'); // 检查ID为5的文档顺序 +r($sortedDocList[6]) && p() && e('10'); // 检查ID为6的文档顺序 +r($sortedDocList[7]) && p() && e('5'); // 检查ID为7的文档顺序 +r($sortedDocList[8]) && p() && e('7'); // 检查ID为8的文档顺序 +r($sortedDocList[9]) && p() && e('6'); // 检查ID为9的文档顺序 +r($sortedDocList[10]) && p() && e('4'); // 检查ID为10的文档顺序 diff --git a/module/execution/js/batchedit.ui.js b/module/execution/js/batchedit.ui.js index b6a3b5ec97..9360903740 100644 --- a/module/execution/js/batchedit.ui.js +++ b/module/execution/js/batchedit.ui.js @@ -1,26 +1,34 @@ window.renderRowData = function($row, index, row) { - if((row.type == 'stage' || row.attribute != '') && stageList[row.attribute]) + let options = {required: true}; + + if(row.type == 'stage' || row.attribute != '') { + let itemList = []; + let projectModel = 'stage'; + if(stageList[row.attribute] !== undefined) itemList = stageList; + if(ipdTypeList[row.attribute] !== undefined) + { + itemList = ipdTypeList; + projectModel = 'ipd'; + } + const parentType = row.grade > 1 && parents[row.parent] ? parents[row.parent].attribute : ''; /* If is stage, modify lifetime to attribute. */ let stageItems = []; - for(let key in stageList) stageItems.push({value: key, text: stageList[key]}); + for(let key in itemList) stageItems.push({value: key, text: itemList[key]}); - $row.find('[data-name="lifetime"]').find('.picker-box').on('inited', function(e, info) + if(stageItems.length > 0) { - let $attribute = info[0]; - $attribute.render({items: stageItems, required: true, name: 'attribute[' + row.id + ']', disabled: row.grade > 1 && parentType != 'mix'}); - $row.attr('data-parent', row.parent); - }); + options.items = stageItems; + options.name = 'attribute[' + row.id + ']'; + options.disabled = row.grade > 1 && parentType != 'mix'; + if(projectModel == 'ipd') options.disabled = true; + } + $row.attr('data-parent', row.parent); } - $row.find('[data-name="lifetime"]').find('.picker-box').on('inited', function(e, info) - { - let $lifetime = info[0]; - $lifetime.render({required: true}); - }); - + $row.find('[data-name="lifetime"]').find('.picker-box').on('inited', function(e, info) { info[0].render(options); }); $row.find('[data-name="project"]').attr('data-lastselected', row.project).attr('data-execution', row.id); } diff --git a/module/execution/ui/batchedit.html.php b/module/execution/ui/batchedit.html.php index f82a043e4f..f77ec53086 100644 --- a/module/execution/ui/batchedit.html.php +++ b/module/execution/ui/batchedit.html.php @@ -15,6 +15,7 @@ $showMethod = $app->tab == 'project' && isset($project) && ($project->model == ' jsVar('weekend', $config->execution->weekend); jsVar('stageList', $lang->stage->typeList); +jsVar('ipdTypeList', $lang->stage->ipdTypeList); jsVar('confirmSync', $lang->execution->confirmSync); jsVar('noticeChangeAttr', $lang->programplan->noticeChangeAttr); jsVar('parents', $parents); diff --git a/module/execution/zen.php b/module/execution/zen.php index e94c1b11b8..1f88c82b10 100644 --- a/module/execution/zen.php +++ b/module/execution/zen.php @@ -1648,6 +1648,10 @@ class executionZen extends execution { $link = helper::createLink('execution', 'testcase', "executionID=%s"); } + elseif($method == 'createrelation') + { + $link = helper::createLink('execution', 'relation', "executionID=%s"); + } if($type != '') $link .= "&type=$type"; return $link; diff --git a/module/programplan/js/create.ui.js b/module/programplan/js/create.ui.js index 965efd4577..cddd143ac4 100644 --- a/module/programplan/js/create.ui.js +++ b/module/programplan/js/create.ui.js @@ -21,27 +21,23 @@ window.handleClickBatchFormAction = function(action, $row, rowIndex) if(action == 'addSub' && $row.find('td[data-name="id"] input[name^=id]').val() > 0) { const $syncData = $row.find('td[data-name="syncData"] input[name^=syncData]'); - if(!$syncData.hasClass('confirmed') && $syncData.val() == '0') + if($syncData.val() == '0') { - if($syncData.hasClass('requested')) return window.clickToAddRow($this, action, $row, rowIndex); - - $syncData.addClass('requested'); const executionID = $row.find('td[data-name="id"] input[name^=id]').val(); $.get($.createLink('project', 'ajaxCheckHasStageData', `executionID=${executionID}`), function(hasData) { if(!hasData) return window.clickToAddRow($this, action, $row, rowIndex); - $syncData.addClass('confirmed'); zui.Modal.confirm(confirmCreateTip).then((res) => { - if(!res) return $row.find('td[data-name="ACTIONS"] [data-type="addSub"]').attr('disabled', 'disabled').addClass('disabled'); + if(!res) return; $syncData.val('1'); window.clickToAddRow($this, action, $row, rowIndex); }); }); } - else if($syncData.val() == '1') + else { window.clickToAddRow($this, action, $row, rowIndex); } @@ -212,8 +208,11 @@ window.handleRenderRow = function($row, index, data) if(project.model == 'ipd') { - if(planID == 0) $row.find('[data-name="ACTIONS"]').find('[data-type="sort"]').addClass('hidden'); - if(level == 0 && planID == 0) $row.find('[data-name="ACTIONS"]').find('[data-type="addSibling"]').addClass('disabled').prop('disabled', true); + if(planID == 0 && level == 0) + { + $row.find('[data-name="ACTIONS"]').find('[data-type="sort"]').addClass('disabled').prop('disabled', true); + $row.find('[data-name="ACTIONS"]').find('[data-type="addSibling"]').addClass('disabled').prop('disabled', true); + } $row.find('[data-name="attribute"]').find('.picker-box').on('inited', function(e, info){ info[0].render({disabled: true}); }); diff --git a/module/programplan/lang/de.php b/module/programplan/lang/de.php index 6560fd5236..464c22e7a0 100644 --- a/module/programplan/lang/de.php +++ b/module/programplan/lang/de.php @@ -74,6 +74,7 @@ $lang->programplan->enabled = 'Enabling Stage'; $lang->programplan->point = 'Review Point'; $lang->programplan->progress = 'Progress'; +$lang->programplan->relation = 'Manage Task Relation'; $lang->programplan->setTaskRelation = 'Manage Task Relation'; $lang->programplan->viewTaskRelation = 'View Task Relation'; $lang->programplan->createRelation = 'Create Task Relation'; diff --git a/module/programplan/lang/en.php b/module/programplan/lang/en.php index 63c1615de7..09ef59d4fe 100644 --- a/module/programplan/lang/en.php +++ b/module/programplan/lang/en.php @@ -74,6 +74,7 @@ $lang->programplan->enabled = 'Enabling Stage'; $lang->programplan->point = 'Review Point'; $lang->programplan->progress = 'Progress'; +$lang->programplan->relation = 'Manage Task Relation'; $lang->programplan->setTaskRelation = 'Manage Task Relation'; $lang->programplan->viewTaskRelation = 'View Task Relation'; $lang->programplan->createRelation = 'Create Task Relation'; diff --git a/module/programplan/lang/fr.php b/module/programplan/lang/fr.php index b17178ba64..9ce00e7591 100644 --- a/module/programplan/lang/fr.php +++ b/module/programplan/lang/fr.php @@ -74,6 +74,7 @@ $lang->programplan->enabled = 'Enabling Stage'; $lang->programplan->point = 'Review Point'; $lang->programplan->progress = 'Progress'; +$lang->programplan->relation = 'Manage Task Relation'; $lang->programplan->setTaskRelation = 'Manage Task Relation'; $lang->programplan->viewTaskRelation = 'View Task Relation'; $lang->programplan->createRelation = 'Create Task Relation'; diff --git a/module/programplan/lang/zh-cn.php b/module/programplan/lang/zh-cn.php index 3cc71018be..db29dcdfdf 100644 --- a/module/programplan/lang/zh-cn.php +++ b/module/programplan/lang/zh-cn.php @@ -74,6 +74,7 @@ $lang->programplan->enabled = '启用阶段'; $lang->programplan->point = '评审点'; $lang->programplan->progress = '进度'; +$lang->programplan->relation = '维护任务关系'; $lang->programplan->setTaskRelation = '维护任务关系'; $lang->programplan->viewTaskRelation = '浏览任务关系'; $lang->programplan->createRelation = '添加任务关系'; diff --git a/module/programplan/ui/create.html.php b/module/programplan/ui/create.html.php index 8ff1518fcb..4dc7d578c9 100644 --- a/module/programplan/ui/create.html.php +++ b/module/programplan/ui/create.html.php @@ -59,7 +59,7 @@ $fnGenerateStageByProductList = function() use ($productID, $productList, $proje }; /* Generate checkboxes for sub-stage management. */ -$fnGenerateSubPlanManageFields = function() use ($lang, $planID, $project, $executionType, $canParallel) +$fnGenerateSubPlanManageFields = function() use ($lang, $planID, $project, $canParallel) { if(!(empty($planID) && $project->model == 'ipd')) return div(); diff --git a/module/project/ui/execution.html.php b/module/project/ui/execution.html.php index 2334b57284..a0f653e7f3 100644 --- a/module/project/ui/execution.html.php +++ b/module/project/ui/execution.html.php @@ -60,8 +60,8 @@ if($canBatchAction) $fieldList = $config->project->execution->dtable->fieldList; $fieldList['status']['statusMap']['changed'] = $lang->task->storyChange; -/* waterfall & waterfallplus model with different edit link. */ -if(in_array($project->model, array('waterfall', 'waterfallplus'))) +/* waterfall & waterfallplus & ipd model with different edit link. */ +if(in_array($project->model, array('waterfall', 'waterfallplus', 'ipd'))) { $fieldList['actions']['actionsMap']['edit']['data-size'] = 'md'; $fieldList['actions']['actionsMap']['edit']['url'] = createLink('programplan', 'edit', "stageID={rawID}&projectID={projectID}"); diff --git a/module/search/test/lib/search.unittest.class.php b/module/search/test/lib/search.unittest.class.php index d0d5ef9249..39724ddadd 100755 --- a/module/search/test/lib/search.unittest.class.php +++ b/module/search/test/lib/search.unittest.class.php @@ -675,4 +675,48 @@ class searchTest return $dataList; } -} + + /** + * 处理工作。设置内置字段的搜索参数。 + * Process build in fields. + * + * @param string $module + * @access public + * @return array + */ + public function processBuildinFieldsTest(string $module): array + { + global $tester; + $searchConfig = $tester->loadModel($module)->buildSearchConfig(1, 'story'); + $result = $this->objectModel->processBuildinFields('projectStory', $searchConfig); + $resultFields = array_keys($result['fields']); + $resultFields = implode(',', $resultFields); + $result['fields'] = $resultFields; + $result['maxCount'] = $this->objectModel->config->maxCount; + + return $result; + } + + /** + * 设置默认搜索参数配置。 + * Test: set default search params. + * + * @param array $fields + * @param array $params + * @access public + * @return array + */ + public function setDefaultParamsTest(array $fields, array $params): string + { + $_SESSION['project'] = 0; + $_SESSION['searchParams']['module'] = 'bug'; + + $result = $this->objectModel->setDefaultParams($fields, $params); + $field = key($result); + $value = zget($result[$field], 'values', array()); + + $return = implode(',', array_keys($value)); + + return str_replace('@', '', $return); + } +} \ No newline at end of file diff --git a/module/search/test/model/setdefaultparams.php b/module/search/test/model/setdefaultparams.php new file mode 100755 index 0000000000..a767eee065 --- /dev/null +++ b/module/search/test/model/setdefaultparams.php @@ -0,0 +1,44 @@ +#!/usr/bin/env php +setDefaultParams(); +timeout=0 +cid=1 + +*/ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/search.unittest.class.php'; + +zenData('user')->gen(5); +zenData('project')->gen(30); +zenData('projectproduct')->gen(10); +zenData('product')->gen(10); + +su('admin'); + +$fields1 = array('product' => 'product'); +$fields2 = array('assignedTo' => 'assignedTo'); +$fields3 = array('execution' => 'execution'); +$fields4 = array('project' => 'project'); +$fields5 = array('product' => 'product'); +$fields6 = array('product' => 'product'); +$fields7 = array('product' => 'product'); +$params1 = array('product' => array('values' => 'products')); +$params2 = array('assignedTo' => array('values' => 'users')); +$params3 = array('execution' => array('values' => 'executions')); +$params4 = array('project' => array('values' => array())); +$params5 = array('product' => array('values' => array(''))); +$params6 = array('product' => array('values' => array(1))); +$params7 = array('product' => array('values' => array(''), 'nonull' => true)); + +$search = new searchTest(); +r($search->setDefaultParamsTest($fields1, $params1)) && p('0') && e('1,2,3,4,5,6,7,8,9,10,null'); // 测试设置 products 的默认参数 +r($search->setDefaultParamsTest($fields2, $params2)) && p('0') && e('admin,user1,user2,user3,user4,$me,null'); // 测试设置 users 的默认参数 +r($search->setDefaultParamsTest($fields3, $params3)) && p('0') && e(',null'); // 测试设置 executions 的默认参数 +r($search->setDefaultParamsTest($fields4, $params4)) && p('0') && e(',null'); // 测试设置 空数组 的默认参数 +r($search->setDefaultParamsTest($fields5, $params5)) && p('0') && e('0,null'); // 测试设置 空字符串 的默认参数 +r($search->setDefaultParamsTest($fields6, $params6)) && p('0') && e('ZERO'); // 测试设置 array(1) 的默认参数 +r($search->setDefaultParamsTest($fields7, $params7)) && p('0') && e('0'); // 测试设置 nonull 的默认参数 \ No newline at end of file diff --git a/module/search/test/tao/processbuildinfields.php b/module/search/test/tao/processbuildinfields.php new file mode 100755 index 0000000000..722a2e7fb6 --- /dev/null +++ b/module/search/test/tao/processbuildinfields.php @@ -0,0 +1,25 @@ +#!/usr/bin/env php +processBuildinFields() + * + * @title=测试 searchTao->processBuildinFields(); + * @timeout=0 + * @cid=1 + */ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/search.unittest.class.php'; + +su('admin'); + +$search = new searchTest(); + +$moduleList = array('projectStory', 'bug', 'product', 'testcase', 'caselib'); + +r($search->processBuildinFieldsTest($moduleList[0])) && p('module;fields;maxCount', ';') && e('story;title,id,keywords,status,pri,module,stage,grade,plan,estimate,source,sourceNote,fromBug,category,openedBy,reviewedBy,result,assignedTo,closedBy,lastEditedBy,mailto,closedReason,version,openedDate,reviewedDate,assignedDate,closedDate,lastEditedDate,activatedDate;500'); // projectstory +r($search->processBuildinFieldsTest($moduleList[1])) && p('module;fields;maxCount', ';') && e('bug;title,module,keywords,steps,assignedTo,resolvedBy,status,confirmed,story,project,branch,plan,id,execution,severity,pri,type,os,browser,resolution,activatedCount,toTask,toStory,openedBy,closedBy,lastEditedBy,mailto,openedBuild,resolvedBuild,openedDate,assignedDate,resolvedDate,closedDate,lastEditedDate,deadline,activatedDate;500'); // bug +r($search->processBuildinFieldsTest($moduleList[2])) && p('module;fields;maxCount', ';') && e('story;title,id,keywords,status,pri,module,stage,grade,plan,estimate,source,sourceNote,fromBug,category,openedBy,reviewedBy,result,assignedTo,closedBy,lastEditedBy,mailto,closedReason,version,openedDate,reviewedDate,assignedDate,closedDate,lastEditedDate,activatedDate;500'); // product +r($search->processBuildinFieldsTest($moduleList[3])) && p('module;fields;maxCount', ';') && e('testcase;title,story,id,keywords,lastEditedBy,type,auto,openedBy,status,stage,module,pri,lib,lastRunner,lastRunResult,lastRunDate,openedDate,lastEditedDate,scene;500'); // testcase +r($search->processBuildinFieldsTest($moduleList[4])) && p('module;fields;maxCount', ';') && e('caselib;title,story,id,keywords,lastEditedBy,type,auto,openedBy,status,stage,module,pri,openedDate,lastEditedDate;500'); // caselib diff --git a/module/testcase/test/lib/testcase.unittest.class.php b/module/testcase/test/lib/testcase.unittest.class.php index 8310d5eda7..870452c5cf 100755 --- a/module/testcase/test/lib/testcase.unittest.class.php +++ b/module/testcase/test/lib/testcase.unittest.class.php @@ -1911,4 +1911,23 @@ class testcaseTest return $tester->dao->select('*,IF(files = "", 0, files) as files')->from(TABLE_CASESPEC)->where('case')->eq($caseID)->andWhere('version')->eq($case->version)->fetch(); } + + /** + * 测试通过搜索获取执行用例。 + * Test get execution cases by search. + * + * @param int $productID + * @param int $projectID + * @param int $moduleID + * @param int|string $branchID + * @access public + * @return string + */ + public function buildSearchFormTest(int $productID, int $projectID, int $moduleID, int|string $branchID): string + { + $this->objectModel->buildSearchForm($productID, array(), 0, 'actionURL', $projectID, $moduleID, $branchID); + + global $tester; + return implode(',', array_keys($tester->config->testcase->search['fields'])); + } } diff --git a/module/testcase/test/model/buildsearchform.php b/module/testcase/test/model/buildsearchform.php new file mode 100644 index 0000000000..1f69f688d2 --- /dev/null +++ b/module/testcase/test/model/buildsearchform.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +gen('45'); +zenData('branch')->gen('10'); +zenData('project')->gen('30'); +zenData('story')->gen('10'); +zenData('module')->gen('10'); +zenData('user')->gen('1'); + +su('admin'); + +/** + +title=测试 testcaseModel->buildSearchForm(); +cid=1 +pid=1 + +*/ + +$productID = array(0, 1, 41); +$projectID = array(0, 11); +$moduleID = array(0, 1); +$branch = array('all', 0); + +$testcase = new testcaseTest(); + +r($testcase->buildSearchFormTest($productID[0], $projectID[0], $moduleID[0], $branch[0])) && p() && e('title,story,id,keywords,lastEditedBy,type,auto,openedBy,status,product,stage,module,pri,lib,lastRunner,lastRunResult,lastRunDate,openedDate,lastEditedDate,scene'); // 测试构建产品 0 project 0 module 0 branch all 的搜索表单 +r($testcase->buildSearchFormTest($productID[1], $projectID[0], $moduleID[0], $branch[0])) && p() && e('title,story,id,keywords,lastEditedBy,type,auto,openedBy,status,product,stage,module,pri,lib,lastRunner,lastRunResult,lastRunDate,openedDate,lastEditedDate,scene'); // 测试构建产品 1 project 0 module 0 branch all 的搜索表单 +r($testcase->buildSearchFormTest($productID[1], $projectID[1], $moduleID[0], $branch[0])) && p() && e('title,story,id,keywords,lastEditedBy,type,auto,openedBy,status,product,stage,module,pri,lib,lastRunner,lastRunResult,lastRunDate,openedDate,lastEditedDate,scene'); // 测试构建产品 1 project 1 module 0 branch all 的搜索表单 +r($testcase->buildSearchFormTest($productID[1], $projectID[1], $moduleID[1], $branch[0])) && p() && e('title,story,id,keywords,lastEditedBy,type,auto,openedBy,status,product,stage,module,pri,lib,lastRunner,lastRunResult,lastRunDate,openedDate,lastEditedDate,scene'); // 测试构建产品 1 project 1 module 1 branch all 的搜索表单 +r($testcase->buildSearchFormTest($productID[2], $projectID[0], $moduleID[0], $branch[0])) && p() && e('title,story,id,keywords,lastEditedBy,type,auto,openedBy,status,product,stage,module,pri,lib,lastRunner,lastRunResult,lastRunDate,openedDate,lastEditedDate,scene,branch'); // 测试构建产品 41 project 0 module 0 branch 0 的搜索表单 +r($testcase->buildSearchFormTest($productID[2], $projectID[0], $moduleID[0], $branch[1])) && p() && e('title,story,id,keywords,lastEditedBy,type,auto,openedBy,status,product,stage,module,pri,lib,lastRunner,lastRunResult,lastRunDate,openedDate,lastEditedDate,scene,branch'); // 测试构建产品 41 project 0 module 0 branch 0 的搜索表单 \ No newline at end of file diff --git a/module/upgrade/test/model/upgrademydocspace.php b/module/upgrade/test/model/upgrademydocspace.php new file mode 100644 index 0000000000..718f35ae2e --- /dev/null +++ b/module/upgrade/test/model/upgrademydocspace.php @@ -0,0 +1,36 @@ +#!/usr/bin/env php +upgradeMyDocSpace(); +cid=1 + +**/ + +include dirname(__FILE__, 5) . '/test/lib/init.php'; +include dirname(__FILE__, 2) . '/lib/upgrade.unittest.class.php'; + +zenData('doclib')->loadYaml('doclib')->gen(10); + +$upgrade = new upgradeTest(); + +$beforeUpgrade = $tester->dao->select('*')->from('zt_doclib')->where('type')->eq('mine')->fetchAll('id'); + +$upgrade->upgradeMyDocSpace(); + +global $tester; + +$myDocLibs = $tester->dao->select('*')->from('zt_doclib')->where('type')->eq('mine')->fetchAll('id'); + +r(count($beforeUpgrade)) && p() && e(5); // 获取更新前我的文档库数量。 +r(count($myDocLibs)) && p() && e(8); // 获取更新后我的文档库数量。 +r($myDocLibs[6]) && p('id,main,vision,parent') && e('6,0,rnd,11'); // 获取更新后我的文档库 6 的信息 +r($myDocLibs[7]) && p('id,main,vision,parent') && e('7,0,rnd,11'); // 获取更新后我的文档库 6 的信息 +r($myDocLibs[8]) && p('id,main,vision,parent') && e('8,0,or,13'); // 获取更新后我的文档库 6 的信息 +r($myDocLibs[9]) && p('id,main,vision,parent') && e('9,0,or,13'); // 获取更新后我的文档库 6 的信息 +r($myDocLibs[10]) && p('id,main,vision,parent') && e('10,0,lite,12'); // 获取更新后我的文档库 6 的信息 +r($myDocLibs[11]) && p('id,main,vision,parent') && e('11,1,rnd,0'); // 获取更新后我的文档库 6 的信息 +r($myDocLibs[12]) && p('id,main,vision,parent') && e('12,1,lite,0'); // 获取更新后我的文档库 6 的信息 +r($myDocLibs[13]) && p('id,main,vision,parent') && e('13,1,or,0'); // 获取更新后我的文档库 6 的信息 \ No newline at end of file diff --git a/module/upgrade/test/model/yaml/upgrademydocspace/doclib.yaml b/module/upgrade/test/model/yaml/upgrademydocspace/doclib.yaml new file mode 100644 index 0000000000..8548d87848 --- /dev/null +++ b/module/upgrade/test/model/yaml/upgrademydocspace/doclib.yaml @@ -0,0 +1,12 @@ +title: table zt_doclib +author: Mengyi Liu +version: "1.0" +fields: + - field: id + range: 1-100 + - field: type + note: "文档类型" + range: product,project,execution,custom,api,mine{6} + - field: vision + note: "文档类型" + range: rnd{7},or{2},lite{2} \ No newline at end of file