From d4ed8bc18a425850372bd09299bace964caf3e31 Mon Sep 17 00:00:00 2001 From: liyuchun <563917701@qq.com> Date: Tue, 26 Jul 2022 08:41:13 +0000 Subject: [PATCH 1/3] * Code for task #62414. --- module/testcase/control.php | 7 +++-- module/testcase/js/browse.js | 7 +++++ module/testcase/lang/de.php | 4 +++ module/testcase/lang/en.php | 4 +++ module/testcase/lang/fr.php | 4 +++ module/testcase/lang/vi.php | 4 +++ module/testcase/lang/zh-cn.php | 4 +++ module/testcase/model.php | 34 ++++++++++++++++++++++++ module/testcase/view/caseheader.html.php | 28 +++++++++++++++++-- 9 files changed, 92 insertions(+), 4 deletions(-) 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;} '; + } + elseif($hasBrowsePriv and $menuType == 'autocase') + { + if($this->moduleName == 'testtask' and $this->methodName == 'browseunits') continue; + if($this->moduleName == 'story' and $this->methodName == 'zerocase') continue; + if($browseType == 'bysuite' or $browseType == 'bysearch') continue; + + echo html::checkbox('showAutoCase', array('1' => $lang->testcase->showAutoCase), '', $this->cookie->showAutoCase ? 'checked=checked' : ''); } elseif($hasBrowsePriv and ($menuType == 'all' or $menuType == 'needconfirm' or $menuType == 'wait')) { - echo html::a($this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=$menuType"), "{$menuItem->text}", '', "class='btn btn-link' id='{$menuType}Tab' data-app='{$this->app->tab}'"); + echo html::a($this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=$menuType¶m=0&caseType=$caseType"), "{$menuItem->text}", '', "class='btn btn-link' id='{$menuType}Tab' data-app='{$this->app->tab}'"); } elseif($hasBrowsePriv and $menuType == 'suite' and $this->app->tab == 'qa') { @@ -126,7 +145,7 @@ $projectID = $isProjectApp ? $this->session->project : 0; echo html::a($this->createLink('story', 'zeroCase', "productID=$productID&branch=$branch&orderBy=id_desc&projectID=$projectID"), "{$lang->story->zeroCase}", '', "class='btn btn-link' id='zerocaseTab' data-app='{$this->app->tab}'"); } - elseif($hasUnitPriv and $menuType == 'browseunits') + elseif($hasUnitPriv and $menuType == 'browseunits' and !$caseType) { echo html::a($this->createLink('testtask', 'browseUnits', "productID=$productID&browseType=newest&orderBy=id_desc&recTotal=0&recPerPage=20&pageID=1&projectID=$projectID"), "{$lang->testcase->browseUnits}", '', "class='btn btn-link' id='browseunitsTab' data-app='{$this->app->tab}'"); } diff --git a/test/class/testcase.class.php b/test/class/testcase.class.php index 5642b59f97..1ec4634ab4 100644 --- a/test/class/testcase.class.php +++ b/test/class/testcase.class.php @@ -94,19 +94,20 @@ class testcaseTest /** * Test get cases of a module. * - * @param int $productID - * @param int $branch - * @param int $moduleIdList - * @param string $orderBy - * @param object $pager + * @param int $productID + * @param int $branch + * @param int $moduleIdList * @param string $browseType * @param string $auto + * @param string $caseType + * @param string $orderBy + * @param object $pager * @access public * @return array */ - public function getModuleCasesTest($productID, $branch = 0, $moduleIdList = 0, $orderBy = 'id_desc', $pager = null, $browseType = '', $auto = 'no') + public function getModuleCasesTest($productID, $branch = 0, $moduleIdList = 0, $browseType = '', $auto = 'no', $caseType = '', $orderBy = 'id_desc', $pager = null) { - $objects = $this->objectModel->getModuleCases($productID, $branch, $moduleIdList, $orderBy, $pager, $browseType, $auto); + $objects = $this->objectModel->getModuleCases($productID, $branch, $moduleIdList, $browseType, $auto, $caseType, $orderBy, $pager); if(dao::isError()) return dao::getError(); @@ -116,19 +117,20 @@ class testcaseTest /** * Test get project cases of a module. * - * @param int $productID - * @param int $branch - * @param int $moduleIdList - * @param string $orderBy - * @param object $pager + * @param int $productID + * @param int $branch + * @param int $moduleIdList * @param string $browseType * @param string $auto + * @param string $caseType + * @param string $orderBy + * @param object $pager * @access public * @return array */ - public function getModuleProjectCasesTest($productID, $branch = 0, $moduleIdList = 0, $orderBy = 'id_desc', $pager = null, $browseType = '', $auto = 'no') + public function getModuleProjectCasesTest($productID, $branch = 0, $moduleIdList = 0, $browseType = '', $auto = 'no', $caseType = '', $orderBy = 'id_desc', $pager = null) { - $objects = $this->objectModel->getModuleProjectCases($productID, $branch, $moduleIdList, $orderBy, $pager, $browseType, $auto); + $objects = $this->objectModel->getModuleProjectCases($productID, $branch, $moduleIdList, $browseType, $auto, $caseType, $orderBy, $pager); if(dao::isError()) return dao::getError(); @@ -221,7 +223,7 @@ class testcaseTest */ public function getTestCasesTest($productID, $browseType, $queryID, $auto = 'no') { - $objects = $this->objectModel->getTestCases($productID, 0, $browseType, $queryID, $moduleID, 'id_desc', null, $auto); + $objects = $this->objectModel->getTestCases($productID, 0, $browseType, $queryID, $moduleID, '', 'id_desc', null, $auto); if(dao::isError()) return dao::getError();