Merge branch 'master' of https://gitlab.zcorp.cc/easycorp/zentaopms
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* 禅道API的todo资源类
|
||||
* 版本V1
|
||||
*
|
||||
* The testcase entry point of zentaopms
|
||||
* Version 1
|
||||
*/
|
||||
class testcaseEntry extends entry
|
||||
{
|
||||
public function get($testcaseID)
|
||||
{
|
||||
$control = $this->loadController('testcase', 'view');
|
||||
$control->view($testcaseID, $this->param('version', 0));
|
||||
|
||||
$data = $this->getData();
|
||||
if(!$data or (isset($data->message) and $data->message == '404 Not found')) return $this->send404();
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
|
||||
if(!isset($data->case)) $this->sendError(400, 'error');
|
||||
|
||||
$this->send(200, $this->format($data->case, 'openedDate:time,lastEditedDate:time,lastRunDate:time'));
|
||||
}
|
||||
|
||||
public function delete($testcaseID)
|
||||
{
|
||||
$control = $this->loadController('testcase', 'delete');
|
||||
$control->delete($testcaseID, 'yes');
|
||||
|
||||
$this->getData();
|
||||
|
||||
$this->sendSuccess(200, 'success');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* 禅道API的testcases资源类
|
||||
* 版本V1
|
||||
*
|
||||
* The testcases entry point of zentaopms
|
||||
* Version 1
|
||||
*/
|
||||
class testcasesEntry extends entry
|
||||
{
|
||||
public function get()
|
||||
{
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = pager::init($this->param('total', 0), $this->param('limit', 20), $this->param('page', 1));
|
||||
|
||||
$testcases = $this->loadModel('testcase')->getByStatus($this->param('productID', 0), $this->param('branch', ''), $this->param('type', 'all'), $this->param('status', 'all'), $this->param('moduleID', 0), $this->param('order', 'id_desc'), $pager, $this->param('auto', 'no'));
|
||||
|
||||
$result = array();
|
||||
foreach($testcases as $testcase)
|
||||
{
|
||||
$result[] = $this->format($testcase, 'openedDate:time,lastEditedDate:time,lastRunDate:time');
|
||||
}
|
||||
|
||||
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'testcases' => $result));
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,9 @@ $routes['/issues/:issueID'] = 'issue';
|
||||
$routes['/todos'] = 'todos';
|
||||
$routes['/todos/:id'] = 'todo';
|
||||
|
||||
$routes['/testcases'] = 'testcases';
|
||||
$routes['/testcases/:id'] = 'testcase';
|
||||
|
||||
$routes['/projects/:projectID/testtasks'] = 'testtasks';
|
||||
$routes['/testtasks'] = 'testtasks';
|
||||
$routes['/testtasks/:id'] = 'testtask';
|
||||
|
||||
@@ -600,7 +600,11 @@ class testcase extends control
|
||||
{
|
||||
$caseID = (int)$caseID;
|
||||
$case = $this->testcase->getById($caseID, $version);
|
||||
if(!$case) die(js::error($this->lang->notFound) . js::locate('back'));
|
||||
if(!$case)
|
||||
{
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'fail', 'message' => '404 Not found'));
|
||||
die(js::error($this->lang->notFound) . js::locate('back'));
|
||||
}
|
||||
if($case->auto == 'unit')
|
||||
{
|
||||
$this->lang->testcase->subMenu->testcase->feature['alias'] = '';
|
||||
@@ -681,6 +685,7 @@ class testcase extends control
|
||||
$this->view->isLibCase = $isLibCase;
|
||||
$this->view->caseFails = $caseFails;
|
||||
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success', 'case' => $case));
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -1017,6 +1022,7 @@ class testcase extends control
|
||||
}
|
||||
|
||||
$locateLink = $this->session->caseList ? $this->session->caseList : inlink('browse', "productID={$case->product}");
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success'));
|
||||
die(js::locate($locateLink, 'parent'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,6 +571,39 @@ class testcaseModel extends model
|
||||
->orderBy($orderBy)->page($pager)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cases by type
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param string $type all|needconfirm
|
||||
* @param string $status all|normal|blocked|investigate
|
||||
* @param int $moduleID
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @param string $auto no|unit|skip
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getByStatus($productID = 0, $branch, $type = 'all', $status = 'all', $moduleID, $orderBy = 'id_desc', $pager, $auto = 'no')
|
||||
{
|
||||
$modules = $moduleID ? $this->loadModel('tree')->getAllChildId($moduleID) : '0';
|
||||
|
||||
$cases = $this->dao->select('t1.*, t2.title as storyTitlen')->from(TABLE_CASE)->alias('t1')
|
||||
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
|
||||
->beginIF($productID)->where('t1.product')->eq((int) $productID)->fi()
|
||||
->beginIF($productID == 0)->where('t1.product')->in($this->app->user->view->products)->fi()
|
||||
->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi()
|
||||
->beginIF($modules)->andWhere('t1.module')->in($modules)->fi()
|
||||
->beginIF($type == 'needconfirm')->andWhere("t2.status = 'active'")->andWhere('t2.version > t1.storyVersion')->fi()
|
||||
->beginIF($status != 'all')->andWhere('t1.status')->eq($status)->fi()
|
||||
->beginIF($auto == 'unit')->andWhere('t1.auto')->eq('unit')->fi()
|
||||
->beginIF($auto != 'unit')->andWhere('t1.auto')->ne('unit')->fi()
|
||||
->andWhere('t1.deleted')->eq('0')
|
||||
->orderBy($orderBy)->page($pager)->fetchAll('id');
|
||||
return $this->appendData($cases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cases of a story.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user