+ add the feature of delete of testtask module.

This commit is contained in:
wangchunsheng
2010-04-12 14:22:48 +00:00
parent 5614dc8cfc
commit 988e08e15b
9 changed files with 131 additions and 154 deletions

View File

@@ -156,7 +156,7 @@ $lang->testcase->menu->testtask = array('link' => '测试任务|testtask|browse|
$lang->testtask->menu->product = '%s';
$lang->testtask->menu->bug = array('link' => '缺陷管理|bug|browse|productID=%s');
$lang->testtask->menu->testcase = array('link' => '用例管理|testcase|browse|productID=%s');
$lang->testtask->menu->testtask = array('link' => '测试任务|testtask|browse|productID=%s', 'alias' => 'view,create,edit,linkcase');
$lang->testtask->menu->testtask = array('link' => '测试任务|testtask|browse|productID=%s', 'alias' => 'view,create,edit,linkcase,cases');
/* 组织结构视图菜单设置。*/
$lang->company->menu->browseUser = array('link' => '用户列表|company|browse', 'subModule' => 'user');

View File

@@ -181,6 +181,7 @@ $lang->resource->testtask->index = 'index';
$lang->resource->testtask->create = 'create';
$lang->resource->testtask->browse = 'browse';
$lang->resource->testtask->view = 'view';
$lang->resource->testtask->cases = 'cases';
$lang->resource->testtask->edit = 'edit';
$lang->resource->testtask->delete = 'delete';
$lang->resource->testtask->batchAssign = 'batchAssign';

View File

@@ -42,6 +42,9 @@ class testtask extends control
/* 浏览一个产品下面的task。*/
public function browse($productID = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
/* 登记session。*/
$this->session->set('testtaskList', $this->app->getURI(true));
/* 设置产品和菜单。*/
$productID = common::saveProductState($productID, key($this->products));
$this->testtask->setMenu($this->products, $productID);
@@ -70,6 +73,7 @@ class testtask extends control
{
$taskID = $this->testtask->create($productID);
if(dao::isError()) die(js::error(dao::getError()));
$this->loadModel('action')->create('testtask', $taskID, 'opened');
die(js::locate($this->createLink('testtask', 'browse', "productID=$productID"), 'parent'));
}
@@ -91,10 +95,9 @@ class testtask extends control
/* 查看一个task。*/
public function view($taskID)
{
$this->app->loadLang('testcase');
/* 获取task和产品信息并设置菜单。*/
$task = $this->testtask->getById($taskID);
$task = $this->testtask->getById($taskID);
if(!$task) die(js::error($this->lang->notFound) . js::locate('back'));
$productID = $task->product;
$this->testtask->setMenu($this->products, $productID);
@@ -103,6 +106,32 @@ class testtask extends control
$this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]);
$this->view->position[] = $this->lang->testtask->view;
/* 赋值。*/
$this->view->productID = $productID;
$this->view->task = $task;
$this->view->users = $this->loadModel('user')->getPairs('noclosed');
$this->view->actions = $this->loadModel('action')->getList('testtask', $taskID);
$this->display();
}
/* 查看任务的用例列表。*/
public function cases($taskID)
{
$this->app->loadLang('testcase');
$this->session->set('caseList', $this->app->getURI(true));
/* 获取task和产品信息并设置菜单。*/
$task = $this->testtask->getById($taskID);
if(!$task) die(js::error($this->lang->notFound) . js::locate('back'));
$productID = $task->product;
$this->testtask->setMenu($this->products, $productID);
/* 导航信息。*/
$this->view->header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->cases;
$this->view->position[] = html::a($this->createLink('testtask', 'browse', "productID=$productID"), $this->products[$productID]);
$this->view->position[] = $this->lang->testtask->cases;
/* 赋值。*/
$this->view->productID = $productID;
$this->view->task = $task;
@@ -112,21 +141,24 @@ class testtask extends control
$this->display();
}
/* 编辑一个Bug。*/
public function edit($taskID)
{
/* 获得task信息。*/
$task = $this->testtask->getById($taskID);
$productID = common::saveProductState($task->product, key($this->products));
/* 更新task信息。*/
if(!empty($_POST))
{
$this->testtask->update($taskID);
$changes = $this->testtask->update($taskID);
if(dao::isError()) die(js::error(dao::getError()));
die(js::locate(inlink('browse', "productID=$productID"), 'parent'));
$actionID = $this->loadModel('action')->create('testtask', $taskID, 'edited');
$this->action->logHistory($actionID, $changes);
die(js::locate(inlink('view', "taskID=$taskID"), 'parent'));
}
/* 获得task信息。*/
$task = $this->testtask->getById($taskID);
$productID = common::saveProductState($task->product, key($this->products));
/* 设置菜单。*/
$this->testtask->setMenu($this->products, $productID);
@@ -152,7 +184,7 @@ class testtask extends control
else
{
$task = $this->testtask->getByID($taskID);
$this->testtask->delete($taskID);
$this->testtask->delete(TABLE_TESTTASK, $taskID);
die(js::locate(inlink('browse', "product=$task->product"), 'parent'));
}
}
@@ -163,7 +195,7 @@ class testtask extends control
if(!empty($_POST))
{
$this->testtask->linkCase($taskID);
$this->locate(inlink('view', "taskID=$taskID"));
$this->locate(inlink('cases', "taskID=$taskID"));
}
$this->session->set('caseList', $this->app->getURI(true));

View File

@@ -28,12 +28,14 @@ $lang->testtask->view = "测试任务详情";
$lang->testtask->edit = "编辑测试任务";
$lang->testtask->browse = "测试任务列表";
$lang->testtask->linkCase = "关联用例";
$lang->testtask->linkCaseAB = "关联";
$lang->testtask->unlinkCase = "移除";
$lang->testtask->batchAssign = "批量指派";
$lang->testtask->runCase = "执行";
$lang->testtask->results = "结果";
$lang->testtask->createBug = "创建Bug";
$lang->testtask->assign = '指派';
$lang->testtask->cases = '用例';
$lang->testtask->common = '测试任务';
$lang->testtask->id = '任务编号';

View File

@@ -50,17 +50,23 @@ class testtaskModel extends model
/* 获得某一个产品的测试任务列表。*/
public function getProductTasks($productID, $orderBy = 'id_desc', $pager = null)
{
return $this->dao->select('t1.*, t2.name AS productName, t3.name AS projectName, t4.name AS buildName')->from(TABLE_TESTTASK)->alias('t1')
return $this->dao->select('t1.*, t2.name AS productName, t3.name AS projectName, t4.name AS buildName')
->from(TABLE_TESTTASK)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->leftJoin(TABLE_PROJECT)->alias('t3')->on('t1.project = t3.id')
->leftJoin(TABLE_BUILD)->alias('t4')->on('t1.build = t4.id')
->where('t1.product')->eq((int)$productID)->orderBy($orderBy)->page($pager)->fetchAll();
->where('t1.product')->eq((int)$productID)
->andWhere('t1.deleted')->eq(0)
->orderBy($orderBy)
->page($pager)
->fetchAll();
}
/* 获取一个测试任务的详细信息。*/
public function getById($taskID)
{
return $this->dao->select('t1.*, t2.name AS productName, t3.name AS projectName, t4.name AS buildName')->from(TABLE_TESTTASK)->alias('t1')
return $this->dao->select('t1.*, t2.name AS productName, t3.name AS projectName, t4.name AS buildName')
->from(TABLE_TESTTASK)->alias('t1')
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
->leftJoin(TABLE_PROJECT)->alias('t3')->on('t1.project = t3.id')
->leftJoin(TABLE_BUILD)->alias('t4')->on('t1.build = t4.id')
@@ -70,17 +76,13 @@ class testtaskModel extends model
/* 更新测试任务信息。*/
public function update($taskID)
{
$oldTask = $this->getById($taskID);
$task = fixer::input('post')
->stripTags('name')
->specialChars('desc')
->get();
$this->dao->update(TABLE_TESTTASK)->data($task)->autoCheck()->batchcheck($this->config->testtask->edit->requiredFields, 'notempty')->where('id')->eq($taskID)->exec();
}
/* 删除测试任务信息。*/
public function delete($taskID)
{
$this->dao->delete()->from(TABLE_TESTTASK)->where('id')->eq($taskID)->exec();
if(!dao::isError()) return common::createChanges($oldTask, $task);
}
/* 关联用例。*/

View File

@@ -25,22 +25,21 @@
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/tablesorter.html.php';?>
<div class='yui-d0'>
<table class='table-1 colored tablesorter'>
<caption>
<table class='table-1 colored tablesorter fixed'>
<caption class='caption-tl'>
<div class='f-left'><?php echo $lang->testtask->browse;?></div>
<div class='f-right'><?php common::printLink('testtask', 'create', "product=$productID", $lang->testtask->create);?></div>
</caption>
<thead>
<tr>
<th><?php echo $lang->testtask->id;?></th>
<th class='w-p30'><?php echo $lang->testtask->name;?></th>
<th><?php echo $lang->testtask->product;?></th>
<th class='w-id'><?php echo $lang->idAB;?></th>
<th><?php echo $lang->testtask->name;?></th>
<th><?php echo $lang->testtask->project;?></th>
<th><?php echo $lang->testtask->build;?></th>
<th><?php echo $lang->testtask->begin;?></th>
<th><?php echo $lang->testtask->end;?></th>
<th><?php echo $lang->testtask->status;?></th>
<th><?php echo $lang->actions;?></th>
<th class='w-80px'><?php echo $lang->testtask->begin;?></th>
<th class='w-80px'><?php echo $lang->testtask->end;?></th>
<th class='w-50px'><?php echo $lang->statusAB;?></th>
<th class='w-120px {sorter:false}'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
@@ -48,17 +47,17 @@
<tr class='a-center'>
<td><?php echo html::a(inlink('view', "taskID=$task->id"), sprintf('%03d', $task->id));?></td>
<td class='a-left nobr'><?php echo html::a(inlink('view', "taskID=$task->id"), $task->name);?></td>
<td><?php echo $task->productName?></td>
<td><?php echo $task->projectName?></td>
<td><?php echo $task->buildName?></td>
<td class='nobr'><?php echo $task->projectName?></td>
<td class='nobr'><?php $task->build == 'trunk' ? print('Trunk') : print(html::a($this->createLink('build', 'view', "buildID=$task->build"), $task->buildName));?></td>
<td><?php echo $task->begin?></td>
<td><?php echo $task->end?></td>
<td><?php echo $lang->testtask->statusList[$task->status];?></td>
<td>
<?php
common::printLink('testtask', 'cases', "taskID=$task->id", $lang->testtask->cases);
common::printLink('testtask', 'linkcase', "taskID=$task->id", $lang->testtask->linkCaseAB);
common::printLink('testtask', 'edit', "taskID=$task->id", $lang->edit);
common::printLink('testtask', 'delete', "taskID=$task->id", $lang->delete, 'hiddenwin');
common::printLink('testtask', 'linkcase', "taskID=$task->id", $lang->testtask->linkCase);
?>
</td>
</tr>

View File

@@ -36,17 +36,20 @@ function checkall(checker)
<div class='yui-d0'>
<?php echo $searchForm;?>
<form method='post'>
<table class='table-1 colored tablesorter'>
<caption><?php echo $lang->testtask->unlinkedCases;?></caption>
<table class='table-1 colored tablesorter fixed'>
<caption class='caption-tl'>
<div class='f-left'><?php echo $lang->testtask->unlinkedCases;?></div>
<div class='f-right'><?php echo html::a($this->session->testtaskList, $lang->goback);?></div>
</caption>
<thead>
<tr>
<th><?php echo $lang->testcase->id;?></th>
<th><?php echo $lang->testcase->pri;?></th>
<tr class='colhead'>
<th class='w-id'><?php echo $lang->idAB;?></th>
<th class='w-pri'><?php echo $lang->priAB;?></th>
<th><?php echo $lang->testcase->title;?></th>
<th><?php echo $lang->testcase->type;?></th>
<th><?php echo $lang->testcase->openedBy;?></th>
<th><?php echo $lang->testcase->status;?></th>
<th class='w-50px'><nobr><?php echo $lang->testtask->linkVersion;?></nobr></th>
<th class='w-80px'><?php echo $lang->testcase->type;?></th>
<th class='w-50px'><?php echo $lang->openedByAB;?></th>
<th class='w-50px'><?php echo $lang->statusAB;?></th>
<th class='w-80px'><nobr><?php echo $lang->testtask->linkVersion;?></nobr></th>
</tr>
</thead>
<tbody>
@@ -54,7 +57,7 @@ function checkall(checker)
<tr class='a-center'>
<td><?php echo html::a($this->createLink('testcase', 'view', "testcaseID=$case->id"), sprintf('%03d', $case->id));?></td>
<td><?php echo $case->pri?></td>
<td width='50%' class='a-left'>
<td class='a-left'>
<?php
echo $case->title . ' ( ';
for($i = $case->version; $i >= 1; $i --)
@@ -75,8 +78,8 @@ function checkall(checker)
</tbody>
<?php endforeach;?>
<tfoot>
<tr class='a-center nobr'>
<td colspan='6'><?php echo html::submitButton();?></td>
<tr>
<td colspan='6' class='a-center'><?php echo html::submitButton();?></td>
<td class='a-left'><input type='checkbox' onclick='checkall(this);'><?php echo $lang->selectAll;?></td>
</tr>
</tfoot>

View File

@@ -26,8 +26,8 @@
<div class='yui-d0'>
<form method='post'>
<table class='table-1 bd-1px'>
<caption>CASE#<?php echo $run->case->id. $lang->colon . $run->case->title;?></caption>
<tr>
<caption class='caption-tl'>CASE#<?php echo $run->case->id. $lang->colon . $run->case->title;?></caption>
<tr class='colhead'>
<th class='w-30px'><?php echo $lang->testcase->stepID;?></th>
<th class='w-p40'><?php echo $lang->testcase->stepDesc;?></th>
<th class='w-p20'><?php echo $lang->testcase->stepExpect;?></th>

View File

@@ -24,113 +24,51 @@
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/tablesorter.html.php';?>
<?php include '../../common/view/colorbox.html.php';?>
<script language='javascript'>
$(document).ready(function()
{
$("a.iframe").colorbox({width:900, height:600, iframe:true, transition:'none'});
});
function checkall(checker)
{
$('input').each(function()
<div class='yui-d0'>
<table class='table-1'>
<caption><?php echo $lang->testtask->view;?></caption>
<tr>
<th class='rowhead'><?php echo $lang->testtask->name;?></th>
<td class='<?php if($task->deleted) echo 'deleted';?>'><?php echo $task->name;?>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->project;?></th>
<td><?php echo $task->projectName;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->build;?></th>
<td><?php $task->buildName ? print($task->buildName) : print($task->build);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->begin;?></th>
<td><?php echo $task->begin;?>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->end;?></th>
<td><?php echo $task->end;?>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->status;?></th>
<td><?php echo $lang->testtask->statusList[$task->status];?>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->desc;?></th>
<td><?php echo nl2br($task->desc);?>
</tr>
</table>
<div class='a-center f-16px strong'>
<?php
$browseLink = $this->session->testtaskList ? $this->session->testtaskList : $this->createLink('testtask', 'browse', "productID=$task->product");
if(!$task->deleted)
{
$(this).attr("checked", checker.checked)
});
}
</script>
<div class='yui-d0 yui-t6'>
<div class='yui-b'>
<table class='table-1'>
<caption><?php echo $lang->testtask->view;?></caption>
<tr>
<th class='rowhead w-p25'><?php echo $lang->testtask->project;?></th>
<td><?php echo $task->projectName;?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->build;?></th>
<td><?php $task->buildName ? print($task->buildName) : print($task->build);?></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->begin;?></th>
<td><?php echo $task->begin;?>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->end;?></th>
<td><?php echo $task->end;?>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->status;?></th>
<td><?php echo $lang->testtask->statusList[$task->status];?>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->name;?></th>
<td><?php echo $task->name;?>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->testtask->desc;?></th>
<td><?php echo nl2br($task->desc);?>
</tr>
</table>
</div>
<div class='yui-main'>
<div class='yui-b'>
<form method='post' action='<?php echo inlink('batchAssign', "task=$task->id");?>' target='hiddenwin'>
<table class='table-1 tablesorter'>
<caption>
<div class='f-left'><?php echo $lang->testtask->linkedCases;?></div>
<div class='f-right'><?php common::printLink('testtask', 'linkcase', "taskID=$task->id", $lang->testtask->linkCase);?></div>
</caption>
<thead>
<tr>
<th class='w-20px'><nobr><?php echo $lang->testcase->id;?></nobr></th>
<th><?php echo $lang->testcase->pri;?></th>
<th class='w-p30'><?php echo $lang->testcase->title;?></th>
<th><?php echo $lang->testcase->type;?></th>
<th><?php echo $lang->testtask->assignedTo;?></th>
<th><?php echo $lang->testtask->lastRun;?></th>
<th><?php echo $lang->testtask->lastResult;?></th>
<th><?php echo $lang->testtask->status;?></th>
<th class='{sorter: false}'><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody>
<?php foreach($runs as $run):?>
<tr class='a-center'>
<td class='a-left'><?php echo "<input type='checkbox' name='cases[]' value='$run->case' /> "; printf('%03d', $run->case);?></td>
<td><?php echo $run->pri?></td>
<td class='a-left nobr'><?php echo html::a($this->createLink('testcase', 'view', "caseID=$run->case&version=$run->version"), $run->title, '_blank');?>
</td>
<td><?php echo $lang->testcase->typeList[$run->type];?></td>
<td><?php echo $users[$run->assignedTo];?></td>
<td><?php if(!helper::isZeroDate($run->lastRun)) echo date(DT_MONTHTIME1, strtotime($run->lastRun));?></td>
<td class='<?php echo $run->lastResult;?>'><?php if($run->lastResult) echo $lang->testcase->resultList[$run->lastResult];?></td>
<td class='<?php echo $run->status;?>'><?php echo $lang->testtask->statusList[$run->status];?></td>
<td>
<?php
common::printLink('testtask', 'runcase', "id=$run->id", $lang->testtask->runCase, '', 'class="iframe"');
common::printLink('testtask', 'results', "id=$run->id", $lang->testtask->results, '', 'class="iframe"');
common::printLink('bug', 'create', "product=$productID&extra=projectID=$task->project,buildID=$task->build,caseID=$run->case,runID=$run->id", $lang->testtask->createBug);
common::printLink('testtask', 'unlinkcase', "id=$run->id", $lang->testtask->unlinkCase, 'hiddenwin');
?>
</td>
</tr>
<?php endforeach;?>
</tbody>
<tfoot>
<tr>
<td><nobr><?php echo "<input type='checkbox' onclick='checkall(this);'> " . $lang->selectAll;?></nobr></td>
<td colspan='9'>
<?php
echo html::select('assignedTo', $users);
echo html::submitButton($lang->testtask->assign);
?>
</td>
</tr>
</tfoot>
</table>
</form>
</div>
common::printLink('testtask', 'cases', "taskID=$task->id", $lang->testtask->cases);
common::printLink('testtask', 'linkcase', "taskID=$task->id", $lang->testtask->linkCaseAB);
common::printLink('testtask', 'edit', "taskID=$task->id", $lang->edit);
common::printLink('testtask', 'delete', "taskID=$task->id", $lang->delete, 'hiddenwin');
}
echo html::a($browseLink, $lang->goback);
?>
</div>
<?php include '../../common/view/action.html.php';?>
</div>
<?php include '../../common/view/footer.html.php';?>