* Adjust the test module related code.
This commit is contained in:
+33
-63
@@ -56,7 +56,7 @@ class testtask extends control
|
||||
$this->session->set('testtaskList', $this->app->getURI(true));
|
||||
$this->session->set('buildList', $this->app->getURI(true));
|
||||
|
||||
$scopeAndStatus = explode(',',$type);
|
||||
$scopeAndStatus = explode(',', $type);
|
||||
$this->session->set('testTaskVersionScope', $scopeAndStatus[0]);
|
||||
$this->session->set('testTaskVersionStatus', $scopeAndStatus[1]);
|
||||
|
||||
@@ -153,34 +153,17 @@ class testtask extends control
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$taskID = $this->testtask->create();
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
$this->loadModel('action')->create('testtask', $taskID, 'opened');
|
||||
|
||||
$this->executeHooks($taskID);
|
||||
|
||||
die(js::locate($this->createLink('testtask', 'browse', "productID=$productID"), 'parent'));
|
||||
}
|
||||
|
||||
/* Create testtask from build of project.*/
|
||||
if($projectID != 0 and $build != 0)
|
||||
{
|
||||
$products = $this->dao->select('t2.id, t2.name')->from(TABLE_PROJECTPRODUCT)->alias('t1')
|
||||
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
|
||||
->where('t1.project')->eq($projectID)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->fetchPairs('id');
|
||||
|
||||
$productID = $productID ? $productID : key($products);
|
||||
$projects = $this->dao->select('id, name')->from(TABLE_PROJECT)->where('id')->eq($projectID)->andWhere('type')->ne('ops')->andWhere('deleted')->eq(0)->fetchPairs('id');
|
||||
$builds = $this->dao->select('id, name')->from(TABLE_BUILD)->where('id')->eq($build)->andWhere('deleted')->eq(0)->fetchPairs('id');
|
||||
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inLink('browse', "productID=$productID")));
|
||||
}
|
||||
|
||||
/* Create testtask from testtask of test.*/
|
||||
if($projectID == 0)
|
||||
{
|
||||
$projects = $this->loadModel('product')->getProjectPairs($productID, 0, $params = 'nodeleted');
|
||||
$builds = $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk');
|
||||
}
|
||||
$productID = $productID ? $productID : key($this->products);
|
||||
$projects = empty($productID) ? array() : $this->product->getProjectPairs($productID, 0, $params = 'nodeleted');
|
||||
$builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk', true);
|
||||
|
||||
/* Set menu. */
|
||||
$productID = $this->product->saveState($productID, $this->products);
|
||||
@@ -191,17 +174,11 @@ class testtask extends control
|
||||
$this->view->position[] = $this->lang->testtask->common;
|
||||
$this->view->position[] = $this->lang->testtask->create;
|
||||
|
||||
if($projectID != 0)
|
||||
{
|
||||
$this->app->loadLang('build');
|
||||
$this->view->products = $products;
|
||||
$this->view->projectID = $projectID;
|
||||
}
|
||||
$this->view->projects = $projects;
|
||||
$this->view->productID = $productID;
|
||||
$this->view->builds = $builds;
|
||||
$this->view->build = $build;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed|qdfirst|nodeleted');
|
||||
$this->view->projects = $projects;
|
||||
$this->view->productID = $productID;
|
||||
$this->view->builds = $builds;
|
||||
$this->view->build = $build;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noclosed|qdfirst|nodeleted');
|
||||
|
||||
$this->display();
|
||||
}
|
||||
@@ -571,10 +548,14 @@ class testtask extends control
|
||||
*/
|
||||
public function edit($taskID)
|
||||
{
|
||||
/* Get task info. */
|
||||
$task = $this->testtask->getById($taskID);
|
||||
$productID = $this->product->saveState($task->product, $this->products);
|
||||
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$changes = $this->testtask->update($taskID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
if($changes or $this->post->comment)
|
||||
{
|
||||
$actionID = $this->loadModel('action')->create('testtask', $taskID, 'edited', $this->post->comment);
|
||||
@@ -583,13 +564,9 @@ class testtask extends control
|
||||
|
||||
$this->executeHooks($taskID);
|
||||
|
||||
die(js::locate(inlink('view', "taskID=$taskID"), 'parent'));
|
||||
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
|
||||
}
|
||||
|
||||
/* Get task info. */
|
||||
$task = $this->testtask->getById($taskID);
|
||||
$productID = $this->product->saveState($task->product, $this->products);
|
||||
|
||||
/* Set menu. */
|
||||
$this->testtask->setMenu($this->products, $productID, $task->branch, $taskID);
|
||||
|
||||
@@ -598,9 +575,14 @@ class testtask extends control
|
||||
$this->view->position[] = $this->lang->testtask->common;
|
||||
$this->view->position[] = $this->lang->testtask->edit;
|
||||
|
||||
/* Create testtask from testtask of test.*/
|
||||
$productID = $productID ? $productID : key($this->products);
|
||||
$projects = empty($productID) ? array() : $this->product->getProjectPairs($productID, 0, $params = 'nodeleted');
|
||||
$builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk', true);
|
||||
|
||||
$this->view->task = $task;
|
||||
$this->view->projects = $this->product->getProjectPairs($productID);
|
||||
$this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch = 0, $params = 'notrunk');
|
||||
$this->view->projects = $projects;
|
||||
$this->view->builds = $builds;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('nodeleted', $task->owner);
|
||||
$this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote');
|
||||
|
||||
@@ -1153,13 +1135,6 @@ class testtask extends control
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$file = $this->loadModel('file')->getUpload('resultFile');
|
||||
$file = $file[0];
|
||||
|
||||
$fileName = $this->file->savePath . $this->file->getSaveName($file['pathname']);
|
||||
move_uploaded_file($file['tmpname'], $fileName);
|
||||
$this->session->set('resultFile', $fileName);
|
||||
|
||||
$taskID = $this->testtask->importUnitResult($productID);
|
||||
if(dao::isError()) die(js::error(dao::getError()));
|
||||
|
||||
@@ -1170,22 +1145,17 @@ class testtask extends control
|
||||
$this->testtask->setMenu($this->products, $productID);
|
||||
|
||||
$this->app->loadLang('job');
|
||||
$projects = $this->dao->select('t2.id, t2.name')->from(TABLE_PROJECTPRODUCT)
|
||||
->alias('t1')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
|
||||
->where('t1.product')->eq((int)$productID)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->beginIF('0')->andWhere('t1.branch')->in('0')->fi()
|
||||
->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->projects)->fi()
|
||||
->andWhere('t2.type')->ne('ops')
|
||||
->orderBy('t1.project desc')
|
||||
->fetchPairs('id', 'name');
|
||||
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->importUnitResult;
|
||||
$this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]);
|
||||
$this->view->position[] = $this->lang->testtask->importUnitResult;
|
||||
$productID = $productID ? $productID : key($this->products);
|
||||
$projects = empty($productID) ? array() : $this->product->getProjectPairs($productID, 0, $params = 'nodeleted');
|
||||
$builds = empty($productID) ? array() : $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk');
|
||||
|
||||
$this->view->projects = array('' => '') + $projects;
|
||||
$this->view->builds = $this->loadModel('build')->getProductBuildPairs($productID, 0, 'notrunk');
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->importUnitResult;
|
||||
$this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]);
|
||||
$this->view->position[] = $this->lang->testtask->importUnitResult;
|
||||
|
||||
$this->view->projects = $projects;
|
||||
$this->view->builds = $builds;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter|nodeleted|noclosed');
|
||||
$this->view->productID = $productID;
|
||||
$this->display();
|
||||
|
||||
@@ -128,6 +128,7 @@ $lang->testtask->checkLinked = "Please check whether the product that the
|
||||
$lang->testtask->noImportData = 'The imported XML does not parse the data.';
|
||||
$lang->testtask->unitXMLFormat = 'Please select a file in JUnit XML format.';
|
||||
$lang->testtask->titleOfAuto = "%s automated testing";
|
||||
$lang->testtask->cannotBeParsed = 'The content of the imported XML file is in the wrong format and cannot be parsed.';
|
||||
|
||||
$lang->testtask->assignedToMe = 'Meine';
|
||||
$lang->testtask->allCases = 'Alle Fälle';
|
||||
|
||||
@@ -128,6 +128,7 @@ $lang->testtask->checkLinked = "Please check whether the product that the
|
||||
$lang->testtask->noImportData = 'The imported XML does not parse the data.';
|
||||
$lang->testtask->unitXMLFormat = 'Please select a file in JUnit XML format.';
|
||||
$lang->testtask->titleOfAuto = "%s automated testing";
|
||||
$lang->testtask->cannotBeParsed = 'The content of the imported XML file is in the wrong format and cannot be parsed.';
|
||||
|
||||
$lang->testtask->assignedToMe = 'AssignedToMe';
|
||||
$lang->testtask->allCases = 'All Cases';
|
||||
|
||||
@@ -128,6 +128,7 @@ $lang->testtask->checkLinked = "Vérifiez si le product auquel la campagne
|
||||
$lang->testtask->noImportData = "Le XML importé ne parse pas les données.";
|
||||
$lang->testtask->unitXMLFormat = 'Veuillez sélectionner un fichier au format XML JUnit.';
|
||||
$lang->testtask->titleOfAuto = "%s tests automatisés";
|
||||
$lang->testtask->cannotBeParsed = 'The content of the imported XML file is in the wrong format and cannot be parsed.';
|
||||
|
||||
$lang->testtask->assignedToMe = 'Affecté à Moi';
|
||||
$lang->testtask->allCases = 'Tous les CasTests';
|
||||
|
||||
@@ -128,6 +128,7 @@ $lang->testtask->checkLinked = "Vui lòng kiểm tra sản phẩm đó mà
|
||||
$lang->testtask->noImportData = 'The imported XML does not parse the data.';
|
||||
$lang->testtask->unitXMLFormat = 'Please select a file in JUnit XML format.';
|
||||
$lang->testtask->titleOfAuto = "%s automated testing";
|
||||
$lang->testtask->cannotBeParsed = 'The content of the imported XML file is in the wrong format and cannot be parsed.';
|
||||
|
||||
$lang->testtask->assignedToMe = 'Giao cho bạn';
|
||||
$lang->testtask->allCases = 'Tất cả tình huống';
|
||||
|
||||
@@ -128,6 +128,7 @@ $lang->testtask->checkLinked = '请检查测试单的产品是否与项目
|
||||
$lang->testtask->noImportData = '导入的XML没有解析出数据。';
|
||||
$lang->testtask->unitXMLFormat = '请选择Junit XML 格式的文件。';
|
||||
$lang->testtask->titleOfAuto = "%s 自动化测试";
|
||||
$lang->testtask->cannotBeParsed = '导入的XML文件内容格式错误,无法解析。';
|
||||
|
||||
$lang->testtask->assignedToMe = '指派给我';
|
||||
$lang->testtask->allCases = '所有用例';
|
||||
|
||||
@@ -128,6 +128,7 @@ $lang->testtask->checkLinked = '請檢查測試單的產品是否與項目
|
||||
$lang->testtask->noImportData = '導入的XML沒有解析出數據。';
|
||||
$lang->testtask->unitXMLFormat = '請選擇Junit XML 格式的檔案。';
|
||||
$lang->testtask->titleOfAuto = "%s 自動化測試";
|
||||
$lang->testtask->cannotBeParsed = '導入的XML文件內容格式錯誤,無法解析。';
|
||||
|
||||
$lang->testtask->assignedToMe = '指派給我';
|
||||
$lang->testtask->allCases = '所有用例';
|
||||
|
||||
@@ -23,12 +23,13 @@ class testtaskModel extends model
|
||||
*/
|
||||
public function setMenu($products, $productID, $branch = 0, $testtask = 0)
|
||||
{
|
||||
$this->lang->product->menu = $this->lang->product->viewMenu;
|
||||
$this->loadModel('product')->setMenu($products, $productID, $branch);
|
||||
$selectHtml = $this->product->select($products, $productID, 'testtask', 'browse', '', $branch);
|
||||
|
||||
if($testtask and $this->app->viewType != 'mhtml')
|
||||
{
|
||||
$testtasks = $this->getProductTasks($productID, 0, 'id_desc', null, array('local', 'totalStatus'));
|
||||
$testtasks = $this->getProductTasks($productID, 0, 'id_desc', null, array('local', 'totalStatus'), 0, 0, $this->session->PRJ);
|
||||
if(!isset($testtasks[$testtask])) $testtasks[$testtask] = $this->getById($testtask);
|
||||
|
||||
$selectHtml .= "<div class='btn-group angle-btn'>";
|
||||
@@ -186,14 +187,19 @@ class testtaskModel extends model
|
||||
* Get test tasks of a product.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @param array $scopeAndStatus
|
||||
* @param int $beginTime
|
||||
* @param int $endTime
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getProductTasks($productID, $branch = 0, $orderBy = 'id_desc', $pager = null, $scopeAndStatus = array(), $beginTime = 0, $endTime = 0)
|
||||
{
|
||||
$products = $scopeAndStatus[0] == 'all' ? $this->app->user->view->products : array();
|
||||
|
||||
return $this->dao->select("t1.*, t2.name AS productName, t3.name AS projectName, t4.name AS buildName, if(t4.name != '', t4.branch, t5.branch) AS branch")
|
||||
->from(TABLE_TESTTASK)->alias('t1')
|
||||
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
|
||||
@@ -202,8 +208,9 @@ class testtaskModel extends model
|
||||
->leftJoin(TABLE_PROJECTPRODUCT)->alias('t5')->on('t1.project = t5.project and t1.product = t5.product')
|
||||
|
||||
->where('t1.deleted')->eq(0)
|
||||
->andWhere('t1.PRJ')->eq($this->session->PRJ)
|
||||
->andWhere('t1.auto')->ne('unit')
|
||||
->andWhere('t1.project')->in("0,{$this->app->user->view->sprints}") //Fix bug #3260.
|
||||
->beginIF(!$this->app->user->admin)->andWhere('t3.id')->in("0,{$this->app->user->view->sprints}")->fi()
|
||||
->beginIF($scopeAndStatus[0] == 'local')->andWhere('t1.product')->eq((int)$productID)->fi()
|
||||
->beginIF($scopeAndStatus[0] == 'all')->andWhere('t1.product')->in($products)->fi()
|
||||
->beginIF($scopeAndStatus[1] == 'totalStatus')->andWhere('t1.status')->in('blocked,doing,wait,done')->fi()
|
||||
@@ -237,6 +244,7 @@ class testtaskModel extends model
|
||||
->leftJoin(TABLE_BUILD)->alias('t4')->on('t1.build = t4.id')
|
||||
->where('t1.deleted')->eq(0)
|
||||
->andWhere('t1.product')->eq($productID)
|
||||
->andWhere('t1.PRJ')->eq($this->session->PRJ)
|
||||
->andWhere('t1.auto')->eq('unit')
|
||||
->beginIF($browseType != 'all' and $browseType != 'newest' and $beginAndEnd)
|
||||
->andWhere('t1.end')->ge($beginAndEnd['begin'])
|
||||
@@ -426,6 +434,7 @@ class testtaskModel extends model
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_CASE)->where($query)
|
||||
->andWhere('id')->notIN($linkedCases)
|
||||
->andWhere('PRJ')->eq($this->session->PRJ)
|
||||
->andWhere('status')->ne('wait')
|
||||
->andWhere('type')->ne('unit')
|
||||
->beginIF($task->branch)->andWhere('branch')->in("0,$task->branch")->fi()
|
||||
@@ -452,7 +461,9 @@ class testtaskModel extends model
|
||||
$cases = array();
|
||||
if($stories)
|
||||
{
|
||||
$cases = $this->dao->select('*')->from(TABLE_CASE)->where($query)
|
||||
$cases = $this->dao->select('*')->from(TABLE_CASE)
|
||||
->where($query)
|
||||
->andWhere('PRJ')->eq($this->session->PRJ)
|
||||
->andWhere('product')->eq($productID)
|
||||
->andWhere('status')->ne('wait')
|
||||
->beginIF($linkedCases)->andWhere('id')->notIN($linkedCases)->fi()
|
||||
@@ -485,6 +496,7 @@ class testtaskModel extends model
|
||||
if($bugs)
|
||||
{
|
||||
$cases = $this->dao->select('*')->from(TABLE_CASE)->where($query)
|
||||
->andWhere('PRJ')->eq($this->session->PRJ)
|
||||
->andWhere('product')->eq($productID)
|
||||
->andWhere('status')->ne('wait')
|
||||
->beginIF($linkedCases)->andWhere('id')->notIN($linkedCases)->fi()
|
||||
@@ -517,6 +529,7 @@ class testtaskModel extends model
|
||||
return $this->dao->select('t1.*,t2.version as version')->from(TABLE_CASE)->alias('t1')
|
||||
->leftJoin(TABLE_SUITECASE)->alias('t2')->on('t1.id=t2.case')
|
||||
->where($query)
|
||||
->andWhere('t1.PRJ')->eq($this->session->PRJ)
|
||||
->andWhere('t2.suite')->eq((int)$suite)
|
||||
->andWhere('t1.product')->eq($productID)
|
||||
->andWhere('status')->ne('wait')
|
||||
@@ -541,7 +554,12 @@ class testtaskModel extends model
|
||||
{
|
||||
$caseList = $this->dao->select("`case`")->from(TABLE_TESTRUN)->where('task')->eq($testTask)->andWhere('`case`')->notin($linkedCases)->fetchPairs('case');
|
||||
|
||||
return $this->dao->select("*")->from(TABLE_CASE)->where($query)->andWhere('id')->in($caseList)->andWhere('status')->ne('wait')->page($pager)->fetchAll();
|
||||
return $this->dao->select("*")->from(TABLE_CASE)->where($query)
|
||||
->andWhere('id')->in($caseList)
|
||||
->andWhere('PRJ')->eq($this->session->PRJ)
|
||||
->andWhere('status')->ne('wait')
|
||||
->page($pager)
|
||||
->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1595,10 +1613,25 @@ class testtaskModel extends model
|
||||
*/
|
||||
public function importUnitResult($productID)
|
||||
{
|
||||
$file = $this->loadModel('file')->getUpload('resultFile');
|
||||
if(empty($file))
|
||||
{
|
||||
dao::$errors[] = $this->lang->testtask->unitXMLFormat;
|
||||
die(js::error(dao::getError()));
|
||||
}
|
||||
|
||||
$file = $file[0];
|
||||
$fileName = $this->file->savePath . $this->file->getSaveName($file['pathname']);
|
||||
move_uploaded_file($file['tmpname'], $fileName);
|
||||
if(simplexml_load_file($fileName) === false)
|
||||
{
|
||||
dao::$errors[] = $this->lang->testtask->cannotBeParsed;
|
||||
die(js::error(dao::getError()));
|
||||
}
|
||||
|
||||
$frame = $this->post->frame;
|
||||
unset($_POST['frame']);
|
||||
|
||||
$fileName = $this->session->resultFile;
|
||||
$data = $this->parseXMLResult($fileName, $productID, $frame);
|
||||
if($frame == 'cppunit' and empty($data['cases'])) $data = $this->parseCppXMLResult($fileName, $productID, $frame);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->testtask->create;?></h2>
|
||||
</div>
|
||||
<form method='post' target='hiddenwin' id='dataform'>
|
||||
<form method='post' class="main-form form-ajax" enctype="multipart/form-data" id='dataform'>
|
||||
<table class='table table-form'>
|
||||
<?php if(isset($projectID)):?>
|
||||
<tr>
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
<small class='text-muted'><?php echo $lang->arrow . $lang->testtask->edit;?></small>
|
||||
</h2>
|
||||
</div>
|
||||
<form method='post' target='hiddenwin' id='dataform'>
|
||||
<table class='table table-form'>
|
||||
<form method='post' class="main-form form-ajax" enctype="multipart/form-data" id='dataform'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th class='w-80px'><?php echo $lang->testtask->project;?></th>
|
||||
<td class='w-p35-f'>
|
||||
|
||||
Reference in New Issue
Block a user