diff --git a/module/bug/model.php b/module/bug/model.php index bb89d38611..58db3963df 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -1311,7 +1311,7 @@ class bugModel extends model $bugSteps .= !empty($stepResults) && !empty($bugResult) ? str_replace('
', '', $this->lang->bug->tplResult) . $bugResult : $this->lang->bug->tplResult; $bugSteps .= !empty($stepResults) && !empty($bugExpect) ? str_replace('
', '', $this->lang->bug->tplExpect) . $bugExpect : $this->lang->bug->tplExpect; - if(!empty($run->task)) $testtask = $this->loadModel('testtask')->getById($run->task); + if(!empty($run->task)) $testtask = $this->loadModel('testtask')->getByID($run->task); $executionID = isset($testtask->execution) ? $testtask->execution : 0; if(!$executionID and $caseID > 0) $executionID = isset($run->case->execution) ? $run->case->execution : 0; // Fix feedback #1043. diff --git a/module/bug/zen.php b/module/bug/zen.php index a0496d7cb4..0276426318 100644 --- a/module/bug/zen.php +++ b/module/bug/zen.php @@ -2349,7 +2349,7 @@ class bugZen extends bug /* Get buildID from testtask. */ if(isset($testtask) and $testtask) { - $testtask = $this->loadModel('testtask')->getById((int)$testtask); + $testtask = $this->loadModel('testtask')->getByID((int)$testtask); $bug = $this->updateBug($bug, array('buildID' => $testtask->build)); } diff --git a/module/ci/control.php b/module/ci/control.php index bba57cef1b..380e28a4eb 100644 --- a/module/ci/control.php +++ b/module/ci/control.php @@ -137,7 +137,7 @@ class ci extends control /* Get testtaskID or create testtask. */ if(!empty($taskID)) { - $testtask = $this->testtask->getById($taskID); + $testtask = $this->testtask->getByID($taskID); $this->dao->update(TABLE_TESTTASK)->set('auto')->eq(strtolower($testType))->where('id')->eq($taskID)->exec(); $productID = $testtask->product; } diff --git a/module/job/control.php b/module/job/control.php index 546b2f3dd9..f2c43de1f0 100644 --- a/module/job/control.php +++ b/module/job/control.php @@ -316,7 +316,7 @@ class job extends control { $this->app->loadLang('project'); $taskID = $compile->testtask; - $task = $this->loadModel('testtask')->getById($taskID); + $task = $this->loadModel('testtask')->getByID($taskID); $runs = $this->testtask->getRuns($taskID, 0, 'id'); $cases = array(); diff --git a/module/testcase/test/model/batchchangecasemodule.php b/module/testcase/test/model/batchchangecasemodule.php old mode 100644 new mode 100755 diff --git a/module/testreport/control.php b/module/testreport/control.php index 5365ed0537..acc1633be5 100644 --- a/module/testreport/control.php +++ b/module/testreport/control.php @@ -92,7 +92,7 @@ class testreport extends control $objectID = $this->commonAction($objectID, $objectType); $object = $this->$objectType->getById($objectID); - if($extra) $task = $this->testtask->getById($extra); + if($extra) $task = $this->testtask->getByID($extra); $title = $extra ? $task->name : $object->name; @@ -181,7 +181,7 @@ class testreport extends control if(empty($objectID) and $extra) $productID = $extra; if($objectID) { - $task = $this->testtask->getById($objectID); + $task = $this->testtask->getByID($objectID); $productID = $this->commonAction($task->product, 'product'); } @@ -199,7 +199,7 @@ class testreport extends control if(empty($objectID)) { $objectID = key($taskPairs); - $task = $this->testtask->getById($objectID); + $task = $this->testtask->getByID($objectID); $productID = $this->commonAction($task->product, 'product'); } $this->view->taskPairs = $taskPairs; @@ -240,7 +240,7 @@ class testreport extends control $execution = $this->execution->getById($executionID); $tasks = $this->testtask->getExecutionTasks($executionID, $objectType); - $task = $objectID ? $this->testtask->getById($objectID) : key($tasks); + $task = $objectID ? $this->testtask->getByID($objectID) : key($tasks); $owners = array(); $buildIdList = array(); $productIdList = array(); @@ -383,7 +383,7 @@ class testreport extends control { $productIdList[$report->product] = $report->product; - $task = $this->testtask->getById($report->objectID); + $task = $this->testtask->getByID($report->objectID); $execution = $this->execution->getById($task->execution); $builds = array(); if($task->build == 'trunk') @@ -631,7 +631,7 @@ class testreport extends control public function setChartDatas($taskID) { $this->loadModel('report'); - $task = $this->loadModel('testtask')->getById($taskID); + $task = $this->loadModel('testtask')->getByID($taskID); foreach($this->lang->testtask->report->charts as $chart => $title) { if(strpos($chart, 'testTask') === false) continue; diff --git a/module/testtask/control.php b/module/testtask/control.php index 15f7a82d77..7fd7b612c3 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -110,27 +110,27 @@ class testtask extends control $endTime = $endTime ? date('Y-m-d', strtotime($endTime)) : ''; $product = $this->product->getById($productID); if($product->type == 'normal') $branch = 'all'; - $tasks = $this->testtask->getProductTasks($productID, $branch, $type, $beginTime, $endTime, $sort, $pager); + $testtasks = $this->testtask->getProductTasks($productID, $branch, $type, $beginTime, $endTime, $sort, $pager); /* 获取不同状态测试单的数量,用于列表底部统计信息展示。 */ $waitCount = 0; $testingCount = 0; $blockedCount = 0; $doneCount = 0; - foreach($tasks as $key => $task) + foreach($testtasks as $testtask) { - if($task->status == 'wait') $waitCount ++; - if($task->status == 'doing') $testingCount ++; - if($task->status == 'blocked') $blockedCount ++; - if($task->status == 'done') $doneCount ++; - if($task->build == 'trunk' || empty($task->buildName)) $task->buildName = $this->lang->trunk; + if($testtask->status == 'wait') $waitCount ++; + if($testtask->status == 'doing') $testingCount ++; + if($testtask->status == 'blocked') $blockedCount ++; + if($testtask->status == 'done') $doneCount ++; + if($testtask->build == 'trunk' || empty($testtask->buildName)) $testtask->buildName = $this->lang->trunk; } $this->view->title = $products[$productID] . $this->lang->colon . $this->lang->testtask->common; $this->view->productID = $productID; $this->view->product = $product; $this->view->branch = $branch; - $this->view->tasks = $tasks; + $this->view->tasks = $testtasks; $this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter'); $this->view->pager = $pager; $this->view->beginTime = $beginTime; @@ -241,23 +241,23 @@ class testtask extends control } /* 进行测试单数据插入操作。 */ - $taskID = $this->testtask->create($formData); + $testtaskID = $this->testtask->create($formData); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); /* 插入数据后对上传的文件进行处理。 */ - $this->loadModel('file')->updateObjectID($this->post->uid, $taskID, 'testtask'); - $this->file->saveUpload('testtask', $taskID); + $this->loadModel('file')->updateObjectID($this->post->uid, $testtaskID, 'testtask'); + $this->file->saveUpload('testtask', $testtaskID); /* 执行工作流的扩展动作并返回提示消息。 */ - $message = $this->executeHooks($taskID); + $message = $this->executeHooks($testtaskID); if(!$message) $message = $this->lang->saveSuccess; /* 根据不同的应用生成不同的跳转链接。 */ - $task = $this->dao->findById($taskID)->from(TABLE_TESTTASK)->fetch(); - if($this->app->tab == 'project') $link = $this->createLink('project', 'testtask', "projectID=$task->project"); - if($this->app->tab == 'execution') $link = $this->createLink('execution', 'testtask', "executionID=$task->execution"); + $testtask = $this->dao->findById($testtaskID)->from(TABLE_TESTTASK)->fetch(); + if($this->app->tab == 'project') $link = $this->createLink('project', 'testtask', "projectID=$testtask->project"); + if($this->app->tab == 'execution') $link = $this->createLink('execution', 'testtask', "executionID=$testtask->execution"); if($this->app->tab == 'qa') $link = $this->createLink('testtask', 'browse', "productID=" . $this->post->product); - return $this->send(array('result' => 'success', 'message' => $message, 'load' => $link, 'id' => $taskID)); + return $this->send(array('result' => 'success', 'message' => $message, 'load' => $link, 'id' => $testtaskID)); } if($executionID) @@ -281,7 +281,7 @@ class testtask extends control if($this->app->tab == 'execution') $this->loadModel('execution')->setMenu($executionID); if($this->app->tab == 'qa') $this->loadModel('qa')->setMenu($products, $productID); - $this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->create; + $this->view->title = $products[$productID] . $this->lang->colon . $this->lang->testtask->create; $this->view->product = $this->product->getByID($productID); $this->view->projectID = $projectID; $this->view->executionID = $executionID; @@ -294,77 +294,54 @@ class testtask extends control } /** + * 查看当前测试单的概要信息。 * View a test task. * - * @param int $taskID + * @param int $testtaskID * @access public * @return void */ - public function view($taskID) + public function view(int $testtaskID) { - /* Get test task, and set menu. */ - $taskID = (int)$taskID; - $task = $this->testtask->getById($taskID, true); - if(!$task) - { - if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found')); - return print(js::error($this->lang->notFound) . js::locate($this->createLink('qa', 'index'))); - } + /* Get test task. */ + $testtask = $this->testtask->getByID($testtaskID, true); + if(!$testtask) return $this->send(array('result' => 'fail', 'load' => array('alert' => $this->lang->notFound, 'locate' => $this->createLink('qa', 'index')))); /* When the session changes, you need to query the related products again. */ - if($this->session->project != $task->project) $this->view->products = $this->products = $this->product->getProductPairsByProject($task->project); - $this->session->project = $task->project; + $this->loadModel('product'); + $products = $this->testtaskZen->getProducts(); + if($this->session->project != $testtask->project) $products = $this->product->getProductPairsByProject($testtask->project); + $this->session->project = $testtask->project; - $productID = $task->product; - $buildID = $task->build; - - if(!isset($this->products[$productID])) + /* 如果该测试单的所属产品不在products里,则把所属产品塞入到products里。 */ + $productID = $testtask->product; + if(!isset($products[$productID])) { $product = $this->product->getByID($productID); - $this->products[$productID] = $product->name; - } - - $build = $this->loadModel('build')->getByID($buildID); - $stories = array(); - $bugs = array(); - - if($build) - { - $stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($build->stories)->fetchAll(); - $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story'); - - $bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($build->bugs)->fetchAll(); - $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug'); + $products[$productID] = $product->name; } if($this->app->tab == 'project') { - $this->loadModel('project')->setMenu($task->project); - $this->lang->modulePageNav = $this->testtask->select($productID, $taskID, 'project', $task->project); + $this->loadModel('project')->setMenu($testtask->project); + $this->lang->modulePageNav = $this->testtask->select($productID, $testtaskID, 'project', $testtask->project); } - elseif($this->app->tab == 'execution') + if($this->app->tab == 'execution') { - $this->loadModel('execution')->setMenu($task->execution); - $this->lang->modulePageNav = $this->testtask->select($productID, $taskID, 'execution', $task->execution); - } - elseif($this->app->tab == 'qa') - { - $this->testtask->setMenu($this->products, $productID, $task->branch, $taskID); + $this->loadModel('execution')->setMenu($testtask->execution); + $this->lang->modulePageNav = $this->testtask->select($productID, $testtaskID, 'execution', $testtask->execution); } + if($this->app->tab == 'qa') $this->testtask->setMenu($products, $productID, $testtask->branch, $testtaskID); - $this->executeHooks($taskID); + $this->executeHooks($testtaskID); // 执行工作流配置的扩展动作。 - if($task->execution) $this->view->execution = $this->loadModel('project')->getById($task->execution); + if($testtask->execution) $this->view->execution = $this->loadModel('project')->getByID($testtask->execution); - $this->view->title = "TASK #$task->id $task->name/" . $this->products[$productID]; - $this->view->productID = $productID; - $this->view->task = $task; - $this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter'); - $this->view->actions = $this->loadModel('action')->getList('testtask', $taskID); - $this->view->build = $build; - $this->view->testreportTitle = $this->dao->select('title')->from(TABLE_TESTREPORT)->where('id')->eq($task->testreport)->fetch('title'); - $this->view->stories = $stories; - $this->view->bugs = $bugs; + $this->view->title = "TASK #$testtask->id $testtask->name/" . $products[$productID]; + $this->view->task = $testtask; + $this->view->users = $this->loadModel('user')->getPairs('noclosed|noletter'); + $this->view->actions = $this->loadModel('action')->getList('testtask', $testtaskID); + $this->view->testreport = $this->loadModel('testreport')->getById($testtask->testreport); $this->display(); } @@ -378,7 +355,7 @@ class testtask extends control */ public function unitCases($taskID, $orderBy = 'id') { - $task = $this->testtask->getById($taskID); + $task = $this->testtask->getByID($taskID); /* Set browseType, productID, moduleID and queryID. */ $productID = $this->product->saveState($task->product, $this->products); @@ -489,7 +466,7 @@ class testtask extends control $browseType = strtolower($browseType); /* Get task and product info, set menu. */ - $task = $this->testtask->getById($taskID); + $task = $this->testtask->getByID($taskID); if(!$task) return print(js::error($this->lang->testtask->checkLinked) . js::locate('back')); $productID = $task->product; @@ -612,7 +589,7 @@ class testtask extends control $this->loadModel('report'); $this->view->charts = array(); - $task = $this->testtask->getById($taskID); + $task = $this->testtask->getByID($taskID); if(!empty($_POST)) { @@ -684,7 +661,7 @@ class testtask extends control /* Get task and product info, set menu. */ $groupBy = empty($groupBy) ? 'story' : $groupBy; - $task = $this->testtask->getById($taskID); + $task = $this->testtask->getByID($taskID); if(!$task) return print(js::error($this->lang->notFound) . js::locate('back')); $productID = $task->product; @@ -773,7 +750,7 @@ class testtask extends control public function edit($taskID) { /* Get task info. */ - $task = $this->testtask->getById($taskID); + $task = $this->testtask->getByID($taskID); $productID = $this->loadModel('product')->saveState($task->product, $this->products); if(!empty($_POST)) @@ -878,7 +855,7 @@ class testtask extends control } /* Get task info. */ - $testtask = $this->testtask->getById($taskID); + $testtask = $this->testtask->getByID($taskID); $productID = $this->product->saveState($testtask->product, $this->products); /* Set menu. */ @@ -918,7 +895,7 @@ class testtask extends control } /* Get task info. */ - $testtask = $this->testtask->getById($taskID); + $testtask = $this->testtask->getByID($taskID); $productID = $this->product->saveState($testtask->product, $this->products); /* Set menu. */ @@ -958,13 +935,13 @@ class testtask extends control } /* Get task info. */ - $testtask = $this->testtask->getById($taskID); + $testtask = $this->testtask->getByID($taskID); $productID = $this->product->saveState((int)$testtask->product, $this->products); /* Set menu. */ $this->loadModel('qa')->setMenu($this->products, $productID, (string)$testtask->branch, $taskID); - $this->view->testtask = $this->testtask->getById($taskID); + $this->view->testtask = $testtask; $this->view->title = $testtask->name . $this->lang->colon . $this->lang->close; $this->view->actions = $this->loadModel('action')->getList('testtask', $taskID); $this->view->users = $this->loadModel('user')->getPairs('noclosed|nodeleted|qdfirst'); @@ -999,7 +976,7 @@ class testtask extends control } /* Get task info. */ - $testtask = $this->testtask->getById($taskID); + $testtask = $this->testtask->getByID($taskID); $productID = $this->product->saveState($testtask->product, $this->products); /* Set menu. */ @@ -1062,7 +1039,7 @@ class testtask extends control $this->session->set('caseList', $this->app->getURI(true), 'qa'); /* Get task and product id. */ - $task = $this->testtask->getById($taskID); + $task = $this->testtask->getByID($taskID); $productID = $this->product->saveState($task->product, $this->products); $product = $this->product->getByID($productID); diff --git a/module/testtask/model.php b/module/testtask/model.php index e6ae758d61..99216beeed 100755 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -17,7 +17,7 @@ class testtaskModel extends model * 创建一个测试单。 * Create a test task. * - * @param object $testtask + * @param object $testtask * @access public * @return int|false */ @@ -242,49 +242,50 @@ class testtaskModel extends model */ public function getByList($idList) { - return $this->dao->select("*")->from(TABLE_TESTTASK)->where('id')->in($idList)->fetchAll('id'); + return $this->dao->select('*')->from(TABLE_TESTTASK)->where('id')->in($idList)->fetchAll('id'); } /** + * 根据ID获取单条测试单的数据。 * Get test task info by id. * - * @param int $taskID - * @param bool $setImgSize + * @param int $taskID + * @param bool $setImgSize * @access public - * @return void + * @return object|false */ - public function getById($taskID, $setImgSize = false) + public function getByID(int $testtaskID, bool $setImgSize = false): object|false { - $task = $this->dao->select("*")->from(TABLE_TESTTASK)->where('id')->eq((int)$taskID)->fetch(); - if($task) + $testtask = $this->dao->select('*')->from(TABLE_TESTTASK)->where('id')->eq($testtaskID)->fetch(); + if($testtask) { - $product = $this->dao->select('name,type')->from(TABLE_PRODUCT)->where('id')->eq($task->product)->fetch(); - $task->productName = $product->name; - $task->productType = $product->type; - $task->branch = 0; - $task->executionName = ''; - $task->buildName = ''; + $product = $this->dao->select('name,type')->from(TABLE_PRODUCT)->where('id')->eq($testtask->product)->fetch(); + $testtask->productName = $product->name; + $testtask->productType = $product->type; + $testtask->branch = 0; + $testtask->executionName = ''; + $testtask->buildName = ''; - if($task->execution) + if($testtask->execution) { - $task->executionName = $this->dao->select('name')->from(TABLE_EXECUTION)->where('id')->eq($task->execution)->fetch('name'); - $task->branch = $this->dao->select('branch')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($task->execution)->andWhere('product')->eq($task->product)->fetch('branch'); + $testtask->executionName = $this->dao->select('name')->from(TABLE_EXECUTION)->where('id')->eq($testtask->execution)->fetch('name'); + $testtask->branch = $this->dao->select('branch')->from(TABLE_PROJECTPRODUCT)->where('project')->eq($testtask->execution)->andWhere('product')->eq($testtask->product)->fetch('branch'); } - $build = $this->dao->select('branch,name')->from(TABLE_BUILD)->where('id')->eq($task->build)->fetch(); - if($build) + if($testtask->build) { - $task->buildName = $build->name; - $task->branch = $build->branch; + $build = $this->dao->select('branch,name')->from(TABLE_BUILD)->where('id')->eq($testtask->build)->fetch(); + $testtask->buildName = zget($build, 'name', ''); + $testtask->branch = zget($build, 'branch', ''); } } - if(!$task) return false; + if(!$testtask) return false; - $task = $this->loadModel('file')->replaceImgURL($task, 'desc'); - if($setImgSize) $task->desc = $this->loadModel('file')->setImgSize($task->desc); - $task->files = $this->loadModel('file')->getByObject('testtask', $task->id); - return $task; + $testtask = $this->loadModel('file')->replaceImgURL($testtask, 'desc'); + if($setImgSize) $testtask->desc = $this->loadModel('file')->setImgSize($testtask->desc); + $testtask->files = $this->loadModel('file')->getByObject('testtask', $testtask->id); + return $testtask; } /** @@ -751,7 +752,7 @@ class testtaskModel extends model */ public function update($taskID) { - $oldTask = $this->getById($taskID); + $oldTask = $this->getByID($taskID); $task = fixer::input('post') ->add('id', $taskID) ->add('product', $oldTask->product) @@ -788,7 +789,7 @@ class testtaskModel extends model */ public function start($taskID) { - $oldTesttask = $this->getById($taskID); + $oldTesttask = $this->getByID($taskID); $testtask = fixer::input('post') ->add('id', $taskID) ->add('status', 'doing') @@ -814,7 +815,7 @@ class testtaskModel extends model */ public function close($taskID) { - $oldTesttask = $this->getById($taskID); + $oldTesttask = $this->getByID($taskID); $testtask = fixer::input('post') ->add('id', $taskID) ->add('status', 'done') @@ -857,7 +858,7 @@ class testtaskModel extends model */ public function block($taskID) { - $oldTesttask = $this->getById($taskID); + $oldTesttask = $this->getByID($taskID); $testtask = fixer::input('post') ->add('id', $taskID) ->add('status', 'blocked') @@ -883,7 +884,7 @@ class testtaskModel extends model */ public function activate($taskID) { - $oldTesttask = $this->getById($taskID); + $oldTesttask = $this->getByID($taskID); $testtask = fixer::input('post') ->add('status', 'doing') ->stripTags($this->config->testtask->editor->activate['id'], $this->config->allowedTags) @@ -2414,7 +2415,7 @@ class testtaskModel extends model if($taskID and $this->app->viewType != 'mhtml') { - $testtask = $this->getById($taskID); + $testtask = $this->getByID($taskID); $module = $this->app->rawModule; $method = $this->app->rawMethod; $dropMenuLink = helper::createLink('testtask', 'ajaxGetDropMenu', "productID=$productID&branch=$branch&taskID=$taskID&module=$module&method=$method"); @@ -2445,7 +2446,7 @@ class testtaskModel extends model if($testtaskID and $this->app->viewType != 'mhtml') { $dropMenuLink = helper::createLink('testtask', 'ajaxGetDropMenu', "productID=$productID&branch=&taskID=$testtaskID&module=$currentModule&method=$currentMethod&objectType=$objectType&objectID=$objectID"); - $testtask = $this->getById($testtaskID); + $testtask = $this->getByID($testtaskID); $output .= "