diff --git a/module/testtask/control.php b/module/testtask/control.php index b543cd1f38..a64b897832 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -300,6 +300,82 @@ class testtask extends control $this->display(); } + /** + * Start testtask. + * + * @param int $taskID + * @access public + * @return void + */ + public function start($taskID) + { + $actions = $this->loadModel('action')->getList('testtask', $taskID); + + if(!empty($_POST)) + { + $changes = $this->testtask->start($taskID); + if(dao::isError()) die(js::error(dao::getError())); + + if($this->post->comment != '' or !empty($changes)) + { + $actionID = $this->action->create('testtask', $taskID, 'Started', $this->post->comment); + $this->action->logHistory($actionID, $changes); + } + die(js::locate($this->createLink('testtask', 'view', "taskID=$taskID"), 'parent')); + } + + /* Get task info. */ + $testtask = $this->testtask->getById($taskID); + $productID = $this->product->saveState($testtask->product, $this->products); + + /* Set menu. */ + $this->testtask->setMenu($this->products, $productID); + + $this->view->testtask = $testtask; + $this->view->header->title = $testtask->name . $this->lang->colon . $this->lang->testtask->start; + $this->view->position[] = $this->lang->testtask->start; + $this->view->actions = $actions; + $this->display(); + } + + /** + * Close testtask. + * + * @param int $taskID + * @access public + * @return void + */ + public function close($taskID) + { + $actions = $this->loadModel('action')->getList('testtask', $taskID); + + if(!empty($_POST)) + { + $changes = $this->testtask->close($taskID); + if(dao::isError()) die(js::error(dao::getError())); + + if($this->post->comment != '' or !empty($changes)) + { + $actionID = $this->action->create('testtask', $taskID, 'Closed', $this->post->comment); + $this->action->logHistory($actionID, $changes); + } + die(js::locate($this->createLink('testtask', 'view', "taskID=$taskID"), 'parent')); + } + + /* Get task info. */ + $testtask = $this->testtask->getById($taskID); + $productID = $this->product->saveState($testtask->product, $this->products); + + /* Set menu. */ + $this->testtask->setMenu($this->products, $productID); + + $this->view->testtask = $this->testtask->getById($taskID); + $this->view->header->title = $testtask->name . $this->lang->colon . $this->lang->close; + $this->view->position[] = $this->lang->close; + $this->view->actions = $actions; + $this->display(); + } + /** * Delete a test task. * diff --git a/module/testtask/lang/en.php b/module/testtask/lang/en.php index 072137d153..94a838d166 100644 --- a/module/testtask/lang/en.php +++ b/module/testtask/lang/en.php @@ -26,6 +26,7 @@ $lang->testtask->createBug = "Bug(+)"; $lang->testtask->assign = 'Assign'; $lang->testtask->cases = 'Cases'; $lang->testtask->next = 'Next'; +$lang->testtask->start = "Start"; $lang->testtask->common = 'Test task'; $lang->testtask->id = 'ID'; @@ -44,6 +45,7 @@ $lang->testtask->linkVersion = 'Version'; $lang->testtask->lastRunAccount = "Run"; $lang->testtask->lastRunTime = 'Time'; $lang->testtask->lastRunResult = 'Result'; +$lang->testtask->report = 'Report'; $lang->testtask->statusList['wait'] = 'Pending'; $lang->testtask->statusList['doing'] = 'In progress'; diff --git a/module/testtask/lang/zh-cn.php b/module/testtask/lang/zh-cn.php index bdb8c768a6..7d05a8cae7 100644 --- a/module/testtask/lang/zh-cn.php +++ b/module/testtask/lang/zh-cn.php @@ -26,6 +26,7 @@ $lang->testtask->createBug = "提Bug"; $lang->testtask->assign = '指派'; $lang->testtask->cases = '用例'; $lang->testtask->next = '下一个'; +$lang->testtask->start = "开始"; $lang->testtask->common = '测试任务'; $lang->testtask->id = '任务编号'; @@ -44,6 +45,7 @@ $lang->testtask->linkVersion = '版本'; $lang->testtask->lastRunAccount = '执行人'; $lang->testtask->lastRunTime = '执行时间'; $lang->testtask->lastRunResult = '结果'; +$lang->testtask->report = '测试报告'; $lang->testtask->statusList['wait'] = '未开始'; $lang->testtask->statusList['doing'] = '进行中'; diff --git a/module/testtask/model.php b/module/testtask/model.php index e73dd73491..410684a20e 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -147,6 +147,49 @@ class testtaskModel extends model if(!dao::isError()) return common::createChanges($oldTask, $task); } + /** + * Start testtask. + * + * @param int $taskID + * @access public + * @return void + */ + public function start($taskID) + { + $oldTesttask = $this->getById($taskID); + $testtask = fixer::input('post') + ->setDefault('status', 'doing') + ->remove('comment')->get(); + + $this->dao->update(TABLE_TESTTASK)->data($testtask) + ->autoCheck() + ->where('id')->eq((int)$taskID) + ->exec(); + + if(!dao::isError()) return common::createChanges($oldTesttask, $testtask); + } + + /** + * Close testtask. + * + * @access public + * @return void + */ + public function close($taskID) + { + $oldTesttask = $this->getById($taskID); + $testtask = fixer::input('post') + ->setDefault('status', 'done') + ->remove('comment')->get(); + + $this->dao->update(TABLE_TESTTASK)->data($testtask) + ->autoCheck() + ->where('id')->eq((int)$taskID) + ->exec(); + + if(!dao::isError()) return common::createChanges($oldTesttask, $testtask); + } + /** * Link cases. * @@ -421,4 +464,22 @@ class testtaskModel extends model } return $results; } + + /** + * Judge an action is clickable or not. + * + * @param object $product + * @param string $action + * @access public + * @return void + */ + public function isClickable($testtask, $action) + { + $action = strtolower($action); + + if($action == 'start') return $testtask->status == 'wait'; + if($action == 'close') return $testtask->status != 'done'; + + return true; + } } diff --git a/module/testtask/view/close.html.php b/module/testtask/view/close.html.php new file mode 100644 index 0000000000..b75f1efe53 --- /dev/null +++ b/module/testtask/view/close.html.php @@ -0,0 +1,32 @@ + + * @package testtask + * @version $Id: close.html.php 935 2013-01-16 07:49:24Z wwccss@gmail.com $ + * @link http://www.zentao.net + */ +?> + + +
+ + + + + + + + + + + + + +
name;?>
testtask->report;?>
comment;?>
goback, $this->session->taskList); ?>
+ +
+ diff --git a/module/testtask/view/start.html.php b/module/testtask/view/start.html.php new file mode 100644 index 0000000000..2fa93cefc5 --- /dev/null +++ b/module/testtask/view/start.html.php @@ -0,0 +1,28 @@ + + * @package testtask + * @version $Id: start.html.php 935 2013-01-16 07:49:24Z wwccss@gmail.com $ + * @link http://www.zentao.net + */ +?> + + +
+ + + + + + + + + +
name;?>
comment;?>
goback, $this->session->taskList); ?>
+ +
+ diff --git a/module/testtask/view/view.html.php b/module/testtask/view/view.html.php index 88289f56b2..6b2b383e2a 100644 --- a/module/testtask/view/view.html.php +++ b/module/testtask/view/view.html.php @@ -56,8 +56,10 @@ $browseLink = $this->session->testtaskList ? $this->session->testtaskList : $this->createLink('testtask', 'browse', "productID=$task->product"); if(!$task->deleted) { - common::printIcon('testtask', 'cases', "taskID=$task->id"); - common::printIcon('testtask', 'linkCase', "taskID=$task->id"); + common::printIcon('testtask', 'start', "taskID=$task->id", $task); + common::printIcon('testtask', 'close', "taskID=$task->id", $task); + common::printIcon('testtask', 'cases', "taskID=$task->id", $task); + common::printIcon('testtask', 'linkCase', "taskID=$task->id", $task); common::printDivider(); common::printIcon('testtask', 'edit', "taskID=$task->id");