* Fix GET of testcases.
This commit is contained in:
@@ -15,25 +15,46 @@ class testcasesEntry extends entry
|
||||
* GET method.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $projectID
|
||||
* @param int $executionID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function get($productID = 0)
|
||||
public function get($productID = 0, $projectID = 0, $executionID = 0)
|
||||
{
|
||||
if(!$productID) $productID = $this->param('productID', 0);
|
||||
if(!$productID) return $this->sendError(400, 'No product id.');
|
||||
if(!$productID) $productID = $this->param('product', 0);
|
||||
if(!$projectID) $projectID = $this->param('project', 0);
|
||||
if(!$executionID) $executionID = $this->param('execution', 0);
|
||||
if(!$productID and !$projectID and !$executionID) return $this->sendError(400, 'Need product or project or execution id.');
|
||||
|
||||
$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($productID, $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)
|
||||
if($executionID)
|
||||
{
|
||||
$result[] = $this->format($testcase, 'openedDate:time,lastEditedDate:time,lastRunDate:time,scriptedDate:date,reviewedDate:date,deleted:bool');
|
||||
$control = $this->loadController('execution', 'testcase');
|
||||
$control->testcase($executionID, $this->param('status', 'all'), $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
$control = $this->loadController('testcase', 'browse');
|
||||
$control->browse($productID, $this->param('branch', ''), $this->param('status', 'all'), 0, $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1), $projectID);
|
||||
}
|
||||
|
||||
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'testcases' => $result));
|
||||
$data = $this->getData();
|
||||
|
||||
if(isset($data->status) and $data->status == 'success')
|
||||
{
|
||||
$cases = $data->data->cases;
|
||||
$pager = $data->data->pager;
|
||||
$result = array();
|
||||
foreach($cases as $case)
|
||||
{
|
||||
$result[] = $this->format($case, 'openedDate:time,lastEditedDate:time,lastRunDate:time,scriptedDate:date,reviewedDate:date,deleted:bool');
|
||||
}
|
||||
|
||||
return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'tasks' => $result));
|
||||
}
|
||||
|
||||
if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
|
||||
|
||||
return $this->sendError(400, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user