+ rewrite the feature of test case.

This commit is contained in:
wangchunsheng
2009-11-13 08:16:11 +00:00
parent 28fbb74cef
commit 5f71cc3502
9 changed files with 174 additions and 113 deletions
+1 -1
View File
@@ -214,7 +214,7 @@
</fieldset>
<fieldset>
<legend><?php echo $lang->bug->legendSteps;?></legend>
<div><?php echo nl2br($bug->steps);?></div>
<div class='content'><?php echo nl2br($bug->steps);?></div>
</fieldset>
<fieldset>
<legend><?php echo $lang->bug->legendHistory;?></legend>
+1 -1
View File
@@ -61,7 +61,7 @@ $lang->submenu->project ->item1 = '新增项目|project|create';
$lang->submenu->project ->item2 = '浏览项目|project|browse';
$lang->submenu->qa->item1 = '缺陷管理|bug|index';
//$lang->submenu->qa->item2 = '用例管理|testcase|index';
$lang->submenu->qa->item2 = '用例管理|testcase|index';
$lang->submenu->my->item1 = '我的TODO|my|todo';
$lang->submenu->my->item2 = '我的任务|my|task';
+35 -11
View File
@@ -43,7 +43,7 @@ class testcase extends control
}
/* 浏览一个产品下面的case。*/
public function browse($productID = 0, $type = 'byModule', $param = 0)
public function browse($productID = 0, $type = 'byModule', $param = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
if(empty($this->products)) $this->locate($this->createLink('product', 'create'));
@@ -63,8 +63,10 @@ class testcase extends control
if($type == "byModule")
{
$this->app->loadClass('pager', $static = true);
$pager = pager::init($recTotal, $recPerPage, $pageID);
$childModuleIds = $this->tree->getAllChildId($currentModuleID);
$cases = $this->testcase->getModuleCases($productID, $childModuleIds);
$cases = $this->testcase->getModuleCases($productID, $childModuleIds, $orderBy, $pager);
}
$header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->case->common;
@@ -78,6 +80,8 @@ class testcase extends control
$this->assign('moduleTree', $this->tree->getTreeMenu($productID, $viewType = 'case', $rooteModuleID = 0, array('treeModel', 'createCaseLink')));
$this->assign('type', $type);
$this->assign('cases', $cases);
$this->assign('pager', $pager->get());
$this->assign('users', $this->user->getPairs($this->app->company->id, 'noletter'));
$this->assign('currentModuleID', $currentModuleID);
$this->assign('currentModuleName', $currentModuleName);
@@ -87,17 +91,18 @@ class testcase extends control
/* 创建case。*/
public function create($productID, $moduleID = 0)
{
$this->loadModel('story');
if(!empty($_POST))
{
$_POST['pri'] = str_replace('item', '', $_POST['pri']);
$this->testcase->create();
$caseID = $this->testcase->create();
if(dao::isError()) die(js::error(dao::getError()));
$this->loadModel('action');
$this->action->create('case', $caseID, 'Opened');
die(js::locate($this->createLink('testcase', 'browse', "productID=$_POST[productID]&type=byModule&param=$_POST[moduleID]"), 'parent'));
}
if(empty($this->products)) $this->locate($this->createLink('product', 'create'));
$productID = (int)$productID;
if($productID == 0) $productID = key($this->products);
$productID = common::saveProductState($productID, key($this->products));
$currentModuleID = (int)$moduleID;
$header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->case->create;
@@ -108,10 +113,11 @@ class testcase extends control
$this->assign('header', $header);
$this->assign('position', $position);
$this->assign('productID', $productID);
$this->assign('users', $users);
$this->assign('productName', $this->products[$productID]);
$this->assign('moduleOptionMenu', $this->tree->getOptionMenu($productID, $viewType = 'case', $rooteModuleID = 0));
$this->assign('currentModuleID', $currentModuleID);
$this->assign('users', $users);
$this->assign('stories', $this->story->getProductStoryPairs($productID));
$this->display();
}
@@ -119,15 +125,22 @@ class testcase extends control
/* 查看一个case。*/
public function view($caseID)
{
$this->loadModel('action');
$case = $this->testcase->getById($caseID);
$productID = $case->product;
$header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->case->view;
$position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]);
$position[] = $this->lang->case->view;
$users = $this->user->getPairs($this->app->company->id, 'noletter');
$actions = $this->action->getList('case', $caseID);
$this->assign('header', $header);
$this->assign('position', $position);
$this->assign('case', $case);
$this->assign('case', $case);
$this->assign('actions', $actions);
$this->assign('productName', $this->products[$productID]);
$this->assign('modulePath', $this->tree->getParents($case->module));
$this->display();
}
@@ -135,10 +148,20 @@ class testcase extends control
/* 编辑一个Bug。*/
public function edit($caseID)
{
$this->loadModel('story');
/* 更新case信息。*/
if(!empty($_POST))
{
$this->testcase->update($caseID);
$changes = $this->testcase->update($caseID);
if(dao::isError()) die(js::error(dao::getError()));
if($this->post->comment != '' or !empty($changes))
{
$this->loadModel('action');
$action = !empty($changes) ? 'Edited' : 'Commented';
$actionID = $this->action->create('case', $caseID, $action, $this->post->comment);
$this->action->logHistory($actionID, $changes);
}
die(js::locate($this->createLink('testcase', 'view', "caseID=$caseID"), 'parent'));
}
@@ -157,7 +180,8 @@ class testcase extends control
$this->assign('productName', $this->products[$productID]);
$this->assign('moduleOptionMenu', $this->tree->getOptionMenu($productID, $viewType = 'case', $rooteModuleID = 0));
$this->assign('currentModuleID', $currentModuleID);
$this->assign('users', $users);
$this->assign('users', $users);
$this->assign('stories', $this->story->getProductStoryPairs($productID));
$this->assign('header', $header);
$this->assign('position', $position);
+8 -6
View File
@@ -35,10 +35,11 @@ $lang->case->openedByMe = '由我创建';
$lang->case->allCases = '所有Case';
$lang->case->moduleCases = '%s';
$lang->case->labProductAndModule = '所属产品::模块';
$lang->case->labTypeAndPri = '类型::优先级';
$lang->case->labProductAndModule = '产品模块';
$lang->case->labTypeAndPri = '类型&优先级';
$lang->case->labSystemBrowserAndHardware = '系统::浏览器';
$lang->case->labAssignAndMail = '指派给::抄送给';
$lang->case->labStory = '相关需求';
$lang->case->legendRelated = '相关信息';
$lang->case->legendBasicInfo = '基本信息';
@@ -52,6 +53,7 @@ $lang->case->legendCases = '相关用例';
$lang->case->legendSteps = '用例步骤';
$lang->case->legendAction = '操作';
$lang->case->legendHistory = '历史记录';
$lang->case->legendComment = '备注';
$lang->case->buttonEdit = '编辑';
$lang->case->buttonActivate = '激活';
@@ -85,11 +87,11 @@ $lang->case->browserList->opera9 = 'opera9';
$lang->case->browserList->oprea10 = '其他';
/* Define the types. */
$lang->case->typeList->feature = '功能测试';
$lang->case->typeList->performance = '性能测试';
$lang->case->typeList['feature'] = '功能测试';
$lang->case->typeList['performance'] = '性能测试';
$lang->case->statusList->normal = 'normal';
$lang->case->statusList->blocked = 'blocked';
$lang->case->statusList['normal'] = '正常';
$lang->case->statusList['blocked'] = 'Blocked';
$lang->case->resolutionList->bydesign = 'By Design';
$lang->case->resolutionList->duplicate = 'Duplicate';
+30 -26
View File
@@ -25,48 +25,52 @@
<?php
class testcaseModel extends model
{
/* 构造函数。*/
public function __construct()
{
parent::__construct();
}
/* 创建一个Case。*/
function create()
{
extract($_POST);
$openedBy = $this->app->user->account;
$openedDate = time();
$sql = "INSERT INTO " . TABLE_CASE . " (product, module, type, pri, title, steps, openedBy, openedDate)
VALUES('$productID', '$moduleID', '$type', '$pri', '$title', '$steps', '$openedBy', '$openedDate' )";
$this->dbh->exec($sql);
$now = date('Y-m-d H:i:s');
$case = fixer::input('post')
->add('openedBy', $this->app->user->account)
->add('openedDate', $now)
->add('status', 'normal')
->setDefault('story', 0)
->stripTags('title')
->specialChars('steps')
->get();
$this->dao->insert(TABLE_CASE)->data($case)->autoCheck()->check('title', 'notempty')->exec();
return $this->dao->lastInsertID();
}
/* 获得某一个产品,某一个模块下面的所有case。*/
public function getModuleCases($productID, $moduleIds = 0)
public function getModuleCases($productID, $moduleIds = 0, $orderBy = 'id|desc', $pager = null)
{
$where = " WHERE `product` = '$productID'";
$where .= !empty($moduleIds) ? " AND module " . helper::dbin($moduleIds) : '';
$sql = "SELECT * FROM " . TABLE_CASE . $where;
$stmt = $this->dbh->query($sql);
return $stmt->fetchAll();
$sql = $this->dao->select('*')->from(TABLE_CASE)->where('product')->eq((int)$productID);
if(!empty($moduleIds)) $sql->andWhere('module')->in($moduleIds);
return $sql->orderBy($orderBy)->page($pager)->fetchAll();
}
/* 获取一个case的详细信息。*/
public function getById($caseID)
{
return $this->dbh->query("SELECT * FROM " . TABLE_CASE . " WHERE id = '$caseID'")->fetch();
$case = $this->dao->findById($caseID)->from(TABLE_CASE)->fetch();
foreach($case as $key => $value) if(strpos($key, 'Date') !== false and !(int)substr($value, 0, 4)) $case->$key = '';
return $case;
}
/* 更新case信息。*/
public function update($caseID)
{
extract($_POST);
$pri = str_replace('item', '', $pri);
$sql = "UPDATE " . TABLE_CASE . " SET
title = '$title', product='$productID', module = '$moduleID',
type='$type', pri = '$pri', status = '$status', steps = '$steps'
WHERE id ='$caseID' LIMIT 1 ";
return $this->dbh->exec($sql);
$oldCase = $this->getById($caseID);
$now = date('Y-m-d H:i:s');
$case = fixer::input('post')
->add('lastEditedBy', $this->app->user->account)
->add('lastEditedDate', $now)
->setDefault('story', 0)
->stripTags('title')
->specialChars('steps')
->remove('comment')
->get();
$this->dao->update(TABLE_CASE)->data($case)->autoCheck()->check('title', 'notempty')->where('id')->eq((int)$caseID)->exec();
if(!dao::isError()) return common::createChanges($oldCase, $case);
}
}
+9 -5
View File
@@ -42,6 +42,7 @@ function selectProduct(productID)
<td>
<div id='main'><?php echo $moduleTree;?></div>
<div class='a-right'>
<?php echo html::a($this->createLink('testcase', 'browse', "productId=$productID"), $lang->case->allCases);?>
<?php echo html::a($this->createLink('tree', 'browse', "productID=$productID&view=case"), $lang->tree->manageCase);?>
</div>
</td>
@@ -68,6 +69,9 @@ $("#{$type}Tab").addClass('active');
EOT;
?>
</ul>
<div>
<?php if(common::hasPriv('testcase', 'create')) echo html::a($this->createLink('testcase', 'create', "productID=$productID&moduleID=$currentModuleID"), $lang->case->create);?>
</div>
</div>
<table class='table-1'>
@@ -81,16 +85,16 @@ EOT;
</tr>
<?php foreach($cases as $case):?>
<tr class='a-center'>
<td><?php echo html::a($this->createLink('testcase', 'view', "testcaseID=$case->id"), $case->id);?></td>
<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'><?php echo $case->title;?></td>
<th><?php echo $case->type;?></th>
<td><?php echo $case->openedBy;?></td>
<th><?php echo $case->status;?></th>
<td><?php echo $lang->case->typeList[$case->type];?></td>
<td><?php echo $users[$case->openedBy];?></td>
<td><?php echo $lang->case->statusList[$case->status];?></td>
</tr>
<?php endforeach;?>
</table>
<div class='a-right'><?php echo html::a($this->createLink('testcase', 'create', "productID=$productID&moduleID=$currentModuleID"), $lang->case->create);?> </div>
<div class='a-right'><?php echo $pager;?></div>
</div>
</div>
</div>
+27 -21
View File
@@ -23,13 +23,29 @@
*/
?>
<?php include '../../common/header.html.php';?>
<style>#produc{width:245px} #story {width:90%}</style>
<script language='Javascript'>
/* 加载产品对应的模块和需求。*/
function loadAll(productID)
{
loadModuleMenu(productID);
loadStory(productID);
}
/* 加载模块。*/
function loadModuleMenu(productID)
{
link = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=case');
$('#moduleIdBox').load(link);
}
/* 加载需求列表。*/
function loadStory(productID)
{
link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID);
$('#storyIdBox').load(link);
}
</script>
<div class='yui-doc3'>
<form method='post' target='hiddenwin'>
@@ -38,27 +54,13 @@ function loadModuleMenu(productID)
<tr>
<th class='rowhead'><?php echo $lang->case->labProductAndModule;?></th>
<td class='a-left'>
<?php echo html::select('productID', $products, $productID, "onchange=loadModuleMenu(this.value); class='select-2'");?>
<span id='moduleIdBox'><?php echo html::select('moduleID', $moduleOptionMenu, $currentModuleID, 'class=select-3');?></span>
<?php echo html::select('product', $products, $productID, "onchange=loadAll(this.value); class='select-2'");?>
<span id='moduleIdBox'><?php echo html::select('module', $moduleOptionMenu, $currentModuleID);?></span>
</td>
</tr>
<!--
<tr>
<th class='rowhead'><?php echo $lang->case->labStory;?></th>
<td class='a-left'>
</td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->case->labProjectAndTask;?></th>
<td class='a-left'>
</td>
</tr>-->
<tr>
<th class='rowhead'><?php echo $lang->case->labTypeAndPri;?></th>
<td class='a-left'>
<?php echo html::select('type', (array)$lang->case->typeList, '', 'class=select-2');?>
<?php echo html::select('pri', (array)$lang->case->priList, '', 'class=select-2');?>
</td>
<td class='a-left'><span id='storyIdBox'><?php echo html::select('story', $stories, '', 'class=select-3');?></span></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->case->title;?></th>
@@ -67,12 +69,16 @@ function loadModuleMenu(productID)
<tr>
<th class='rowhead'><?php echo $lang->case->steps;?></th>
<td class='a-left'><textarea name='steps' class='area-1' rows='8'></textarea></td>
</tr>
<tr>
<th class='rowhead'><?php echo $lang->case->labTypeAndPri;?></th>
<td class='a-left'>
<?php echo html::select('type', (array)$lang->case->typeList, '', 'class=select-2');?>
<?php echo html::select('pri', (array)$lang->case->priList, '', 'class=select-2');?>
</td>
</tr>
<tr>
<td colspan='2'>
<input type='submit' class='button-s' />
<input type='reset' class='button-r' />
</td>
<td colspan='2'><?php echo html::submitButton() . html::resetButton();?> </td>
</tr>
</table>
</form>
+40 -20
View File
@@ -23,19 +23,40 @@
*/
?>
<?php include '../../common/header.html.php';?>
<style>#produc{width:245px} #story {width:90%}</style>
<script language='Javascript'>
storyID ='<?php echo $case->story;?>'
/* 加载产品对应的模块和需求。*/
function loadAll(productID)
{
loadModuleMenu(productID);
loadStory(productID);
}
/* 加载模块。*/
function loadModuleMenu(productID)
{
link = createLink('tree', 'ajaxGetOptionMenu', 'productID=' + productID + '&viewtype=case');
$('#moduleIdBox').load(link);
}
/* 加载需求列表。*/
function loadStory(productID)
{
link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&moduleID=0&storyID=' + storyID);
$('#storyIdBox').load(link);
}
</script>
<form method='post'>
<div class='yui-d0'>
<div id='titlebar'>
<div id='main'>
CASE #<?php echo $case->id . $lang->colon;?>
<?php echo html::input('title', $case->title, 'class=text-5');?>
<div class='f-right'><input type='submit' value='<?php echo $lang->save;?>' name='submit' /></div>
<?php echo html::input('title', $case->title, 'class=text-1');?>
</div>
<div><?php echo html::submitButton();?></div>
</div>
</div>
@@ -49,11 +70,10 @@ function loadModuleMenu(productID)
<tr>
<td class='rowhead'><?php echo $lang->case->labProductAndModule;?></td>
<td>
<?php echo html::select('productID', $products, $productID, "onchange=loadModuleMenu(this.value); class='select-2'");?>
<span id='moduleIdBox'><?php echo html::select('moduleID', $moduleOptionMenu, $currentModuleID);?></span>
<?php echo html::select('product', $products, $productID, "onchange=loadAll(this.value); class='select-2'");?>
<span id='moduleIdBox'><?php echo html::select('module', $moduleOptionMenu, $currentModuleID);?></span>
</td>
</tr>
<tr>
<td class='rowhead'><?php echo $lang->case->type;?></td>
<td><?php echo html::select('type', (array)$lang->case->typeList, $case->type, 'class=select-2');?>
@@ -68,11 +88,12 @@ function loadModuleMenu(productID)
</tr>
<tr>
<td class='rowhead'><?php echo $lang->case->story;?></td>
<td><?php echo $case->story;?></td>
<td class='a-left'><span id='storyIdBox'><?php echo html::select('story', $stories, $case->story, 'class=select-3');?></span></td>
</tr>
</table>
</fieldset>
<!--
<fieldset>
<legend><?php echo $lang->case->legendMailto;?></legend>
<div>mailto</div>
@@ -82,6 +103,7 @@ function loadModuleMenu(productID)
<legend><?php echo $lang->case->legendAttatch;?></legend>
<div>attatch</div>
</fieldset>
-->
</div>
@@ -113,11 +135,12 @@ function loadModuleMenu(productID)
</tr>
</table>
</fieldset>
<!--
<fieldset>
<legend><?php echo $lang->case->legendLinkBugs;?></legend>
<div> linkcase </div>
</fieldset>
-->
</div>
</div>
@@ -127,25 +150,22 @@ function loadModuleMenu(productID)
<fieldset>
<legend><?php echo $lang->case->legendSteps;?></legend>
<div class='a-center'>
<textarea name='steps' rows='10' class='area-1'><?php echo $case->steps;?></textarea>
<textarea name='steps' rows='5' class='area-1'><?php echo $case->steps;?></textarea>
</div>
</fieldset>
<fieldset>
<legend><?php echo $lang->case->legendComment;?></legend>
<div class='a-center'>
<textarea name='comment' rows='4' class='area-1'></textarea></td>
</div>
</fieldset>
<fieldset>
<legend><?php echo $lang->case->legendAction;?></legend>
<div class='a-center'>
<input type='submit' value='<?php echo $lang->save;?>' name='submit' />
<input type='button' value='<?php echo $lang->case->buttonToList;?>' />
<?php echo html::submitButton();?>
<input type='button' value='<?php echo $lang->case->buttonToList;?>' class='button-s'
onclick='location.href="<?php echo $this->createLink('testcase', 'browse', "productID=$productID");?>"' />
</div>
</fieldset>
<fieldset>
<legend><?php echo $lang->case->legendHistory;?></legend>
<table class='table-1' cellpadding='0' cellspacing='0'>
<tr>
</tr>
</table>
</fieldset>
</div>
<?php include '../../common/footer.html.php';?>
+23 -22
View File
@@ -29,11 +29,8 @@
CASE #<?php echo $case->id . $lang->colon . $case->title;?>
<div class='f-right'>
<?php
echo html::a($this->createLink('testcase', 'edit', "caseID=$case->id"), $lang->case->buttonEdit);
//echo html::a($this->createLink('case', 'resolve', "caseID=$case->id"), $lang->case->buttonResolve);
//echo html::a($this->createLink('case', 'close', "caseID=$case->id"), $lang->case->buttonClose);
//echo html::a($this->createLink('case', 'activate', "caseID=$case->id"), $lang->case->buttonActivate);
echo html::a($this->createLink('testcase', 'browse', "productID=$case->product"), $lang->case->buttonToList);
if(common::hasPriv('testcase', 'edit')) echo html::a($this->createLink('testcase', 'edit', "caseID=$case->id"), $lang->case->buttonEdit);
if(common::hasPriv('testcase', 'browse')) echo html::a($this->createLink('testcase', 'browse', "productID=$case->product"), $lang->case->buttonToList);
?>
</div>
</div>
@@ -48,11 +45,21 @@
<table class='table-1 a-left' cellpadding='0' cellspacing='0'>
<tr>
<td class='rowhead'><?php echo $lang->case->labProductAndModule;?></td>
<td><?php echo $case->product;?></td>
<td>
<?php
echo $productName;
if(!empty($modulePath)) echo $lang->arrow;
foreach($modulePath as $key => $module)
{
echo $module->name;
if(isset($modulePath[$key + 1])) echo $lang->arrow;
}
?>
</td>
</tr>
<tr>
<td class='rowhead'><?php echo $lang->case->type;?></td>
<td><?php echo $case->type;?></td>
<td><?php echo $lang->case->typeList[$case->type];?></td>
</tr>
<tr>
<td class='rowhead'><?php echo $lang->case->pri;?></td>
@@ -60,7 +67,7 @@
</tr>
<tr>
<td class='rowhead'><?php echo $lang->case->status;?></td>
<td><?php echo $case->status;?></td>
<td><?php echo $lang->case->statusList[$case->status];?></td>
</tr>
<tr>
<td class='rowhead'><?php echo $lang->case->story;?></td>
@@ -70,6 +77,7 @@
</table>
</fieldset>
<!--
<fieldset>
<legend><?php echo $lang->case->legendMailto;?></legend>
<div>mailto</div>
@@ -79,6 +87,7 @@
<legend><?php echo $lang->case->legendAttatch;?></legend>
<div>attatch</div>
</fieldset>
-->
</div>
@@ -111,10 +120,12 @@
</table>
</fieldset>
<!--
<fieldset>
<legend><?php echo $lang->case->legendLinkBugs;?></legend>
<div> linkcase </div>
</fieldset>
-->
</div>
</div>
@@ -125,29 +136,19 @@
<legend><?php echo $lang->case->legendAction;?></legend>
<div class='a-center' style='font-size:16px; font-weight:bold'>
<?php
echo html::a($this->createLink('testcase', 'edit', "caseID=$case->id"), $lang->case->buttonEdit);
//echo html::a($this->createLink('case', 'resolve', "caseID=$case->id"), $lang->case->buttonResolve);
//echo html::a($this->createLink('case', 'close', "caseID=$case->id"), $lang->case->buttonClose);
//echo html::a($this->createLink('case', 'activate', "caseID=$case->id"), $lang->case->buttonActivate);
echo html::a($this->createLink('testcase', 'browse', "productID=$case->product"), $lang->case->buttonToList);
if(common::hasPriv('testcase', 'edit')) echo html::a($this->createLink('testcase', 'edit', "caseID=$case->id"), $lang->case->buttonEdit);
if(common::hasPriv('testcase', 'browse')) echo html::a($this->createLink('testcase', 'browse', "productID=$case->product"), $lang->case->buttonToList);
?>
</div>
</fieldset>
<fieldset>
<legend><?php echo $lang->case->legendSteps;?></legend>
<div>
<div class='content'>
<?php echo nl2br($case->steps);?>
</div>
</fieldset>
<fieldset>
<legend><?php echo $lang->case->legendHistory;?></legend>
<table class='table-1' cellpadding='0' cellspacing='0'>
<tr>
</tr>
</table>
</fieldset>
<?php include '../../common/action.html.php';?>
</div>
<?php include '../../common/footer.html.php';?>