From d97b6a11054ee221200c76be7317e96de184c17a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=B7=91=E6=9D=B0?= Date: Thu, 12 Jan 2023 08:26:58 +0800 Subject: [PATCH] * Add case of execution model. --- test/class/execution.class.php | 14 +++++++++ test/model/execution/setprojectsession.php | 35 ++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 test/model/execution/setprojectsession.php diff --git a/test/class/execution.class.php b/test/class/execution.class.php index 8bb3da3bb3..4bdbc9d51f 100644 --- a/test/class/execution.class.php +++ b/test/class/execution.class.php @@ -13,6 +13,20 @@ class executionTest $this->objectModel = $tester->loadModel('execution'); } + /** + * Set project into session. + * + * @param int $executionID + * @access public + * @return int + */ + public function setProjectSessionTest($executionID) + { + unset($_SESSION['project']); + $this->objectModel->setProjectSession($executionID); + return empty($_SESSION['project']) ? 0 : $_SESSION['project']; + } + /** * Test save state. * diff --git a/test/model/execution/setprojectsession.php b/test/model/execution/setprojectsession.php new file mode 100644 index 0000000000..5d4e57bc25 --- /dev/null +++ b/test/model/execution/setprojectsession.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +gen(5); +su('admin'); + +$execution = zdTable('project'); +$execution->id->range('1-5'); +$execution->name->range('项目集1,项目1,迭代1,阶段1,看板1'); +$execution->type->range('execution,project,sprint,stage,kanban'); +$execution->parent->range('0,1,2{3}'); +$execution->project->range('0{2},2{3}'); +$execution->status->range('wait{3},suspended,closed,doing'); +$execution->openedBy->range('admin,user1'); +$execution->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$execution->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$execution->gen(5); + +/** + +title=测试 executionModel::setProjectSession(); +cid=1 +pid=1 + +执行存在的情况 >> 2 +执行不存在的情况 >> 0 + +*/ + +$executionTester = new executionTest(); + +r($executionTester->setProjectSessionTest(3)) && p() && e('2'); // 执行存在的情况 +r($executionTester->setProjectSessionTest(10)) && p() && e('0'); // 执行不存在的情况