diff --git a/module/testtask/control.php b/module/testtask/control.php index 8c455e6472..5ded8cd9ad 100644 --- a/module/testtask/control.php +++ b/module/testtask/control.php @@ -189,18 +189,25 @@ class testtask extends control /** * Browse cases of a test task. * - * @param int $taskID + * @param string $taskID * @param string $browseType bymodule|all|assignedtome * @param int $param + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function cases($taskID, $browseType = 'byModule', $param = 0) + public function cases($taskID, $browseType = 'byModule', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1) { /* Save the session. */ $this->app->loadLang('testcase'); $this->session->set('caseList', $this->app->getURI(true)); + /* Load pager. */ + $this->app->loadClass('pager', $static = true); + $pager = pager::init($recTotal, $recPerPage, $pageID); + /* Set the browseType and moduleID. */ $browseType = strtolower($browseType); $moduleID = ($browseType == 'bymodule') ? (int)$param : 0; @@ -215,11 +222,11 @@ class testtask extends control { $modules = ''; if($moduleID) $modules = $this->loadModel('tree')->getAllChildID($moduleID); - $this->view->runs = $this->testtask->getRuns($taskID, $modules); + $this->view->runs = $this->testtask->getRuns($taskID, $modules, $pager); } elseif($browseType == 'assignedtome') { - $this->view->runs = $this->testtask->getUserRuns($taskID, $this->session->user->account); + $this->view->runs = $this->testtask->getUserRuns($taskID, $this->session->user->account, $pager); } $this->view->header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->cases; @@ -235,6 +242,7 @@ class testtask extends control $this->view->taskID = $taskID; $this->view->moduleID = $moduleID; $this->view->treeClass = $browseType == 'bymodule' ? '' : 'hidden'; + $this->view->pager = $pager; $this->display(); } diff --git a/module/testtask/model.php b/module/testtask/model.php index 4eba11d82f..745ab8d193 100644 --- a/module/testtask/model.php +++ b/module/testtask/model.php @@ -170,34 +170,38 @@ class testtaskModel extends model /** * Get test runs of a test task. * - * @param int $taskID - * @param int $moduleID + * @param int $taskID + * @param int $moduleID + * @param object $pager * @access public * @return array */ - public function getRuns($taskID, $moduleID) + public function getRuns($taskID, $moduleID, $pager = null) { return $this->dao->select('t2.*,t1.*')->from(TABLE_TESTRUN)->alias('t1') ->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id') ->where('t1.task')->eq((int)$taskID) ->beginIF($moduleID)->andWhere('t2.module')->in($moduleID)->fi() - ->fetchAll(); + ->page($pager) + ->fetchAll('', false); } /** * Get test runs of a user. * - * @param int $taskID - * @param int $user + * @param int $taskID + * @param int $user + * @param obejct $pager * @access public * @return array */ - public function getUserRuns($taskID, $user) + public function getUserRuns($taskID, $user, $pager = null) { return $this->dao->select('t2.*,t1.*')->from(TABLE_TESTRUN)->alias('t1') ->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id') ->where('t1.task')->eq((int)$taskID) ->andWhere('t1.assignedTo')->eq($user) + ->page($pager) ->fetchAll(); } diff --git a/module/testtask/view/cases.html.php b/module/testtask/view/cases.html.php index 97e9389058..7cf382cae7 100644 --- a/module/testtask/view/cases.html.php +++ b/module/testtask/view/cases.html.php @@ -83,18 +83,21 @@ var moduleID = ''; -