testsuite.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * The testsuite 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 testsuiteEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $testsuiteID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($testsuiteID)
  22. {
  23. $control = $this->loadController('testsuite', 'view');
  24. $control->view($testsuiteID, $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
  25. $data = $this->getData();
  26. if(!$data or (isset($data->message) and $data->message == '404 Not found')) return $this->send404();
  27. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  28. if(!isset($data->data->suite)) $this->sendError(400, 'error');
  29. $suite = $this->format($data->data->suite, 'addedBy:user,addedDate:time,lastEditedBy:user,lastEditedDate:time,deleted:bool');
  30. $suite->testcases = array();
  31. foreach($data->data->cases as $case)
  32. {
  33. $suite->testcases[] = $this->format($case, 'openedBy:user,openedDate:time,lastEditedBy:user,lastEditedDate:time,lastRunDate:time,scriptedDate:date,reviewedBy:user,reviewedDate:date,deleted:bool');
  34. }
  35. return $this->send(200, $suite);
  36. }
  37. /**
  38. * DELETE method.
  39. *
  40. * @param int $testsuiteID
  41. * @access public
  42. * @return string
  43. */
  44. public function delete($testsuiteID)
  45. {
  46. $control = $this->loadController('testsuite', 'delete');
  47. $control->delete($testsuiteID, 'yes');
  48. $this->getData();
  49. return $this->sendSuccess(200, 'success');
  50. }
  51. }