Merge branch 'master' into sprint/220
This commit is contained in:
+153
-35
@@ -60,13 +60,13 @@ class testcase extends control
|
||||
else
|
||||
{
|
||||
$mode = ($this->app->methodName == 'create' and empty($this->config->CRProduct)) ? 'noclosed' : '';
|
||||
$products = $this->product->getPairs($mode);
|
||||
$products = $this->product->getPairs($mode, 0, '', 'all');
|
||||
}
|
||||
if(empty($products) and !helper::isAjaxRequest()) return print($this->locate($this->createLink('product', 'showErrorNone', "moduleName=$tab&activeMenu=testcase&objectID=$objectID")));
|
||||
}
|
||||
else
|
||||
{
|
||||
$products = $this->product->getPairs();
|
||||
$products = $this->product->getPairs('', 0, '', 'all');
|
||||
}
|
||||
$this->view->products = $this->products = $products;
|
||||
}
|
||||
@@ -119,6 +119,8 @@ class testcase extends control
|
||||
$linkedProducts = $this->product->getProducts($projectID, 'all', '', false);
|
||||
$this->products = count($linkedProducts) > 1 ? array('0' => $this->lang->product->all) + $linkedProducts : $linkedProducts;
|
||||
$productID = count($linkedProducts) > 1 ? $productID : key($linkedProducts);
|
||||
$hasProduct = $this->dao->findById($projectID)->from(TABLE_PROJECT)->fetch('hasProduct');
|
||||
if(!$hasProduct) unset($this->config->testcase->search['fields']['product']);
|
||||
|
||||
$this->loadModel('project')->setMenu($projectID);
|
||||
}
|
||||
@@ -164,7 +166,8 @@ class testcase extends control
|
||||
$actionURL = $this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID");
|
||||
$this->config->testcase->search['onMenuBar'] = 'yes';
|
||||
|
||||
$this->testcase->buildSearchForm($productID, $this->products, $queryID, $actionURL, $projectID);
|
||||
$searchProducts = $this->product->getPairs('', 0, '', 'all');
|
||||
$this->testcase->buildSearchForm($productID, $searchProducts, $queryID, $actionURL, $projectID);
|
||||
|
||||
$showModule = !empty($this->config->datatable->testcaseBrowse->showModule) ? $this->config->datatable->testcaseBrowse->showModule : '';
|
||||
|
||||
@@ -247,6 +250,7 @@ class testcase extends control
|
||||
{
|
||||
$groupBy = empty($groupBy) ? 'story' : $groupBy;
|
||||
$productID = $this->product->saveState($productID, $this->products);
|
||||
$product = $this->product->getByID($productID);
|
||||
if($branch === '') $branch = $this->cookie->preBranch;
|
||||
|
||||
$this->app->loadLang('testtask');
|
||||
@@ -255,7 +259,7 @@ class testcase extends control
|
||||
if($this->app->tab == 'project')
|
||||
{
|
||||
$products = array('0' => $this->lang->product->all) + $this->product->getProducts($this->session->project, 'all', '', false);
|
||||
$this->lang->modulePageNav = $this->product->select($products, $productID, 'testcase', 'groupCase', "projectID=$projectID", $branch);
|
||||
if(!$product->shadow) $this->lang->modulePageNav = $this->product->select($products, $productID, 'testcase', 'groupCase', $projectID, $branch);
|
||||
}
|
||||
|
||||
$this->session->set('caseList', $this->app->getURI(true), $this->app->tab);
|
||||
@@ -296,8 +300,72 @@ class testcase extends control
|
||||
$this->view->suiteID = 0;
|
||||
$this->view->moduleID = 0;
|
||||
$this->view->branch = $branch;
|
||||
$this->view->product = $this->product->getByID($productID);
|
||||
$this->view->caseType = $caseType;
|
||||
$this->view->product = $product;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show zero case story.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branchID
|
||||
* @param string $orderBy
|
||||
* @param int $projectID
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function zeroCase($productID = 0, $branchID = 0, $orderBy = 'id_desc', $projectID = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
$orderBy = empty($orderBy) ? 'id_desc' : $orderBy;
|
||||
$this->session->set('storyList', $this->app->getURI(true) . '#app=' . $this->app->tab, 'product');
|
||||
$this->session->set('caseList', $this->app->getURI(true), $this->app->tab);
|
||||
|
||||
$this->loadModel('story');
|
||||
if($this->app->tab == 'project')
|
||||
{
|
||||
$this->loadModel('project')->setMenu($this->session->project);
|
||||
$products = $this->product->getProducts($this->session->project, 'all', '', false);
|
||||
$productID = $this->product->saveState($productID, $products);
|
||||
$product = $this->product->getByID($productID);
|
||||
if(!$product->shadow) $this->lang->modulePageNav = $this->product->select($products, $productID, 'testcase', 'zeroCase', $projectID, $branchID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$products = $this->product->getPairs();
|
||||
$productID = $this->product->saveState($productID, $products);
|
||||
$product = $this->product->getByID($productID);
|
||||
$this->loadModel('qa');
|
||||
$this->app->rawModule = 'testcase';
|
||||
foreach($this->config->qa->menuList as $module) $this->lang->navGroup->$module = 'qa';
|
||||
$this->qa->setMenu($products, $productID, $branchID);
|
||||
}
|
||||
|
||||
/* Append id for secend sort. */
|
||||
$sort = common::appendOrder($orderBy);
|
||||
$stories = $this->story->getZeroCase($productID, $branchID, $sort);
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$recTotal = count($stories);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$stories = array_chunk($stories, $pager->recPerPage);
|
||||
|
||||
$this->view->title = $this->lang->story->zeroCase;
|
||||
|
||||
$this->view->stories = empty($stories) ? $stories : $stories[$pageID - 1];
|
||||
$this->view->users = $this->user->getPairs('noletter');
|
||||
$this->view->projectID = $projectID;
|
||||
$this->view->productID = $productID;
|
||||
$this->view->branchID = $branchID;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->suiteList = $this->loadModel('testsuite')->getSuites($productID);
|
||||
$this->view->browseType = '';
|
||||
$this->view->product = $product;
|
||||
$this->view->pager = $pager;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -346,6 +414,7 @@ class testcase extends control
|
||||
|
||||
$this->loadModel('action');
|
||||
$this->action->create('case', $caseID, 'Opened');
|
||||
if($this->testcase->getStatus('create') == 'wait') $this->action->create('case', $caseID, 'submitReview');
|
||||
|
||||
/* If the story is linked project, make the case link the project. */
|
||||
$this->testcase->syncCase2Project($caseResult['caseInfo'], $caseID);
|
||||
@@ -361,8 +430,9 @@ class testcase extends control
|
||||
setcookie('caseModule', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, false);
|
||||
|
||||
/* Use this session link, when the tab is not QA, a session of the case list exists, and the session is not from the Dynamic page. */
|
||||
$useSession = $this->app->tab != 'qa' and $this->session->caseList and strpos($this->session->caseList, 'dynamic') === false;
|
||||
$response['locate'] = $useSession ? $this->session->caseList : $this->createLink('testcase', 'browse', "productID={$this->post->product}&branch={$this->post->branch}&browseType=all¶m=0&orderBy=id_desc");
|
||||
$useSession = ($this->app->tab != 'qa' and $this->session->caseList and strpos($this->session->caseList, 'dynamic') === false);
|
||||
$locateLink = $this->app->tab == 'project' ? $this->createLink('project', 'testcase', "projectID={$this->session->project}") : $this->createLink('testcase', 'browse', "productID={$this->post->product}&branch={$this->post->branch}&browseType=all¶m=0&orderBy=id_desc");
|
||||
$response['locate'] = $useSession ? $this->session->caseList : $locateLink;
|
||||
return $this->send($response);
|
||||
}
|
||||
if(empty($this->products)) $this->locate($this->createLink('product', 'create'));
|
||||
@@ -510,6 +580,7 @@ class testcase extends control
|
||||
$this->view->precondition = $precondition;
|
||||
$this->view->keywords = $keywords;
|
||||
$this->view->steps = $steps;
|
||||
$this->view->hiddenProduct = !empty($product->shadow);
|
||||
$this->view->users = $this->user->getPairs('noletter|noclosed|nodeleted');
|
||||
$this->view->branch = $branch;
|
||||
$this->view->product = $product;
|
||||
@@ -697,13 +768,15 @@ class testcase extends control
|
||||
|
||||
$caseID = (int)$caseID;
|
||||
$case = $this->testcase->getById($caseID, $version);
|
||||
$case = $this->loadModel('story')->checkNeedConfirm($case);
|
||||
|
||||
if(!$case)
|
||||
{
|
||||
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')));
|
||||
}
|
||||
|
||||
$case = $this->loadModel('story')->checkNeedConfirm($case);
|
||||
|
||||
if($from == 'testtask')
|
||||
{
|
||||
$run = $this->loadModel('testtask')->getRunByCase($taskID, $caseID);
|
||||
@@ -772,7 +845,7 @@ class testcase extends control
|
||||
$this->view->caseModule = empty($case->module) ? '' : $this->tree->getById($case->module);
|
||||
$this->view->users = $this->user->getPairs('noletter');
|
||||
$this->view->actions = $this->loadModel('action')->getList('case', $caseID);
|
||||
$this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('testcase', $caseID);
|
||||
$this->view->preAndNext = !isOnlybody() ? $this->loadModel('common')->getPreAndNextObject('testcase', $caseID) : '';
|
||||
$this->view->runID = $from == 'testcase' ? 0 : $run->id;
|
||||
$this->view->isLibCase = $isLibCase;
|
||||
$this->view->caseFails = $caseFails;
|
||||
@@ -794,27 +867,28 @@ class testcase extends control
|
||||
{
|
||||
$this->loadModel('story');
|
||||
|
||||
$case = $this->testcase->getById($caseID);
|
||||
if(!$case) return print(js::error($this->lang->notFound) . js::locate('back'));
|
||||
|
||||
$testtasks = $this->loadModel('testtask')->getGroupByCases($caseID);
|
||||
$testtasks = empty($testtasks[$caseID]) ? array() : $testtasks[$caseID];
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$changes = array();
|
||||
$files = array();
|
||||
if($comment == false or $comment == 'false')
|
||||
{
|
||||
$changes = $this->testcase->update($caseID, $testtasks);
|
||||
if(dao::isError()) return print(js::error(dao::getError()));
|
||||
$files = $this->loadModel('file')->saveUpload('testcase', $caseID);
|
||||
}
|
||||
if($this->post->comment != '' or !empty($changes) or !empty($files))
|
||||
if($this->post->comment != '' or !empty($changes))
|
||||
{
|
||||
$this->loadModel('action');
|
||||
$action = (!empty($changes) or !empty($files)) ? 'Edited' : 'Commented';
|
||||
$fileAction = '';
|
||||
if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n";
|
||||
$actionID = $this->action->create('case', $caseID, $action, $fileAction . $this->post->comment);
|
||||
$action = !empty($changes) ? 'Edited' : 'Commented';
|
||||
$actionID = $this->action->create('case', $caseID, $action, $this->post->comment);
|
||||
$this->action->logHistory($actionID, $changes);
|
||||
|
||||
if($case->status != 'wait' and $this->post->status == 'wait') $this->action->create('case', $caseID, 'submitReview');
|
||||
}
|
||||
|
||||
$this->executeHooks($caseID);
|
||||
@@ -829,8 +903,6 @@ class testcase extends control
|
||||
}
|
||||
}
|
||||
|
||||
$case = $this->testcase->getById($caseID);
|
||||
if(!$case) return print(js::error($this->lang->notFound) . js::locate('back'));
|
||||
if($case->auto == 'unit')
|
||||
{
|
||||
$this->lang->testcase->subMenu->testcase->feature['alias'] = '';
|
||||
@@ -919,13 +991,16 @@ class testcase extends control
|
||||
$moduleIdList = $case->module;
|
||||
if($case->module) $moduleIdList = $this->tree->getAllChildID($case->module);
|
||||
|
||||
$moduleIdList = (!in_array($this->app->tab, array('execution', 'project')) and empty($stories)) ? 0 : $moduleIdList;
|
||||
$stories = $this->story->getProductStoryPairs($productID, $case->branch, $moduleIdList, 'all','id_desc', 0, 'full', 'story', false);
|
||||
|
||||
$this->view->productID = $productID;
|
||||
$this->view->product = $product;
|
||||
$this->view->products = $this->products;
|
||||
$this->view->branchTagOption = $branchTagOption;
|
||||
$this->view->productName = $this->products[$productID];
|
||||
$this->view->moduleOptionMenu = $moduleOptionMenu;
|
||||
$this->view->stories = $this->story->getProductStoryPairs($productID, $case->branch, $moduleIdList, 'all','id_desc', 0, 'full', 'story', false);
|
||||
$this->view->stories = $stories;
|
||||
}
|
||||
$forceNotReview = $this->testcase->forceNotReview();
|
||||
if($forceNotReview) unset($this->lang->testcase->statusList['wait']);
|
||||
@@ -1043,8 +1118,7 @@ class testcase extends control
|
||||
$cases = $this->dao->select('t1.*,t2.id as runID')->from(TABLE_CASE)->alias('t1')
|
||||
->leftJoin(TABLE_TESTRUN)->alias('t2')->on('t1.id = t2.case')
|
||||
->where('t1.deleted')->eq(0)
|
||||
->beginIF($tab == 'my')->andWhere('t2.id')->in($caseIDList)->fi()
|
||||
->beginIF($tab != 'my')->andWhere('t1.id')->in($caseIDList)->fi()
|
||||
->andWhere('t1.id')->in($caseIDList)
|
||||
->fetchAll('id');
|
||||
$caseIDList = array_keys($cases);
|
||||
|
||||
@@ -1311,10 +1385,13 @@ class testcase extends control
|
||||
* @param int $caseID
|
||||
* @param string $browseType
|
||||
* @param int $param
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function linkCases($caseID, $browseType = '', $param = 0)
|
||||
public function linkCases($caseID, $browseType = '', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
/* Get case and queryID. */
|
||||
$case = $this->testcase->getById($caseID);
|
||||
@@ -1328,19 +1405,28 @@ class testcase extends control
|
||||
$objectID = 0;
|
||||
if($this->app->tab == 'project') $objectID = $case->project;
|
||||
if($this->app->tab == 'execution') $objectID = $case->execution;
|
||||
|
||||
unset($this->config->testcase->search['fields']['product']);
|
||||
$this->testcase->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID);
|
||||
|
||||
/* Get cases to link. */
|
||||
$cases2Link = $this->testcase->getCases2Link($caseID, $browseType, $queryID);
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', true);
|
||||
$recTotal = count($cases2Link);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$cases2Link = array_chunk($cases2Link, $pager->recPerPage);
|
||||
|
||||
/* Assign. */
|
||||
$this->view->title = $case->title . $this->lang->colon . $this->lang->testcase->linkCases;
|
||||
$this->view->position[] = html::a($this->createLink('product', 'view', "productID=$case->product"), $this->products[$case->product]);
|
||||
$this->view->position[] = html::a($this->createLink('product', 'view', "productID=$case->product"), zget($this->products, $case->product, ''));
|
||||
$this->view->position[] = html::a($this->createLink('testcase', 'view', "caseID=$caseID"), $case->title);
|
||||
$this->view->position[] = $this->lang->testcase->linkCases;
|
||||
$this->view->case = $case;
|
||||
$this->view->cases2Link = $cases2Link;
|
||||
$this->view->cases2Link = empty($cases2Link) ? $cases2Link : $cases2Link[$pageID - 1];
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->pager = $pager;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -1351,10 +1437,13 @@ class testcase extends control
|
||||
* @param int $caseID
|
||||
* @param string $browseType
|
||||
* @param int $param
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function linkBugs($caseID, $browseType = '', $param = 0)
|
||||
public function linkBugs($caseID, $browseType = '', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
$this->loadModel('bug');
|
||||
|
||||
@@ -1367,16 +1456,32 @@ class testcase extends control
|
||||
$objectID = 0;
|
||||
if($this->app->tab == 'project') $objectID = $case->project;
|
||||
if($this->app->tab == 'execution') $objectID = $case->execution;
|
||||
|
||||
/* Unset search field 'plan' in single project. */
|
||||
unset($this->config->bug->search['fields']['product']);
|
||||
if($case->project and ($this->app->tab == 'project' or $this->app->tab == 'execution'))
|
||||
{
|
||||
$project = $this->loadModel('project')->getById($case->project);
|
||||
if(!$project->hasProduct and $project->model == 'waterfall') unset($this->config->bug->search['fields']['plan']);
|
||||
}
|
||||
|
||||
$this->bug->buildSearchForm($case->product, $this->products, $queryID, $actionURL, $objectID);
|
||||
|
||||
/* Get cases to link. */
|
||||
$bugs2Link = $this->testcase->getBugs2Link($caseID, $browseType, $queryID);
|
||||
|
||||
/* Pager. */
|
||||
$this->app->loadClass('pager', true);
|
||||
$recTotal = count($bugs2Link);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$bugs2Link = array_chunk($bugs2Link, $pager->recPerPage);
|
||||
|
||||
/* Assign. */
|
||||
$this->view->position[] = $this->lang->testcase->linkBugs;
|
||||
$this->view->case = $case;
|
||||
$this->view->bugs2Link = $bugs2Link;
|
||||
$this->view->bugs2Link = empty($bugs2Link) ? $bugs2Link : $bugs2Link[$pageID - 1];
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->pager = $pager;
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -1471,14 +1576,18 @@ class testcase extends control
|
||||
* Confirm story changes.
|
||||
*
|
||||
* @param int $caseID
|
||||
* @param bool $reload
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function confirmStoryChange($caseID,$reload=true)
|
||||
public function confirmStoryChange($caseID, $reload = true)
|
||||
{
|
||||
$case = $this->testcase->getById($caseID);
|
||||
$this->dao->update(TABLE_CASE)->set('storyVersion')->eq($case->latestStoryVersion)->where('id')->eq($caseID)->exec();
|
||||
$this->loadModel('action')->create('case', $caseID, 'confirmed', '', $case->latestStoryVersion);
|
||||
if($case->story)
|
||||
{
|
||||
$this->dao->update(TABLE_CASE)->set('storyVersion')->eq($case->latestStoryVersion)->where('id')->eq($caseID)->exec();
|
||||
$this->loadModel('action')->create('case', $caseID, 'confirmed', '', $case->latestStoryVersion);
|
||||
}
|
||||
if($reload) return print(js::reload('parent'));
|
||||
}
|
||||
|
||||
@@ -1516,8 +1625,19 @@ class testcase extends control
|
||||
$orderBy = '`' . $field . '`_' . $sort;
|
||||
}
|
||||
|
||||
$product = $this->loadModel('product')->getById($productID);
|
||||
if($product->type != 'normal') $this->lang->testcase->branch = $this->lang->product->branchName[$product->type];
|
||||
$product = $this->loadModel('product')->getById($productID);
|
||||
$products = $this->loadModel('product')->getPairs('', 0, '', 'all');
|
||||
if($product->type != 'normal')
|
||||
{
|
||||
$this->lang->testcase->branch = $this->lang->product->branchName[$product->type];
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->config->testcase->exportFields = str_replace('branch,', '', $this->config->testcase->exportFields);
|
||||
}
|
||||
|
||||
if($product->shadow) $this->config->testcase->exportFields = str_replace('product,', '', $this->config->testcase->exportFields);
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
$this->loadModel('file');
|
||||
@@ -1579,7 +1699,6 @@ class testcase extends control
|
||||
|
||||
/* Get users, products and projects. */
|
||||
$users = $this->loadModel('user')->getPairs('noletter');
|
||||
$products = $this->loadModel('product')->getPairs();
|
||||
$branches = $this->loadModel('branch')->getPairs($productID);
|
||||
|
||||
/* Get related objects id lists. */
|
||||
@@ -1719,12 +1838,11 @@ class testcase extends control
|
||||
}
|
||||
|
||||
$fileName = $this->lang->testcase->common;
|
||||
$productName = $this->dao->findById($productID)->from(TABLE_PRODUCT)->fetch('name');
|
||||
$browseType = isset($this->lang->testcase->featureBar['browse'][$browseType]) ? $this->lang->testcase->featureBar['browse'][$browseType] : '';
|
||||
|
||||
if($taskID) $taskName = $this->dao->findById($taskID)->from(TABLE_TESTTASK)->fetch('name');
|
||||
|
||||
$this->view->fileName = $productName . $this->lang->dash . ($taskID ? $taskName . $this->lang->dash : '') . $browseType . $fileName;
|
||||
$this->view->fileName = zget($products, $productID, '') . $this->lang->dash . ($taskID ? $taskName . $this->lang->dash : '') . $browseType . $fileName;
|
||||
$this->view->allExportFields = $this->config->testcase->exportFields;
|
||||
$this->view->customExport = true;
|
||||
$this->display();
|
||||
@@ -1737,7 +1855,7 @@ class testcase extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function exportTemplet($productID)
|
||||
public function exportTemplate($productID)
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user