diff --git a/module/testcase/control.php b/module/testcase/control.php index 3af8e4fe59..873b29ebd1 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -110,6 +110,7 @@ class testcase extends control $moduleID = ($browseType == 'bymodule') ? (int)$param : ($browseType == 'bysearch' ? 0 : ($this->cookie->caseModule ? $this->cookie->caseModule : 0)); $suiteID = ($browseType == 'bysuite') ? (int)$param : ($browseType == 'bymodule' ? ($this->cookie->caseSuite ? $this->cookie->caseSuite : 0) : 0); + $caseType = ($browseType == 'bytype') ? $param : ''; $queryID = ($browseType == 'bysearch') ? (int)$param : 0; /* Set menu, save session. */ @@ -142,11 +143,12 @@ class testcase extends control $sort = common::appendOrder($orderBy); /* Get test cases. */ - $cases = $this->testcase->getTestCases($productID, $branch, $browseType, $browseType == 'bysearch' ? $queryID : $suiteID, $moduleID, $sort, $pager); + $browseParam = $browseType == 'bysearch' ? $queryID : ($browseType == 'bysuite' ? $suiteID : $caseType); + $cases = $this->testcase->getTestCases($productID, $branch, $browseType, $browseParam, $moduleID, $sort, $pager); if(empty($cases) and $pageID > 1) { $pager = pager::init(0, $recPerPage, 1); - $cases = $this->testcase->getTestCases($productID, $branch, $browseType, $browseType == 'bysearch' ? $queryID : $suiteID, $moduleID, $sort, $pager); + $cases = $this->testcase->getTestCases($productID, $branch, $browseType, $browseParam, $moduleID, $sort, $pager); } /* save session .*/ @@ -216,6 +218,7 @@ class testcase extends control $this->view->orderBy = $orderBy; $this->view->browseType = $browseType; $this->view->param = $param; + $this->view->caseType = $caseType; $this->view->cases = $cases; $this->view->branch = (!empty($product) and $product->type != 'normal') ? $branch : 0; $this->view->branchOption = $branchOption; diff --git a/module/testcase/js/browse.js b/module/testcase/js/browse.js index 22c7a22f5b..adb0de6b26 100644 --- a/module/testcase/js/browse.js +++ b/module/testcase/js/browse.js @@ -31,5 +31,12 @@ $(function() $('#caseIdList').val(storyIdList); }); }); + + $('input[name^="showAutoCase"]').click(function() + { + var showAutoCase = $(this).is(':checked') ? 1 : 0; + $.cookie('showAutoCase', showAutoCase, {expires:config.cookieLife, path:config.webRoot}); + window.location.reload(); + }); }); diff --git a/module/testcase/lang/de.php b/module/testcase/lang/de.php index 20888cd3c8..a287737ed6 100644 --- a/module/testcase/lang/de.php +++ b/module/testcase/lang/de.php @@ -95,6 +95,9 @@ $lang->testcase->deleted = 'Deleted'; $lang->testcase->browseUnits = 'Unit Test'; $lang->testcase->suite = 'Test Suite'; $lang->testcase->executionStatus = 'executionStatus'; +$lang->testcase->caseType = 'Case Type'; +$lang->testcase->allType = 'All Types'; +$lang->testcase->showAutoCase = 'Show Automated Test Cases'; $lang->case = $lang->testcase; // For dao checking using. Because 'case' is a php keywords, so the module name is testcase, table name is still case. @@ -249,6 +252,7 @@ $lang->testcase->action->unlinkedfromproject = array('main' => '$date, 由 testcase->action->linked2execution = array('main' => '$date, 由 $actor 关联到' . $lang->executionCommon . ' $extra。'); $lang->testcase->action->unlinkedfromexecution = array('main' => '$date, 由 $actor 从' . $lang->executionCommon . ' $extra 移除。'); +$lang->testcase->featureBar['browse']['casetype'] = $lang->testcase->caseType; $lang->testcase->featureBar['browse']['all'] = $lang->testcase->allCases; $lang->testcase->featureBar['browse']['wait'] = 'Wartend'; $lang->testcase->featureBar['browse']['needconfirm'] = $lang->testcase->needConfirm; diff --git a/module/testcase/lang/en.php b/module/testcase/lang/en.php index 98f7e19313..0fce9fedeb 100644 --- a/module/testcase/lang/en.php +++ b/module/testcase/lang/en.php @@ -95,6 +95,9 @@ $lang->testcase->deleted = 'Deleted'; $lang->testcase->browseUnits = 'Unit Test'; $lang->testcase->suite = 'Test Suite'; $lang->testcase->executionStatus = 'executionStatus'; +$lang->testcase->caseType = 'Case Type'; +$lang->testcase->allType = 'All Types'; +$lang->testcase->showAutoCase = 'Show Automated Test Cases'; $lang->case = $lang->testcase; // For dao checking using. Because 'case' is a php keywords, so the module name is testcase, table name is still case. @@ -249,6 +252,7 @@ $lang->testcase->action->unlinkedfromproject = array('main' => '$date, 由 testcase->action->linked2execution = array('main' => '$date, 由 $actor 关联到' . $lang->executionCommon . ' $extra。'); $lang->testcase->action->unlinkedfromexecution = array('main' => '$date, 由 $actor 从' . $lang->executionCommon . ' $extra 移除。'); +$lang->testcase->featureBar['browse']['casetype'] = $lang->testcase->caseType; $lang->testcase->featureBar['browse']['all'] = $lang->testcase->allCases; $lang->testcase->featureBar['browse']['wait'] = 'Waiting'; $lang->testcase->featureBar['browse']['needconfirm'] = $lang->testcase->needConfirm; diff --git a/module/testcase/lang/fr.php b/module/testcase/lang/fr.php index 52d72910af..88ae60d147 100644 --- a/module/testcase/lang/fr.php +++ b/module/testcase/lang/fr.php @@ -95,6 +95,9 @@ $lang->testcase->deleted = 'Deleted'; $lang->testcase->browseUnits = 'Unit Test'; $lang->testcase->suite = 'Test Suite'; $lang->testcase->executionStatus = 'executionStatus'; +$lang->testcase->caseType = 'Case Type'; +$lang->testcase->allType = 'All Types'; +$lang->testcase->showAutoCase = 'Show Automated Test Cases'; $lang->case = $lang->testcase; // For dao checking using. Because 'case' is a php keywords, so the module name is testcase, table name is still case. @@ -249,6 +252,7 @@ $lang->testcase->action->unlinkedfromproject = array('main' => '$date, 由 testcase->action->linked2execution = array('main' => '$date, 由 $actor 关联到' . $lang->executionCommon . ' $extra。'); $lang->testcase->action->unlinkedfromexecution = array('main' => '$date, 由 $actor 从' . $lang->executionCommon . ' $extra 移除。'); +$lang->testcase->featureBar['browse']['casetype'] = $lang->testcase->caseType; $lang->testcase->featureBar['browse']['all'] = $lang->testcase->allCases; $lang->testcase->featureBar['browse']['wait'] = 'En Attente'; $lang->testcase->featureBar['browse']['needconfirm'] = $lang->testcase->needConfirm; diff --git a/module/testcase/lang/vi.php b/module/testcase/lang/vi.php index c94f2630af..530ce56766 100644 --- a/module/testcase/lang/vi.php +++ b/module/testcase/lang/vi.php @@ -75,6 +75,9 @@ $lang->testcase->fromTesttask = 'Từ Yêu cầu Test'; $lang->testcase->fromCaselib = 'Từ thư viện tình huống'; $lang->testcase->deleted = 'Đã xóa'; $lang->testcase->browseUnits = 'Unit Test'; +$lang->testcase->caseType = 'Case Type'; +$lang->testcase->allType = 'All Types'; +$lang->testcase->showAutoCase = 'Show Automated Test Cases'; $lang->case = $lang->testcase; // For dao checking using. Because 'case' is a php keywords, so the module name is testcase, table name is still case. @@ -222,6 +225,7 @@ $lang->testcase->action->unlinkedfromproject = array('main' => '$date, 由 testcase->action->linked2execution = array('main' => '$date, 由 $actor 关联到' . $lang->executionCommon . ' $extra。'); $lang->testcase->action->unlinkedfromexecution = array('main' => '$date, 由 $actor 从' . $lang->executionCommon . ' $extra 移除。'); +$lang->testcase->featureBar['browse']['casetype'] = $lang->testcase->caseType; $lang->testcase->featureBar['browse']['all'] = $lang->testcase->allCases; $lang->testcase->featureBar['browse']['wait'] = 'Đang đợi'; $lang->testcase->featureBar['browse']['needconfirm'] = $lang->testcase->needConfirm; diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php index 5496e40098..a1e811ed05 100644 --- a/module/testcase/lang/zh-cn.php +++ b/module/testcase/lang/zh-cn.php @@ -95,6 +95,9 @@ $lang->testcase->deleted = '是否删除'; $lang->testcase->browseUnits = '单元测试'; $lang->testcase->suite = '套件'; $lang->testcase->executionStatus = '执行状态'; +$lang->testcase->caseType = '用例类型'; +$lang->testcase->allType = '所有类型'; +$lang->testcase->showAutoCase = '显示自动化用例'; $lang->case = $lang->testcase; // 用于DAO检查时使用。因为case是系统关键字,所以无法定义该模块为case,只能使用testcase,但表还是使用的case。 @@ -249,6 +252,7 @@ $lang->testcase->action->unlinkedfromproject = array('main' => '$date, 由 testcase->action->linked2execution = array('main' => '$date, 由 $actor 关联到' . $lang->executionCommon . ' $extra。'); $lang->testcase->action->unlinkedfromexecution = array('main' => '$date, 由 $actor 从' . $lang->executionCommon . ' $extra 移除。'); +$lang->testcase->featureBar['browse']['casetype'] = $lang->testcase->caseType; $lang->testcase->featureBar['browse']['all'] = $lang->testcase->allCases; $lang->testcase->featureBar['browse']['wait'] = '待评审'; $lang->testcase->featureBar['browse']['needconfirm'] = $lang->testcase->needConfirm; diff --git a/module/testcase/model.php b/module/testcase/model.php index 2130aa43ea..fe3523a3e5 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -394,6 +394,35 @@ class testcaseModel extends model ->orderBy($orderBy)->page($pager)->fetchAll('id'); } + /** + * Get cases by type. + * + * @param int $productID + * @param int|string $branch + * @param int $suiteID + * @param array $moduleIdList + * @param string $orderBy + * @param object $pager + * @param string $auto no|unit + * @access public + * @return array + */ + public function getByType($productID, $branch = 0, $type = '', $moduleIdList = 0, $orderBy = 'id_desc', $pager = null, $auto = 'no') + { + return $this->dao->select('t1.*, t2.title as storyTitle')->from(TABLE_CASE)->alias('t1') + ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id') + ->where('t1.product')->eq((int)$productID) + ->beginIF($this->app->tab == 'project')->andWhere('t1.project')->eq($this->session->project)->fi() + ->beginIF($type)->andWhere('t1.type')->eq($type)->fi() + ->beginIF($branch !== 'all')->andWhere('t1.branch')->eq($branch)->fi() + ->beginIF($moduleIdList)->andWhere('t1.module')->in($moduleIdList)->fi() + ->beginIF($auto == 'unit')->andWhere('t1.auto')->eq('unit')->fi() + ->beginIF($auto != 'unit')->andWhere('t1.auto')->ne('unit')->fi() + ->andWhere('t1.deleted')->eq('0') + ->orderBy($orderBy)->page($pager) + ->fetchAll('id'); + } + /** * Get case info by ID. * @@ -495,6 +524,7 @@ class testcaseModel extends model $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; + $auto = $this->cookie->showAutoCase ? 'auto' : $auto; /* By module or all cases. */ $cases = array(); @@ -532,6 +562,10 @@ class testcaseModel extends model { $cases = $this->getBySuite($productID, $branch, $queryID, $modules, $sort, $pager, $auto); } + elseif($browseType == 'bytype') + { + $cases = $this->getByType($productID, $branch, $queryID, $modules, $sort, $pager, $auto); + } /* By search. */ elseif($browseType == 'bysearch') { diff --git a/module/testcase/view/caseheader.html.php b/module/testcase/view/caseheader.html.php index 98f2357687..0f79571b46 100644 --- a/module/testcase/view/caseheader.html.php +++ b/module/testcase/view/caseheader.html.php @@ -13,6 +13,7 @@ .btn-group a.btn-primary {border-right: 1px solid rgba(255,255,255,0.2);} .btn-group button.dropdown-toggle.btn-primary {padding:6px;} .body-modal #mainMenu>.btn-toolbar {width: auto;} +#mainMenu .pull-left .checkbox-primary {margin-top: 5px;}