* finish task #2119.

This commit is contained in:
wangyidong
2014-11-04 07:49:10 +00:00
parent b0b9235673
commit 64d6b19a4c
6 changed files with 52 additions and 34 deletions
+5 -3
View File
@@ -328,7 +328,7 @@ class common extends control
* @access public
* @return void
*/
static public function printRPN($backLink, $preAndNext = '')
static public function printRPN($backLink, $preAndNext = '', $linkTemplate = '')
{
global $lang, $app;
if(isonlybody()) return false;
@@ -340,14 +340,16 @@ class common extends control
$id = (isset($_SESSION['testcaseOnlyCondition']) and !$_SESSION['testcaseOnlyCondition'] and $app->getModuleName() == 'testcase' and isset($preAndNext->pre->case)) ? 'case' : 'id';
$title = isset($preAndNext->pre->title) ? $preAndNext->pre->title : $preAndNext->pre->name;
$title = '#' . $preAndNext->pre->$id . ' ' . $title;
echo html::a(inLink('view', "ID={$preAndNext->pre->$id}"), '<i class="icon-pre icon-chevron-left"></i>', '', "id='pre' class='btn' title='{$title}'");
$link = $linkTemplate ? sprintf($linkTemplate, $preAndNext->pre->$id) : inLink('view', "ID={$preAndNext->pre->$id}");
echo html::a($link, '<i class="icon-pre icon-chevron-left"></i>', '', "id='pre' class='btn' title='{$title}'");
}
if(isset($preAndNext->next) and $preAndNext->next)
{
$id = (isset($_SESSION['testcaseOnlyCondition']) and !$_SESSION['testcaseOnlyCondition'] and $app->getModuleName() == 'testcase' and isset($preAndNext->next->case)) ? 'case' : 'id';
$title = isset($preAndNext->next->title) ? $preAndNext->next->title : $preAndNext->next->name;
$title = '#' . $preAndNext->next->$id . ' ' . $title;
echo html::a(inLink('view', "ID={$preAndNext->next->$id}"), '<i class="icon-pre icon-chevron-right"></i>', '', "id='next' class='btn' title='$title'");
$link = $linkTemplate ? sprintf($linkTemplate, $preAndNext->next->$id) : inLink('view', "ID={$preAndNext->next->$id}");
echo html::a($link, '<i class="icon-pre icon-chevron-right"></i>', '', "id='next' class='btn' title='$title'");
}
}
+24 -25
View File
@@ -658,40 +658,39 @@ class commonModel extends model
if(empty($queryCondition) or $this->session->$typeOnlyCondition)
{
$objects = $this->dao->select('*')->from($table)
->where('id')->eq($objectID)
$queryObjects = $this->dao->select('*')->from($table)->where('id')->eq($objectID)
->beginIF($queryCondition != false)->orWhere($queryCondition)->fi()
->beginIF($orderBy != false)->orderBy($orderBy)->fi()
->fetchPairs('id', 'id');
$tmpIDs = ',' . join(',', $objects) . ',';
->query();
}
else
{
$queryObjects = $this->dao->query($queryCondition . " ORDER BY $orderBy")->fetchAll();
$objects = array();
$tmpIDs = ',';
foreach($queryObjects as $key => $object)
{
$id = ($type == 'testcase' and isset($object->case)) ? $object->case : $object->id;
$objects[$id] = $object;
$tmpIDs .= $id . ',';
}
$queryObjects = $this->dao->query($queryCondition . " ORDER BY $orderBy");
}
/* Get pre and next ID. */
$currentStart = strpos($tmpIDs, ',' . $objectID . ',');
$currentEnd = $currentStart + strlen($objectID) + 1;
$preTag = strrpos(substr($tmpIDs, 0, $currentStart), ',');
$nextTag = strpos($tmpIDs, ',', $currentEnd + 1);
$pre = $preTag === false ? '' : substr($tmpIDs, $preTag + 1, $currentStart - $preTag - 1);
$next = $nextTag === false ? '' : substr($tmpIDs, $currentEnd + 1, $nextTag - $currentEnd - 1);
/* Set pre and next object. */
$preObj = false;
$preAndNextObject->pre = '';
$preAndNextObject->next = '';
if(empty($queryCondition) or $this->session->$typeOnlyCondition) $objects = $this->dao->select('*')->from($table)->where('id')->in("$pre,$next")->fetchAll('id');
if(isset($objects[$pre])) $preAndNextObject->pre = $objects[$pre];
if(isset($objects[$next])) $preAndNextObject->next = $objects[$next];
while($object = $queryObjects->fetch())
{
$key = (!$this->session->$typeOnlyCondition and $type == 'testcase' and isset($object->case)) ? 'case' : 'id';
$id = $object->$key;
/* Get next object. */
if($preObj === true)
{
$preAndNextObject->next = $object;
break;
}
/* Get pre object. */
if($id == $objectID)
{
if($preObj) $preAndNextObject->pre = $preObj;
$preObj = true;
}
if($preObj !== true) $preObj = $object;
}
return $preAndNextObject;
}
+5 -1
View File
@@ -433,14 +433,16 @@ class testcase extends control
* @access public
* @return void
*/
public function view($caseID, $version = 0, $from = 'testcase')
public function view($caseID, $version = 0, $from = 'testcase', $taskID = 0)
{
$case = $this->testcase->getById($caseID, $version);
if(!$case) die(js::error($this->lang->notFound) . js::locate('back'));
if($from == 'testtask') $run = $this->loadModel('testtask')->getRunByCase($taskID, $caseID);
$productID = $case->product;
$this->testcase->setMenu($this->products, $productID);
$this->view->title = "CASE #$case->id $case->title - " . $this->products[$productID];
$this->view->position[] = html::a($this->createLink('testcase', 'browse', "productID=$productID"), $this->products[$productID]);
$this->view->position[] = $this->lang->testcase->common;
@@ -448,12 +450,14 @@ class testcase extends control
$this->view->case = $case;
$this->view->from = $from;
$this->view->taskID = $taskID;
$this->view->version = $version ? $version : $case->version;
$this->view->productName = $this->products[$productID];
$this->view->modulePath = $this->tree->getParents($case->module);
$this->view->users = $this->user->getPairs('noletter');
$this->view->actions = $this->loadModel('action')->getList('case', $caseID);
$this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('testcase', $caseID);
$this->view->runID = $from == 'testcase' ? 0 : $run->id;
$this->display();
}
+4 -4
View File
@@ -43,10 +43,10 @@
ob_start();
echo "<div class='btn-group'>";
common::printIcon('testtask', 'runCase', "runID=0&caseID=$case->id&version=$case->currentVersion", '', 'button', '', '', 'runCase');
common::printIcon('testtask', 'results', "runID=0&caseID=$case->id&version=$case->version", '', 'button', '', '', 'results');
common::printIcon('testtask', 'runCase', "runID=$runID&caseID=$case->id&version=$case->currentVersion", '', 'button', '', '', 'runCase');
common::printIcon('testtask', 'results', "runID=$runID&caseID=$case->id&version=$case->version", '', 'button', '', '', 'results');
if($case->lastRunResult == 'fail') common::printIcon('testcase', 'createBug', "product=$case->product&extra=caseID=$case->id,version=$case->version,runID=", '', 'button', 'bug', '', 'iframe');
if($case->lastRunResult == 'fail') common::printIcon('testcase', 'createBug', "product=$case->product&extra=caseID=$case->id,version=$case->version,runID=$runID", '', 'button', 'bug', '', 'iframe');
echo '</div>';
echo "<div class='btn-group'>";
@@ -57,7 +57,7 @@
echo '</div>';
echo "<div class='btn-group'>";
common::printRPN($browseLink, $preAndNext);
common::printRPN($browseLink, $preAndNext, inlink('view', "caseID=%s&version=0&testtask=$from&taskID=$taskID"));
echo '</div>';
$actionLinks = ob_get_contents();
+13
View File
@@ -118,6 +118,19 @@ class testtaskModel extends model
return $task;
}
/**
* Get taskrun by case id.
*
* @param int $taskID
* @param int $caseID
* @access public
* @return void
*/
public function getRunByCase($taskID, $caseID)
{
return $this->dao->select('*')->from(TABLE_TESTRUN)->where('task')->eq($taskID)->andWhere('`case`')->eq($caseID)->fetch();
}
/**
* Get test tasks by user.
*
+1 -1
View File
@@ -62,7 +62,7 @@ var moduleID = '<?php echo $moduleID;?>';
<?php printf('%03d', $run->case);?>
</td>
<td><span class='<?php echo 'pri' . zget($lang->testcase->priList, $run->pri, $run->pri)?>'><?php echo zget($lang->testcase->priList, $run->pri, $run->pri)?></span></td>
<td class='text-left nobr'><?php echo html::a($this->createLink('testcase', 'view', "caseID=$run->case&version=$run->version&from=testtask"), $run->title, '_blank');?>
<td class='text-left nobr'><?php echo html::a($this->createLink('testcase', 'view', "caseID=$run->case&version=$run->version&from=testtask&taskID=$run->task"), $run->title, '_blank');?>
</td>
<td><?php echo $lang->testcase->typeList[$run->type];?></td>
<td><?php $assignedTo = $users[$run->assignedTo]; echo substr($assignedTo, strpos($assignedTo, ':') + 1);?></td>