- testcaseModel: remove unused methods.
This commit is contained in:
@@ -3165,175 +3165,6 @@ class testcaseModel extends model
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Search cases has scene.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $queryID
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @param int $branch
|
||||
* @param string $auto
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function getBySearchHasScene($productID, $queryID, $orderBy, $pager = null, $branch = 0, $auto = 'no')
|
||||
{
|
||||
if($queryID)
|
||||
{
|
||||
$query = $this->loadModel('search')->getQuery($queryID);
|
||||
if($query)
|
||||
{
|
||||
$this->session->set('testcaseQuery', $query->sql);
|
||||
$this->session->set('testcaseForm', $query->form);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set('testcaseQuery', ' 1 = 1');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->session->testcaseQuery == false) $this->session->set('testcaseQuery', ' 1 = 1');
|
||||
}
|
||||
|
||||
$queryProductID = $productID;
|
||||
$allProduct = "`product` = 'all'";
|
||||
$caseQuery = '(' . $this->session->testcaseQuery;
|
||||
if(strpos($this->session->testcaseQuery, $allProduct) !== false)
|
||||
{
|
||||
$products = $this->app->user->view->products;
|
||||
$caseQuery = str_replace($allProduct, '1', $caseQuery);
|
||||
$caseQuery = $caseQuery . ' AND `product` ' . helper::dbIN($products);
|
||||
$queryProductID = 'all';
|
||||
}
|
||||
|
||||
$allBranch = "`branch` = 'all'";
|
||||
if($branch !== 'all' and strpos($caseQuery, '`branch` =') === false) $caseQuery .= " AND `branch` in('$branch')";
|
||||
if(strpos($caseQuery, $allBranch) !== false) $caseQuery = str_replace($allBranch, '1', $caseQuery);
|
||||
$caseQuery .= ')';
|
||||
$caseQuery = str_replace('`version`', 't1.`version`', $caseQuery);
|
||||
|
||||
if($this->app->tab == 'project') $caseQuery = str_replace('`product`', 't2.`product`', $caseQuery);
|
||||
|
||||
/* Search criteria under compatible project. */
|
||||
$sql = $this->dao->select('*')->from(VIEW_SCENECASE)->alias('t1');
|
||||
if($this->app->tab == 'project') $sql->leftJoin(TABLE_PROJECTCASE)->alias('t2')->on('t1.id=t2.case');
|
||||
$cases = $sql
|
||||
->where($caseQuery)
|
||||
->andWhere('isCase')->eq(1)
|
||||
->beginIF($this->app->tab == 'project')->andWhere('t2.project')->eq($this->session->project)->fi()
|
||||
->beginIF($this->app->tab == 'project' and !empty($productID) and $queryProductID != 'all')->andWhere('t2.product')->eq($productID)->fi()
|
||||
->beginIF($this->app->tab != 'project' and !empty($productID) and $queryProductID != 'all')->andWhere('t1.product')->eq($productID)->fi()
|
||||
->beginIF($auto != 'unit')->andWhere('t1.auto')->ne('unit')->fi()
|
||||
->beginIF($auto == 'unit')->andWhere('t1.auto')->eq('unit')->fi()
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->orderBy($orderBy)->page($pager)->fetchAll('id');
|
||||
|
||||
return $cases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scenes and cases list.
|
||||
*
|
||||
* @param int|array $productID int|array
|
||||
* @param string $branch number|all
|
||||
* @param int $moduleID
|
||||
* @param array $caseIdArr
|
||||
* @param object $pager object|null
|
||||
* @param string $type
|
||||
* @param array $topIdList
|
||||
* @param string $browseType
|
||||
* @param string $executionSql
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getList($productID, $branch, $moduleID, $caseIdArr, $pager = null, $type = '', $topIdList = array(), $browseType = '', &$executionSql = null)
|
||||
{
|
||||
/* Get list of module and its children module. */
|
||||
$modules = $moduleID ? $this->loadModel('tree')->getAllChildId($moduleID) : '0';
|
||||
|
||||
/* Get scenes and all cases in $caseIdArr. */
|
||||
$cases = $this->dao->select('id,path')->from(VIEW_SCENECASE)
|
||||
->where('id')->in($caseIdArr)
|
||||
->beginIF($browseType != 'bysearch')->orWhere('( isCase')->eq(2)->fi()
|
||||
->beginIF($browseType == 'bysearch')->andWhere('( 1')->eq(1)->fi()
|
||||
->beginIF(is_array($productID))->andWhere('product')->in($productID)->fi()
|
||||
->beginIF(!is_array($productID) and intval($productID) > 0)->andWhere('product')->eq($productID)->fi()
|
||||
->beginIF($branch != 'all')->andWhere('branch')->eq($branch)->fi()
|
||||
->beginIF(intval($moduleID) > 0)->andWhere('module')->in($modules)->fi()
|
||||
->markRight(1)
|
||||
->fetchPairs('id','path');
|
||||
|
||||
$sceneIdArr = array();
|
||||
foreach($cases as $path)
|
||||
{
|
||||
$tmpArr = explode(',', trim($path, ','));
|
||||
$sceneIdArr = array_merge($sceneIdArr,$tmpArr);
|
||||
}
|
||||
$sceneIdArr = array_unique($sceneIdArr);
|
||||
|
||||
/* Get path list. */
|
||||
$pathList = $this->dao->select('id,path')->from(VIEW_SCENECASE)
|
||||
->where('deleted')->eq(0)
|
||||
->beginIF(is_array($productID))->andWhere('product')->in($productID)->fi()
|
||||
->beginIF(!is_array($productID) and intval($productID) > 0)->andWhere('product')->eq($productID)->fi()
|
||||
->andWhere('id')->in($sceneIdArr)
|
||||
->beginIF($modules)->andWhere('module')->in($modules)->fi()
|
||||
->beginIF($this->cookie->onlyScene)->andWhere('isCase')->eq(2)->fi()
|
||||
->orderBy('id_asc')
|
||||
->fetchPairs('id');
|
||||
|
||||
/* Get all IDs list. */
|
||||
$objectIdList = array();
|
||||
foreach($pathList as $path)
|
||||
{
|
||||
if($type == 'child' and !empty($topIdList))
|
||||
{
|
||||
$paths = explode(',', trim($path, ','));
|
||||
$topID = $paths[0];
|
||||
|
||||
if(!in_array($topID, $topIdList)) continue;
|
||||
}
|
||||
|
||||
foreach(explode(',', trim($path, ',')) as $pathID) $objectIdList[$pathID] = $pathID;
|
||||
}
|
||||
|
||||
/* Sort by product ID for project list. */
|
||||
$orderBy = 'product_desc,sort_desc';
|
||||
|
||||
/* Get sql for batch execution. */
|
||||
if($executionSql !== null) $executionSql = $this->buildQuery($modules, $type, $objectIdList, $branch)->andWhere('isCase')->eq(1)->orderBy($orderBy)->get();
|
||||
|
||||
return $this->buildQuery($modules, $type, $objectIdList, $branch)->orderBy($orderBy)->page($pager)->fetchAll('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get paginated data with all IDs list.
|
||||
*
|
||||
* @param string $modules
|
||||
* @param string $type
|
||||
* @param string|array $objectIdList
|
||||
* @param string $branch
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
private function buildQuery($modules, $type, $objectIdList, $branch)
|
||||
{
|
||||
$this->dao->reset();
|
||||
$rawMethod = $this->app->rawMethod;
|
||||
$rawModule = $this->app->rawModule;
|
||||
return $this->dao->select('*')->from(VIEW_SCENECASE)
|
||||
->where('deleted')->eq(0)
|
||||
->beginIF($this->cookie->onlyScene)->andWhere('isCase')->eq(2)->fi()
|
||||
->beginIF($modules)->andWhere('module')->in($modules)->fi()
|
||||
->beginIF($rawMethod == 'browse' and $type === 'top')->andWhere('parent')->eq(0)->andWhere('id')->in($objectIdList)->fi()
|
||||
->beginIF($rawMethod == 'browse' and $type === 'child')->andWhere('id')->in($objectIdList)->fi()
|
||||
->beginIF($rawModule == 'project' and $rawMethod == 'testcase' and intval($branch) > 0)->andWhere('branch')->eq($branch)->fi()
|
||||
->beginIF($rawModule == 'project' and $rawMethod == 'testcase' and $type === 'top')->andWhere('parent')->eq(0)->andWhere('id')->in($objectIdList)->fi()
|
||||
->beginIF($rawModule == 'project' and $rawMethod == 'testcase' and $type === 'child')->andWhere('id')->in($objectIdList)->fi();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scene list include sub scenes and cases.
|
||||
*
|
||||
@@ -3538,85 +3369,6 @@ class testcaseModel extends model
|
||||
return $scenePairs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cases which has scene.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param string $browseType
|
||||
* @param int $queryID
|
||||
* @param int $moduleID
|
||||
* @param string $sort
|
||||
* @param object $pager
|
||||
* @param string $auto
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getTestCaseHasScene($productID, $branch, $browseType, $queryID, $moduleID, $sort, $pager, $auto = 'no')
|
||||
{
|
||||
/* Set modules and browse type. */
|
||||
$modules = $moduleID ? $this->loadModel('tree')->getAllChildId($moduleID) : '0';
|
||||
$browseType = ($browseType == 'bymodule' and $this->session->caseBrowseType and $this->session->caseBrowseType != 'bysearch') ? $this->session->caseBrowseType : $browseType;
|
||||
$group = $this->lang->navGroup->testcase;
|
||||
|
||||
/* By module or all cases. */
|
||||
$cases = array();
|
||||
if($browseType == 'bymodule' or $browseType == 'all' or $browseType == 'wait')
|
||||
{
|
||||
if($this->app->tab == 'project')
|
||||
{
|
||||
$cases = $this->getModuleProjectCases($productID, $branch, $modules, $sort, $pager, $browseType, $auto);
|
||||
}
|
||||
else
|
||||
{
|
||||
$cases = $this->getModuleCases($productID, $branch, $modules, $sort, $pager, $browseType, $auto);
|
||||
}
|
||||
}
|
||||
/* Cases need confirmed. */
|
||||
elseif($browseType == 'needconfirm')
|
||||
{
|
||||
$cases = $this->dao->select('distinct t1.*, t2.title AS storyTitle')->from(TABLE_CASE)->alias('t1')
|
||||
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
|
||||
->leftJoin(TABLE_PROJECTCASE)->alias('t3')->on('t1.id = t3.case')
|
||||
->where("t2.status = 'active'")
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->andWhere('t2.version > t1.storyVersion')
|
||||
->beginIF(!empty($productID))->andWhere('t1.product')->eq($productID)->fi()
|
||||
->beginIF($this->app->tab == 'project')->andWhere('t3.project')->eq($this->session->project)->fi()
|
||||
->beginIF($branch !== 'all')->andWhere('t1.branch')->eq($branch)->fi()
|
||||
->beginIF($modules)->andWhere('t1.module')->in($modules)->fi()
|
||||
->beginIF($auto != 'unit')->andWhere('t1.auto')->ne('unit')->fi()
|
||||
->beginIF($auto == 'unit')->andWhere('t1.auto')->eq('unit')->fi()
|
||||
->orderBy($sort)
|
||||
->page($pager, 't1.id')
|
||||
->fetchAll();
|
||||
}
|
||||
elseif($browseType == 'bysuite')
|
||||
{
|
||||
$cases = $this->getBySuite($productID, $branch, $queryID, $modules, $sort, $pager, $auto);
|
||||
}
|
||||
/* By search. */
|
||||
elseif($browseType == 'bysearch')
|
||||
{
|
||||
$cases = $this->getBySearchHasScene($productID, $queryID, $sort, $pager, $branch, $auto);
|
||||
}
|
||||
|
||||
return $cases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Substr string.
|
||||
*
|
||||
* @param string $text
|
||||
* @param int $length
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function istrcut($text, $length)
|
||||
{
|
||||
return (mb_strlen($text, 'utf8') > $length) ? mb_substr($text, 0, $length, 'utf8').'...' : $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print table head.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user