executioncases.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * The execution cases entry point of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package entries
  9. * @version 1
  10. * @link https://www.zentao.net
  11. */
  12. class executionCasesEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $executionID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($executionID = 0)
  22. {
  23. if(!$executionID) $executionID = $this->param('execution', 0);
  24. if(empty($executionID)) return $this->sendError(400, 'Need execution id.');
  25. $control = $this->loadController('execution', 'testcase');
  26. $control->testcase($executionID, (int)$this->param('product', 0), $this->param('branch', 'all'), $this->param('status', 'all'), 0, (int)$this->param('module', 0), $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
  27. $data = $this->getData();
  28. if(isset($data->status) and $data->status == 'success')
  29. {
  30. $cases = $data->data->cases;
  31. $pager = $data->data->pager;
  32. $result = array();
  33. foreach($cases as $case)
  34. {
  35. $case->statusName = $this->lang->testcase->statusList[$case->status];
  36. $result[] = $this->format($case, 'openedDate:time,reviewedDate:date,lastEditedDate:time,lastRunDate:time');
  37. }
  38. return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'cases' => $result));
  39. }
  40. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  41. return $this->sendError(400, 'error');
  42. }
  43. }