diff --git a/api/v1/entries/testcase.php b/api/v1/entries/testcase.php
index 4dc45c1e03..5c8ee647f7 100644
--- a/api/v1/entries/testcase.php
+++ b/api/v1/entries/testcase.php
@@ -46,26 +46,28 @@ class testcaseEntry extends entry
$oldCase = $this->loadModel('testcase')->getByID($caseID);
/* Set $_POST variables. */
- $fields = 'title,pri,story,type,stage,product,module,branch,precondition';
+ $fields = 'title,pri,story,type,stage,product,module,branch,precondition,script';
$this->batchSetPost($fields, $oldCase);
+ if(isset($this->requestBody->script)) $this->setPost('auto', 'auto');
/* Set steps and expects. */
+ $steps = array();
+ $expects = array();
+ $stepType = array();
if(isset($this->requestBody->steps))
{
- $steps = array();
- $expects = array();
- $stepType = array();
foreach($this->requestBody->steps as $step)
{
$steps[] = $step->desc;
$expects[] = $step->expect;
$stepType[] = 'item';
}
- $this->setPost('steps', $steps);
- $this->setPost('expects', $expects);
- $this->setPost('stepType', $stepType);
}
+ $this->setPost('steps', $steps);
+ $this->setPost('expects', $expects);
+ $this->setPost('stepType', $stepType);
+
$control = $this->loadController('testcase', 'edit');
$control->edit($caseID);
diff --git a/config/filter.php b/config/filter.php
index d12e06a8b2..b3073c6041 100755
--- a/config/filter.php
+++ b/config/filter.php
@@ -318,14 +318,16 @@ $filter->execution->export->cookie['checkedItem'] = 'reg::checked';
$filter->execution->kanban->cookie['taskToOpen'] = 'int';
$filter->execution->all->cookie['showExecutionBatchEdit'] = 'int';
-$filter->testcase->browse->cookie['caseModule'] = 'int';
-$filter->testcase->browse->cookie['caseSuite'] = 'int';
-$filter->testcase->browse->cookie['preBranch'] = 'reg::word';
-$filter->testcase->create->cookie['lastCaseModule'] = 'int';
-$filter->testcase->default->cookie['lastProduct'] = 'int';
-$filter->testcase->default->cookie['preProductID'] = 'int';
-$filter->testcase->export->cookie['checkedItem'] = 'reg::checked';
-$filter->testcase->groupcase->cookie['preBranch'] = 'reg::word';
+$filter->testcase->browse->cookie['caseModule'] = 'int';
+$filter->testcase->browse->cookie['caseSuite'] = 'int';
+$filter->testcase->browse->cookie['preBranch'] = 'reg::word';
+$filter->testcase->browse->cookie['showAutoCase'] = 'int';
+$filter->testcase->create->cookie['lastCaseModule'] = 'int';
+$filter->testcase->default->cookie['lastProduct'] = 'int';
+$filter->testcase->default->cookie['preProductID'] = 'int';
+$filter->testcase->export->cookie['checkedItem'] = 'reg::checked';
+$filter->testcase->groupcase->cookie['preBranch'] = 'reg::word';
+$filter->testcase->groupcase->cookie['showAutoCase'] = 'int';
$filter->testreport->default->cookie['lastProduct'] = 'int';
$filter->testreport->default->cookie['lastProject'] = 'int';
diff --git a/db/update17.8.sql b/db/update17.8.sql
index 62dd3545a3..cbebf84955 100644
--- a/db/update17.8.sql
+++ b/db/update17.8.sql
@@ -1,3 +1,4 @@
+ALTER TABLE `zt_case` ADD `script` longtext NOT NULL AFTER `howRun`;
ALTER TABLE `zt_product` ADD `shadow` tinyint(1) unsigned NOT NULL AFTER `code`;
ALTER TABLE `zt_project` ADD `hasProduct` tinyint(1) unsigned NOT NULL DEFAULT 1 AFTER `code`;
ALTER table `zt_project` ADD `multiple` enum('0', '1') NOT NULL DEFAULT '1' AFTER `fluidBoard`;
diff --git a/module/group/lang/resource.php b/module/group/lang/resource.php
index d4f6c8db68..7b1f700c0e 100644
--- a/module/group/lang/resource.php
+++ b/module/group/lang/resource.php
@@ -1052,6 +1052,7 @@ $lang->resource->testcase->batchCreate = 'batchCreate';
$lang->resource->testcase->createBug = 'createBug';
$lang->resource->testcase->view = 'view';
$lang->resource->testcase->edit = 'edit';
+$lang->resource->testcase->showScript = 'showScript';
$lang->resource->testcase->linkCases = 'linkCases';
$lang->resource->testcase->linkBugs = 'linkBugs';
$lang->resource->testcase->batchEdit = 'batchEdit';
@@ -1106,6 +1107,7 @@ $lang->testcase->methodOrder[130] = 'ignoreLibcaseChange';
$lang->testcase->methodOrder[135] = 'batchConfirmStoryChange';
$lang->testcase->methodOrder[140] = 'importToLib';
$lang->testcase->methodOrder[145] = 'automation';
+$lang->testcase->methodOrder[150] = 'showScript';
/* Test task. */
$lang->resource->testtask = new stdclass();
diff --git a/module/project/control.php b/module/project/control.php
index 29463c7bb3..1886938275 100755
--- a/module/project/control.php
+++ b/module/project/control.php
@@ -1329,7 +1329,7 @@ class project extends control
$hasProduct = $this->dao->findByID($projectID)->from(TABLE_PROJECT)->fetch('hasProduct');
if($hasProduct) $this->lang->modulePageNav = $this->product->select($products, $productID, 'project', 'testcase', $extra, $branch);
- echo $this->fetch('testcase', 'browse', "productID=$productID&branch=$branch&browseType=$browseType¶m=$param&orderBy=$orderBy&recTotal=$orderBy&recPerPage=$recPerPage&pageID=$pageID&projectID=$projectID");
+ echo $this->fetch('testcase', 'browse', "productID=$productID&branch=$branch&browseType=$browseType¶m=$param&caseType=&orderBy=$orderBy&recTotal=$orderBy&recPerPage=$recPerPage&pageID=$pageID&projectID=$projectID");
}
/**
diff --git a/module/testcase/config.php b/module/testcase/config.php
index 4c1d5d936e..26acbca266 100644
--- a/module/testcase/config.php
+++ b/module/testcase/config.php
@@ -230,6 +230,6 @@ $config->testcase->datatable->fieldList['stepNumber']['name'] = $lang->testc
$config->testcase->datatable->fieldList['actions']['title'] = 'actions';
$config->testcase->datatable->fieldList['actions']['fixed'] = 'right';
-$config->testcase->datatable->fieldList['actions']['width'] = '150';
+$config->testcase->datatable->fieldList['actions']['width'] = '180';
$config->testcase->datatable->fieldList['actions']['required'] = 'yes';
$config->testcase->datatable->fieldList['actions']['sort'] = 'no';
diff --git a/module/testcase/control.php b/module/testcase/control.php
index 6f374f38ba..d6f9cbf31b 100644
--- a/module/testcase/control.php
+++ b/module/testcase/control.php
@@ -78,6 +78,7 @@ class testcase extends control
* @param int|string $branch
* @param string $browseType
* @param int $param
+ * @param string $caseType
* @param string $orderBy
* @param int $recTotal
* @param int $recPerPage
@@ -86,7 +87,7 @@ class testcase extends control
* @access public
* @return void
*/
- public function browse($productID = 0, $branch = '', $browseType = 'all', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1, $projectID = 0)
+ public function browse($productID = 0, $branch = '', $browseType = 'all', $param = 0, $caseType = '', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1, $projectID = 0)
{
$this->loadModel('datatable');
$this->app->loadLang('zanode');
@@ -145,11 +146,11 @@ 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);
+ $cases = $this->testcase->getTestCases($productID, $branch, $browseType, $browseType == 'bysearch' ? $queryID : $suiteID, $moduleID, $caseType, $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, $browseType == 'bysearch' ? $queryID : $suiteID, $moduleID, $caseType, $sort, $pager);
}
/* save session .*/
@@ -220,6 +221,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;
@@ -238,11 +240,14 @@ class testcase extends control
* Group case.
*
* @param int $productID
+ * @param string $branch
* @param string $groupBy
+ * @param int $projectID
+ * @param string $caseType
* @access public
* @return void
*/
- public function groupCase($productID = 0, $branch = '', $groupBy = 'story', $projectID = 0)
+ public function groupCase($productID = 0, $branch = '', $groupBy = 'story', $projectID = 0, $caseType = '')
{
$groupBy = empty($groupBy) ? 'story' : $groupBy;
$productID = $this->product->saveState($productID, $this->products);
@@ -260,7 +265,7 @@ class testcase extends control
$this->session->set('caseList', $this->app->getURI(true), $this->app->tab);
- $cases = $this->testcase->getModuleCases($productID, $branch, 0, $groupBy);
+ $cases = $this->testcase->getModuleCases($productID, $branch, 0, '', 'no', $caseType, $groupBy);
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', false);
$cases = $this->loadModel('story')->checkNeedConfirm($cases);
$cases = $this->testcase->appendData($cases);
@@ -296,6 +301,7 @@ class testcase extends control
$this->view->suiteID = 0;
$this->view->moduleID = 0;
$this->view->branch = $branch;
+ $this->view->caseType = $caseType;
$this->view->product = $product;
$this->display();
}
@@ -620,7 +626,7 @@ class testcase extends control
$currentModule = $this->app->tab == 'project' ? 'project' : 'testcase';
$currentMethod = $this->app->tab == 'project' ? 'testcase' : 'browse';
$projectParam = $this->app->tab == 'project' ? "projectID={$this->session->project}&" : '';
- return print(js::locate($this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=all¶m=0&orderBy=id_desc"), 'parent'));
+ return print(js::locate($this->createLink($currentModule, $currentMethod, $projectParam . "productID=$productID&branch=$branch&browseType=all¶m=0&caseType=&orderBy=id_desc"), 'parent'));
}
if(empty($this->products)) $this->locate($this->createLink('product', 'create'));
@@ -2350,6 +2356,19 @@ class testcase extends control
$this->display();
}
+ /**
+ * Show script.
+ *
+ * @param int $caseID
+ * @access public
+ * @return void
+ */
+ public function showScript($caseID)
+ {
+ $this->view->case = $this->testcase->getByID($caseID);
+ $this->display();
+ }
+
/**
* Automation test setting.
*
diff --git a/module/testcase/css/showscript.css b/module/testcase/css/showscript.css
new file mode 100644
index 0000000000..3d4f16e6b9
--- /dev/null
+++ b/module/testcase/css/showscript.css
@@ -0,0 +1,3 @@
+.repoCode pre {margin: 0; padding: 0; background: white; border: none;}
+.repoCode pre > table > tbody > tr > th, .repoCode pre > table > tbody > tr > td {padding: 1px 3px;}
+.repoCode pre > table > tbody > tr > th {border-right: 1px solid #E4E4E4; background: #fafafa; color: #999; width: 40px; text-align: right; vertical-align: top;}
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/js/groupcase.js b/module/testcase/js/groupcase.js
index e69de29bb2..4eb3535d5b 100644
--- a/module/testcase/js/groupcase.js
+++ b/module/testcase/js/groupcase.js
@@ -0,0 +1,9 @@
+$(function()
+{
+ $('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/js/showscript.js b/module/testcase/js/showscript.js
new file mode 100644
index 0000000000..1280979a67
--- /dev/null
+++ b/module/testcase/js/showscript.js
@@ -0,0 +1,20 @@
+$(document).ready(function()
+{
+ var $pre = $('.repoCode .content pre');
+ var rowTip = '';
+ if($('#rowTip').length > 0) rowTip = $('#rowTip').html();
+
+ if($pre.length)
+ {
+ hljs.initHighlightingOnLoad();
+ var content = hljs.highlight($pre.attr('class'), $pre.text());
+ var code = '', line;
+ var arr = content.value.split(/\r\n|[\n\v\f\r\x85\u2028\u2029]/);
+ for(var i = 0 ; i < arr.length ; i++)
+ {
+ line = i + 1;
+ code += "
| " + line + " | " + (arr[i] || ' ') + rowTip + " |
";
+ }
+ $pre.html("");
+ }
+});
diff --git a/module/testcase/lang/de.php b/module/testcase/lang/de.php
index 19b7eb7620..53db8e5900 100644
--- a/module/testcase/lang/de.php
+++ b/module/testcase/lang/de.php
@@ -97,6 +97,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.
@@ -147,6 +150,7 @@ $lang->testcase->step = 'Schritt';
$lang->testcase->stepChild = 'Teilschritt';
$lang->testcase->viewAll = 'Alle anziegen';
$lang->testcase->importToLib = "Import To Library";
+$lang->testcase->showScript = 'Show Script';
$lang->testcase->new = 'Neu';
@@ -252,11 +256,13 @@ $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;
$lang->testcase->featureBar['browse']['group'] = 'Group View';
$lang->testcase->featureBar['browse']['zerocase'] = 'Zero Case Story';
$lang->testcase->featureBar['browse']['browseunits'] = 'Unit Test';
+$lang->testcase->featureBar['browse']['autocase'] = $lang->testcase->showAutoCase;
$lang->testcase->featureBar['browse']['suite'] = 'Suite';
$lang->testcase->featureBar['groupcase'] = $lang->testcase->featureBar['browse'];
diff --git a/module/testcase/lang/en.php b/module/testcase/lang/en.php
index 6f0f6d4ea4..834bcb794c 100644
--- a/module/testcase/lang/en.php
+++ b/module/testcase/lang/en.php
@@ -97,6 +97,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.
@@ -147,6 +150,7 @@ $lang->testcase->step = 'Steps';
$lang->testcase->stepChild = 'Child Steps';
$lang->testcase->viewAll = 'All Cases';
$lang->testcase->importToLib = "Import To Library";
+$lang->testcase->showScript = 'Show Script';
$lang->testcase->new = 'New';
@@ -252,11 +256,13 @@ $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;
$lang->testcase->featureBar['browse']['group'] = 'Group View';
$lang->testcase->featureBar['browse']['zerocase'] = 'Zero Case Story';
$lang->testcase->featureBar['browse']['browseunits'] = 'Unit Test';
+$lang->testcase->featureBar['browse']['autocase'] = $lang->testcase->showAutoCase;
$lang->testcase->featureBar['browse']['suite'] = 'Suite';
$lang->testcase->featureBar['groupcase'] = $lang->testcase->featureBar['browse'];
diff --git a/module/testcase/lang/fr.php b/module/testcase/lang/fr.php
index 655b02debd..1710177707 100644
--- a/module/testcase/lang/fr.php
+++ b/module/testcase/lang/fr.php
@@ -97,6 +97,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.
@@ -147,6 +150,7 @@ $lang->testcase->step = 'Etapes';
$lang->testcase->stepChild = 'Sous-Etapes';
$lang->testcase->viewAll = 'Tous les CasTests';
$lang->testcase->importToLib = "Import To Library";
+$lang->testcase->showScript = 'Show Script';
$lang->testcase->new = 'Nouveau';
@@ -252,11 +256,13 @@ $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;
$lang->testcase->featureBar['browse']['group'] = 'Group View';
$lang->testcase->featureBar['browse']['zerocase'] = 'Zero Case Story';
$lang->testcase->featureBar['browse']['browseunits'] = 'Unit Test';
+$lang->testcase->featureBar['browse']['autocase'] = $lang->testcase->showAutoCase;
$lang->testcase->featureBar['browse']['suite'] = 'Suite';
$lang->testcase->featureBar['groupcase'] = $lang->testcase->featureBar['browse'];
diff --git a/module/testcase/lang/vi.php b/module/testcase/lang/vi.php
index bcd797fd58..6c65b92494 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.
@@ -123,6 +126,7 @@ $lang->testcase->groupName = 'Tên nhóm';
$lang->testcase->step = 'Các bước';
$lang->testcase->stepChild = 'Các bước con';
$lang->testcase->viewAll = 'Tất cả tình huống';
+$lang->testcase->showScript = 'Show Script';
$lang->testcase->new = 'Mới';
@@ -222,6 +226,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;
@@ -229,4 +234,5 @@ $lang->testcase->featureBar['browse']['group'] = 'Group View';
$lang->testcase->featureBar['browse']['suite'] = 'Suite';
$lang->testcase->featureBar['browse']['zerocase'] = 'Zero Case Story';
$lang->testcase->featureBar['browse']['browseunits'] = 'Unit Test';
+$lang->testcase->featureBar['browse']['autocase'] = $lang->testcase->showAutoCase;
$lang->testcase->featureBar['groupcase'] = $lang->testcase->featureBar['browse'];
diff --git a/module/testcase/lang/zh-cn.php b/module/testcase/lang/zh-cn.php
index 03ba675e2d..a95b6a8290 100644
--- a/module/testcase/lang/zh-cn.php
+++ b/module/testcase/lang/zh-cn.php
@@ -97,6 +97,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。
@@ -146,7 +149,8 @@ $lang->testcase->groupName = '分组名称';
$lang->testcase->step = '步骤';
$lang->testcase->stepChild = '子步骤';
$lang->testcase->viewAll = '查看所有';
-$lang->testcase->importToLib = "导入用例库";
+$lang->testcase->importToLib = '导入用例库';
+$lang->testcase->showScript = '查看自动化脚本';
$lang->testcase->new = '新增';
@@ -252,11 +256,13 @@ $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']['all'] = '全部';
+$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;
$lang->testcase->featureBar['browse']['group'] = '分组查看';
$lang->testcase->featureBar['browse']['zerocase'] = "零用例{$lang->SRCommon}";
$lang->testcase->featureBar['browse']['browseunits'] = '单元测试';
+$lang->testcase->featureBar['browse']['autocase'] = $lang->testcase->showAutoCase;
$lang->testcase->featureBar['browse']['suite'] = '套件';
$lang->testcase->featureBar['groupcase'] = $lang->testcase->featureBar['browse'];
diff --git a/module/testcase/model.php b/module/testcase/model.php
index e0c3290b1c..e614d330df 100644
--- a/module/testcase/model.php
+++ b/module/testcase/model.php
@@ -238,14 +238,15 @@ class testcaseModel extends model
* @param int $productID
* @param int|string $branch
* @param int $moduleIdList
- * @param string $orderBy
- * @param object $pager
* @param string $browseType
* @param string $auto no|unit
+ * @param string $caseType
+ * @param string $orderBy
+ * @param object $pager
* @access public
* @return array
*/
- public function getModuleCases($productID, $branch = 0, $moduleIdList = 0, $orderBy = 'id_desc', $pager = null, $browseType = '', $auto = 'no')
+ public function getModuleCases($productID, $branch = 0, $moduleIdList = 0, $browseType = '', $auto = 'no', $caseType = '', $orderBy = 'id_desc', $pager = null)
{
$stmt = $this->dao->select('t1.*, t2.title as storyTitle, t2.deleted as storyDeleted')->from(TABLE_CASE)->alias('t1')
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id');
@@ -259,6 +260,8 @@ class testcaseModel extends model
->beginIF($browseType == 'wait')->andWhere('t1.status')->eq($browseType)->fi()
->beginIF($auto == 'unit')->andWhere('t1.auto')->eq('unit')->fi()
->beginIF($auto != 'unit')->andWhere('t1.auto')->ne('unit')->fi()
+ ->beginIF(!$this->cookie->showAutoCase)->andWhere('t1.auto')->ne('auto')->fi()
+ ->beginIF($caseType)->andWhere('t1.type')->eq($caseType)->fi()
->andWhere('t1.deleted')->eq('0')
->orderBy($orderBy)
->page($pager)
@@ -271,14 +274,15 @@ class testcaseModel extends model
* @param int $productID
* @param int|string $branch
* @param int $moduleIdList
- * @param string $orderBy
- * @param object $pager
* @param string $browseType
* @param string $auto no|unit
+ * @param string $caseType
+ * @param string $orderBy
+ * @param object $pager
* @access public
* @return array
*/
- public function getModuleProjectCases($productID, $branch = 0, $moduleIdList = 0, $orderBy = 'id_desc', $pager = null, $browseType = '', $auto = 'no')
+ public function getModuleProjectCases($productID, $branch = 0, $moduleIdList = 0, $browseType = '', $auto = 'no', $caseType = '', $orderBy = 'id_desc', $pager = null)
{
$executions = $this->loadModel('execution')->getIdList($this->session->project);
array_push($executions, $this->session->project);
@@ -294,6 +298,8 @@ class testcaseModel extends model
->beginIF($browseType == 'wait')->andWhere('t2.status')->eq($browseType)->fi()
->beginIF($auto == 'unit')->andWhere('t2.auto')->eq('unit')->fi()
->beginIF($auto != 'unit')->andWhere('t2.auto')->ne('unit')->fi()
+ ->beginIF(!$this->cookie->showAutoCase)->andWhere('t2.auto')->ne('auto')->fi()
+ ->beginIF($caseType)->andWhere('t2.type')->eq($caseType)->fi()
->andWhere('t2.deleted')->eq('0')
->orderBy($orderBy)
->page($pager, 't1.case')
@@ -398,6 +404,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.
*
@@ -487,18 +522,20 @@ class testcaseModel extends model
* @param string $browseType
* @param int $queryID
* @param int $moduleID
+ * @param string $caseType
* @param string $sort
* @param object $pager
* @param string $auto no|unit
* @access public
* @return array
*/
- public function getTestCases($productID, $branch, $browseType, $queryID, $moduleID, $sort, $pager, $auto = 'no')
+ public function getTestCases($productID, $branch, $browseType, $queryID, $moduleID, $caseType = '', $sort = 'id_desc', $pager = null, $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;
+ $auto = $this->cookie->showAutoCase ? 'auto' : $auto;
/* By module or all cases. */
$cases = array();
@@ -506,11 +543,11 @@ class testcaseModel extends model
{
if($this->app->tab == 'project')
{
- $cases = $this->getModuleProjectCases($productID, $branch, $modules, $sort, $pager, $browseType, $auto);
+ $cases = $this->getModuleProjectCases($productID, $branch, $modules, $browseType, $auto, $caseType, $sort, $pager);
}
else
{
- $cases = $this->getModuleCases($productID, $branch, $modules, $sort, $pager, $browseType, $auto);
+ $cases = $this->getModuleCases($productID, $branch, $modules, $browseType, $auto, $caseType, $sort, $pager);
}
}
/* Cases need confirmed. */
@@ -528,6 +565,8 @@ class testcaseModel extends model
->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()
+ ->beginIF(!$this->cookie->showAutoCase)->andWhere('t1.auto')->ne('auto')->fi()
+ ->beginIF($caseType)->andWhere('t1.type')->eq($caseType)->fi()
->orderBy($sort)
->page($pager, 't1.id')
->fetchAll();
@@ -2040,9 +2079,11 @@ class testcaseModel extends model
{
$showBranch = isset($this->config->testcase->browse->showBranch) ? $this->config->testcase->browse->showBranch : 1;
}
+
+ $autoIcon = $case->auto == 'auto' ? " " : '';
if(isset($branches[$case->branch]) and $showBranch) echo "{$branches[$case->branch]} ";
if($modulePairs and $case->module and isset($modulePairs[$case->module])) echo "{$modulePairs[$case->module]} ";
- echo $canView ? ($fromCaseID ? html::a($caseLink, $case->title, null, "style='color: $case->color' data-app='{$this->app->tab}'") . html::a(helper::createLink('testcase', 'view', "caseID=$fromCaseID"), "[#$fromCaseID]", '', "data-app='{$this->app->tab}'") : html::a($caseLink, $case->title, null, "style='color: $case->color' data-app='{$this->app->tab}'")) : "$case->title";
+ echo $canView ? ($fromCaseID ? html::a($caseLink, $case->title, null, "style='color: $case->color' data-app='{$this->app->tab}'") . html::a(helper::createLink('testcase', 'view', "caseID=$fromCaseID"), "[#$fromCaseID]" . $autoIcon, '', "data-app='{$this->app->tab}'") : html::a($caseLink, $case->title . $autoIcon, null, "style='color: $case->color' data-app='{$this->app->tab}'")) : "$case->title";
break;
case 'branch':
echo $branches[$case->branch];
@@ -2524,6 +2565,7 @@ class testcaseModel extends model
}
$menu .= $this->buildMenu('testtask', 'runCase', "runID=0&$params&version=$case->version", $case, 'browse', 'play', '', 'runCase iframe', false, "data-width='95%'");
+ if($case->auto == 'auto') $menu .= $this->buildMenu('testcase', 'showScript', $params, $case, 'browse', 'file-code', '', 'runCase iframe', false);
$menu .= $this->buildMenu('testtask', 'results', "runID=0&$params", $case, 'browse', '', '', 'iframe', true, "data-width='95%'");
$editParams = $params;
diff --git a/module/testcase/view/caseheader.html.php b/module/testcase/view/caseheader.html.php
index b7214ff7cb..37f3720404 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;}
#mainMenu .dividing-line {width: 1px; height: 16px; display: inline-block; background: #D8DBDE; margin: 7px 8px 0 0; float: left;}
@@ -48,6 +49,7 @@
hidden)) continue;
$menuType = $menuItem->name;
+ $caseType = isset($caseType) ? $caseType : '';
if(!$config->testcase->needReview and empty($config->testcase->forceReview) and $menuType == 'wait') continue;
if($hasBrowsePriv and $menuType == 'QUERY' and in_array($browseType, array('all', 'needconfirm', 'bysuite')))
{
@@ -55,9 +57,50 @@
$isBySearch = $browseType == 'bysearch';
include '../../common/view/querymenu.html.php';
}
+ elseif($hasBrowsePriv and $menuType == 'casetype')
+ {
+ if($this->moduleName == 'testtask' and $this->methodName == 'browseunits') continue;
+ if($this->moduleName == 'story' and $this->methodName == 'zerocase') continue;
+ if($browseType == 'bysuite') continue;
+
+ $lang->testcase->typeList[''] = $lang->testcase->allType;
+
+ $currentTypeName = zget($lang->testcase->typeList, $caseType, '');
+ $currentLable = empty($currentTypeName) ? $lang->testcase->allType : $currentTypeName;
+ if(!isset($param)) $param = 0;
+
+ echo "
";
+ echo html::a('javascript:;', "{$currentLable}" . " ", '', "class='btn btn-link' data-toggle='dropdown'");
+ echo "
';
+ }
+ 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')
{
@@ -67,10 +110,10 @@
echo "
";
echo html::a('javascript:;', "{$currentLable}" . " ", '', "class='btn btn-link' data-toggle='dropdown'");
+ echo "