From 80cce4e58086c626fae902d9e0c1b3b5264a6cd1 Mon Sep 17 00:00:00 2001 From: daitingting Date: Wed, 4 Jan 2023 08:08:38 +0000 Subject: [PATCH 01/59] * Finish task #82075. --- module/story/control.php | 5 +++-- module/story/model.php | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/module/story/control.php b/module/story/control.php index 34fffa959d..f2616d8583 100755 --- a/module/story/control.php +++ b/module/story/control.php @@ -1364,7 +1364,7 @@ class story extends control $buildApp = $tab == 'product' ? 'project' : $tab; $releaseApp = $tab == 'execution' ? 'product' : $tab; $this->session->set('productList', $uri . "#app={$tab}", 'product'); - if(!isonlybody())$this->session->set('buildList', $uri, $buildApp); + if(!isonlybody()) $this->session->set('buildList', $uri, $buildApp); $this->app->loadLang('bug'); $storyID = (int)$storyID; @@ -1401,7 +1401,8 @@ class story extends control } elseif($from == 'project') { - $this->loadModel('project')->setMenu($this->session->project); + $projectID = (isset($story->projects[$this->session->project]) || empty($story->projects)) ? $this->session->project : key($story->projects); + $this->loadModel('project')->setMenu($projectID); } elseif($from == 'qa') { diff --git a/module/story/model.php b/module/story/model.php index 5be24f3135..c5ca0c99c9 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -47,13 +47,30 @@ class storyModel extends model if($setImgSize) $story->spec = $this->file->setImgSize($story->spec); if($setImgSize) $story->verify = $this->file->setImgSize($story->verify); - $story->executions = $this->dao->select('t1.project, t2.name, t2.status, t2.type, t2.multiple')->from(TABLE_PROJECTSTORY)->alias('t1') + $projects = $this->dao->select('t1.project, t2.name, t2.status, t2.type, t2.multiple, t2.project AS parentProject')->from(TABLE_PROJECTSTORY)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.project = t2.id') - ->where('t2.type')->in('sprint,stage,kanban') + ->where('t2.type')->in('sprint,stage,kanban,project') ->beginIF($story->twins)->andWhere('t1.story')->in(ltrim($story->twins, ',') . $story->id) ->beginIF(!$story->twins)->andWhere('t1.story')->in($story->id) ->orderBy('t1.`order` DESC') ->fetchAll('project'); + + $story->projects = array(); + $story->executions = array(); + foreach($projects as $project) + { + if($project->type == 'project') + { + $story->projects[$project->project] = $project->project; + } + else + { + $story->executions[$project->project] = $project; + + if(!$project->multiple) $story->projects[$project->parentProject] = $project->parentProject; + } + } + $story->tasks = $this->dao->select('id, name, assignedTo, execution, project, status, consumed, `left`,type')->from(TABLE_TASK) ->where('deleted')->eq(0) ->beginIF($story->twins)->andWhere('story')->in(ltrim($story->twins, ',') . $story->id) From edb17bfdc76e1284d340480537481f125a593f57 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Thu, 5 Jan 2023 10:44:51 +0800 Subject: [PATCH 02/59] * Add test of program model. --- test/class/program.class.php | 4 ++-- test/model/program/create.php | 33 +++++++++++++++++---------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/test/class/program.class.php b/test/class/program.class.php index 83f491a8c3..dc67fe51eb 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -22,7 +22,7 @@ class programTest * @access public * @return object */ - public function create($data) + public function createTest($data) { $_POST = $data; @@ -30,7 +30,7 @@ class programTest if(dao::isError()) return array('message' => dao::getError()); - $program = $this->program->getById($programID); + $program = $this->program->getByID($programID); return $program; } diff --git a/test/model/program/create.php b/test/model/program/create.php index de144c8745..9fd462eea3 100755 --- a/test/model/program/create.php +++ b/test/model/program/create.php @@ -2,25 +2,27 @@ switchDB(); su('admin'); +$program = zdTable('project'); +$program->id->range('1'); +$program->name->range('父项目集1'); +$program->type->range('program'); +$program->begin->range('2022-01-12'); +$program->end->range('2022-02-12'); +$program->gen(1); + +die; + /** title=测试 programModel::create(); cid=1 pid=1 -创建新项目集 >> 测试新增项目集一 -项目集名称为空时 >> 『项目集名称』不能为空。 -项目集的开始时间为空 >> 『计划开始』不能为空。 -项目集的完成时间为空 >> 『计划完成』不能为空。 -项目集的计划完成时间大于计划开始时间 >> 『计划完成』应当大于『2022-01-12』。 -项目集的完成日期大于父项目集的完成日期(需要实时更新日期) >> 父项目集的开始日期:2022-01-16,开始日期不能小于父项目集的开始日期 - */ -$program = new programTest(); +$programTester = new programTest(); $data = array( 'parent' => 0, @@ -53,10 +55,9 @@ $moreThanParent['parent'] = '1'; $moreThanParent['begin'] = '2018-01-01'; $moreThanParent['end'] = '2022-02-10'; -r($program->create($normalProgram)) && p('name') && e('测试新增项目集一'); // 创建新项目集 -r($program->create($emptyNameProgram)) && p('message[name]:0') && e('『项目集名称』不能为空。'); // 项目集名称为空时 -r($program->create($emptyBeginProgram)) && p('message[begin]:0') && e('『计划开始』不能为空。'); // 项目集的开始时间为空 -r($program->create($emptyEndProgram)) && p('message[end]:0') && e('『计划完成』不能为空。'); // 项目集的完成时间为空 -r($program->create($beginGtEndProgram)) && p('message[end]:0') && e('『计划完成』应当大于『2022-01-12』。'); // 项目集的计划完成时间大于计划开始时间 -r($program->create($moreThanParent)) && p('message:begin;message:end') && e('父项目集的开始日期:2022-01-16,开始日期不能小于父项目集的开始日期'); // 项目集的完成日期大于父项目集的完成日期(需要实时更新日期) -$db->restoreDB(); \ No newline at end of file +r($programTester->createTest($normalProgram)) && p('name') && e('测试新增项目集一'); // 创建新项目集 +r($programTester->createTest($emptyNameProgram)) && p('message[name]:0') && e('『项目集名称』不能为空。'); // 项目集名称为空时 +r($programTester->createTest($emptyBeginProgram)) && p('message[begin]:0') && e('『计划开始』不能为空。'); // 项目集的开始时间为空 +r($programTester->createTest($emptyEndProgram)) && p('message[end]:0') && e('『计划完成』不能为空。'); // 项目集的完成时间为空 +r($programTester->createTest($beginGtEndProgram)) && p('message[end]:0') && e('『计划完成』应当大于『2022-01-12』。'); // 『计划完成』应当大于『2022-01-12』。 +r($programTester->createTest($moreThanParent)) && p('message:begin;message:end') && e('父项目集的开始日期:2022-01-16,开始日期不能小于父项目集的开始日期'); // 项目集的完成日期大于父项目集的完成日期(需要实时更新日期) From f8df2cd571239e6f89d6651ad23f623c822e2e20 Mon Sep 17 00:00:00 2001 From: daitingting Date: Thu, 5 Jan 2023 03:05:51 +0000 Subject: [PATCH 03/59] * Finish task #82073. --- module/bug/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/bug/model.php b/module/bug/model.php index 64fb3747d1..c4ebe96f61 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -863,7 +863,7 @@ class bugModel extends model if($bug->assignedTo != $oldBug->assignedTo) $bug->assignedDate = $now; if($bug->resolution != '') $bug->confirmed = 1; - if(($bug->resolvedBy != '' or $bug->resolution != '') and $oldBug->status != 'closed') + if(($bug->resolvedBy != '' or $bug->resolution != '') and strpos(',resolved,closed,', ",{$oldBug->status},") === false) { $bug->resolvedDate = $now; $bug->status = 'resolved'; From 21c5ddefcc49909611f423514214562356eb8b3a Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 5 Jan 2023 11:10:04 +0800 Subject: [PATCH 04/59] * Modify program create test case. --- test/model/program/create.php | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/test/model/program/create.php b/test/model/program/create.php index 9fd462eea3..a2d6fb0b5c 100755 --- a/test/model/program/create.php +++ b/test/model/program/create.php @@ -8,18 +8,23 @@ $program = zdTable('project'); $program->id->range('1'); $program->name->range('父项目集1'); $program->type->range('program'); -$program->begin->range('2022-01-12'); -$program->end->range('2022-02-12'); +$program->path->range('1')->prefix(',')->postfix(','); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); $program->gen(1); -die; - /** title=测试 programModel::create(); cid=1 pid=1 +创建新项目集 >> 测试新增项目集一 +项目集名称为空时 >> 『项目集名称』不能为空。 +项目集的开始时间为空 >> 『计划开始』不能为空。 +项目集的完成时间为空 >> 『计划完成』不能为空。 +『计划完成』应当大于『2022-01-12』。 >> 『计划完成』应当大于『2022-01-12』。 + */ $programTester = new programTest(); @@ -27,7 +32,7 @@ $programTester = new programTest(); $data = array( 'parent' => 0, 'name' => '测试新增项目集一', - 'budget' => '', + 'budget' => '', 'budgetUnit' => 'CNY', 'begin' => '2022-01-12', 'end' => '2022-02-12', @@ -50,14 +55,8 @@ $emptyEndProgram['end'] = ''; $beginGtEndProgram = $data; $beginGtEndProgram['end'] = '2022-01-10'; -$moreThanParent = $data; -$moreThanParent['parent'] = '1'; -$moreThanParent['begin'] = '2018-01-01'; -$moreThanParent['end'] = '2022-02-10'; - -r($programTester->createTest($normalProgram)) && p('name') && e('测试新增项目集一'); // 创建新项目集 -r($programTester->createTest($emptyNameProgram)) && p('message[name]:0') && e('『项目集名称』不能为空。'); // 项目集名称为空时 -r($programTester->createTest($emptyBeginProgram)) && p('message[begin]:0') && e('『计划开始』不能为空。'); // 项目集的开始时间为空 -r($programTester->createTest($emptyEndProgram)) && p('message[end]:0') && e('『计划完成』不能为空。'); // 项目集的完成时间为空 -r($programTester->createTest($beginGtEndProgram)) && p('message[end]:0') && e('『计划完成』应当大于『2022-01-12』。'); // 『计划完成』应当大于『2022-01-12』。 -r($programTester->createTest($moreThanParent)) && p('message:begin;message:end') && e('父项目集的开始日期:2022-01-16,开始日期不能小于父项目集的开始日期'); // 项目集的完成日期大于父项目集的完成日期(需要实时更新日期) +r($programTester->createTest($normalProgram)) && p('name') && e('测试新增项目集一'); // 创建新项目集 +r($programTester->createTest($emptyNameProgram)) && p('message[name]:0') && e('『项目集名称』不能为空。'); // 项目集名称为空时 +r($programTester->createTest($emptyBeginProgram)) && p('message[begin]:0') && e('『计划开始』不能为空。'); // 项目集的开始时间为空 +r($programTester->createTest($emptyEndProgram)) && p('message[end]:0') && e('『计划完成』不能为空。'); // 项目集的完成时间为空 +r($programTester->createTest($beginGtEndProgram)) && p('message[end]:0') && e('『计划完成』应当大于『2022-01-12』。'); // 『计划完成』应当大于『2022-01-12』。 From 682d97e9f52414f2aabd0d757603513f739eb008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=B7=91=E6=9D=B0?= Date: Thu, 5 Jan 2023 11:20:15 +0800 Subject: [PATCH 05/59] * Add test of program model. --- test/class/program.class.php | 11 +++++----- test/model/program/createdefaultprogram.php | 11 ++++------ test/model/program/createstakeholder.php | 23 +++++++++++++-------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/test/class/program.class.php b/test/class/program.class.php index dc67fe51eb..b581982738 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -36,15 +36,16 @@ class programTest } /** - * createStakeholder + * Create stakeholder. * - * @param int mixed $programID + * @param int $programID + * @param array $accounts * @access public * @return void */ - public function createStakeholder($programID) + public function createStakeholderTest($programID, $accounts = array()) { - $_POST['accounts'] = array('dev1', 'dev2'); + $_POST['accounts'] = $accounts; $stakeHolder = $this->program->createStakeholder($programID); return $this->program->getStakeholdersByPrograms($programID); @@ -60,7 +61,7 @@ class programTest { $programID = $this->program->createDefaultProgram(); - return $programID; + return $programID > 0; } /** diff --git a/test/model/program/createdefaultprogram.php b/test/model/program/createdefaultprogram.php index 136076867e..14270abcf7 100644 --- a/test/model/program/createdefaultprogram.php +++ b/test/model/program/createdefaultprogram.php @@ -2,7 +2,6 @@ switchDB(); /** @@ -10,14 +9,12 @@ title=测试 programModel::createDefaultProgram(); cid=1 pid=1 -创建默认项目集并返回ID >> 751 +创建默认项目集 >> 1 */ -$test = new programTest(); +$programTester = new programTest(); -$result = $test->createDefaultProgramTest(); +$result = $programTester->createDefaultProgramTest(); -r($result) && p('') && e('751'); // 创建默认项目集并返回ID - -$db->restoreDB(); \ No newline at end of file +r($result) && p('') && e('1'); // 创建默认项目集 diff --git a/test/model/program/createstakeholder.php b/test/model/program/createstakeholder.php index 26d773a962..115e695ee9 100755 --- a/test/model/program/createstakeholder.php +++ b/test/model/program/createstakeholder.php @@ -2,7 +2,15 @@ switchDB(); + +$program = zdTable('project'); +$program->id->range('1'); +$program->name->range('父项目集1'); +$program->type->range('program'); +$program->path->range('1')->prefix(',')->postfix(','); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->gen(1); /** @@ -11,17 +19,14 @@ cid=1 pid=1 创建id=1的项目集的干系人并查看数量。 >> 2 -创建id=1的项目集的干系人dev1,dev2并查看Account。 >> dev2;dev1 +创建id=1的项目集的干系人dev1,dev2并查看Account。 >> dev1;dev2 */ -global $tester; -$tester->loadModel('program'); +$programTester = new programTest(); -$_POST['accounts'] = array('dev1', 'dev2'); -$tester->program->createStakeholder(1); -$result = $tester->program->getStakeholdersByPrograms(1); +$accounts = array('dev1', 'dev2'); +$result = $programTester->createStakeholderTest(1, $accounts); r(count($result)) && p('') && e('2'); // 创建id=1的项目集的干系人并查看数量。 -r($result) && p('0:account;1:account') && e('dev2;dev1'); // 创建id=1的项目集的干系人dev1,dev2并查看Account。 -$db->restoreDB(); \ No newline at end of file +r($result) && p('0:account;1:account') && e('dev1;dev2'); // 创建id=1的项目集的干系人dev1,dev2并查看Account。 From 6e02dc58ea0c48635156c9e5916c7bbc325bd4e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=B7=91=E6=9D=B0?= Date: Thu, 5 Jan 2023 11:30:15 +0800 Subject: [PATCH 06/59] * Add test of program model. --- test/class/program.class.php | 17 +++++++++++++++++ test/model/program/getbudgetleft.php | 28 ++++++++++++++++++---------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/test/class/program.class.php b/test/class/program.class.php index b581982738..baad2a2e70 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -117,4 +117,21 @@ class programTest return $program; } + + /** + * Get budget left. + * + * @param int $programID + * @access public + * @return int + */ + public function getBudgetLeftTest($programID) + { + $program = $this->program->getByID($programID); + $budget = $this->program->getBudgetLeft($program); + + if(dao::isError()) return array('message' => dao::getError()); + + return $budget; + } } diff --git a/test/model/program/getbudgetleft.php b/test/model/program/getbudgetleft.php index 066cf1789f..4db0a00893 100755 --- a/test/model/program/getbudgetleft.php +++ b/test/model/program/getbudgetleft.php @@ -1,25 +1,33 @@ #!/usr/bin/env php id->range('1,2'); +$program->name->range('父项目集1,父项目集2'); +$program->type->range('program'); +$program->budget->range('900000,899900'); +$program->path->range('1,2')->prefix(',')->postfix(','); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->gen(2); + /** title=测试 programModel::getBudgetLeft(); cid=1 pid=1 -查看项目11的所有父项目集的预算剩余 >> 900000 -查看项目12的所有父项目集的预算剩余 >> 899900 +查看项目集1的所有父项目集的预算剩余 >> 900000 +查看项目集2的所有父项目集的预算剩余 >> 899900 */ -global $tester; -$tester->loadModel('program'); -$program1 = $tester->program->getById(11); -$program2 = $tester->program->getById(12); -$result1 = $tester->program->getBudgetLeft($program1); -$result2 = $tester->program->getBudgetLeft($program2); +$programTester = new programTest(); +$result1 = $programTester->getBudgetLeftTest(1); +$result2 = $programTester->getBudgetLeftTest(2); -r($result) && p() && e('900000'); // 查看项目11的所有父项目集的预算剩余 -r($result) && p() && e('899900'); // 查看项目12的所有父项目集的预算剩余 \ No newline at end of file +r($result1) && p() && e('900000'); // 查看项目集1的所有父项目集的预算剩余 +r($result2) && p() && e('899900'); // 查看项目集2的所有父项目集的预算剩余 From 592aeee6cd506efee8d439d873ce2025a518998f Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 5 Jan 2023 13:11:39 +0800 Subject: [PATCH 07/59] * Modify program udpdate test case. --- test/class/program.class.php | 4 ++-- test/model/program/update.php | 44 +++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/test/class/program.class.php b/test/class/program.class.php index baad2a2e70..4551f246e7 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -87,14 +87,14 @@ class programTest /** - * update + * Test update program. * * @param mixed $proguamID * @param mixed $data * @access public * @return void */ - public function update($programID, $data) + public function updateTest($programID, $data) { $_POST = $data; $this->program->update($programID); diff --git a/test/model/program/update.php b/test/model/program/update.php index 62037da4ae..6254c65887 100755 --- a/test/model/program/update.php +++ b/test/model/program/update.php @@ -2,16 +2,24 @@ switchDB(); su('admin'); +$program = zdTable('project'); +$program->id->range('1'); +$program->name->range('项目集1'); +$program->type->range('program'); +$program->path->range('1')->prefix(',')->postfix(','); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->gen(1); + /** title=测试 programModel::update(); cid=1 pid=1 -正常更新项目集的情况 >> 测试更新项目集十 +正常更新项目集的情况 >> 测试更新项目集 更新项目集名称为空时 >> 『项目集名称』不能为空。 当计划开始为空时更新项目集信息 >> 『计划开始』不能为空。 当计划完成为空时更新项目集信息 >> 『计划完成』不能为空。 @@ -19,19 +27,20 @@ pid=1 */ -$program = new programTest(); +$programTester = new programTest(); $data = array( - 'parent' => '0', - 'name' => '测试更新项目集十', - 'begin' => '2020-10-10', - 'end' => '2022-09-03', - 'acl' => 'private', - 'budget' => '100', - 'budgetUnit' => 'CNY', - 'syncPRJUnit' => true, + 'parent' => '0', + 'name' => '测试更新项目集', + 'begin' => '2020-10-10', + 'end' => '2023-09-03', + 'acl' => 'private', + 'budget' => '100', + 'status' => 'wait', + 'budgetUnit' => 'CNY', + 'syncPRJUnit' => true, 'exchangeRate' => '', - 'whitelist' => array('dev10', 'dev12') + 'whitelist' => array('dev10', 'dev12') ); $normalProgram = $data; @@ -48,9 +57,8 @@ $emptyEndProgram['end'] = ''; $realBeganProgram = $data; $realBeganProgram['realBegan'] = '2020-11-10'; -r($program->update(10, $normalProgram)) && p('name') && e('测试更新项目集十'); // 正常更新项目集的情况 -r($program->update(10, $emptyTitleProgram)) && p('message[name]:0') && e('『项目集名称』不能为空。'); // 更新项目集名称为空时 -r($program->update(10, $emptyBeginProgram)) && p('message[begin]:0') && e('『计划开始』不能为空。'); // 当计划开始为空时更新项目集信息 -r($program->update(10, $emptyEndProgram)) && p('message[end]:0') && e('『计划完成』不能为空。'); // 当计划完成为空时更新项目集信息 -r($program->update(10, $realBeganProgram)) && p('status') && e('doing'); // 更新未开始的项目集实际开始时间 -$db->restoreDB(); +r($programTester->updateTest(1, $normalProgram)) && p('name') && e('测试更新项目集'); // 正常更新项目集的情况 +r($programTester->updateTest(1, $emptyTitleProgram)) && p('message[name]:0') && e('『项目集名称』不能为空。'); // 更新项目集名称为空时 +r($programTester->updateTest(1, $emptyBeginProgram)) && p('message[begin]:0') && e('『计划开始』不能为空。'); // 当计划开始为空时更新项目集信息 +r($programTester->updateTest(1, $emptyEndProgram)) && p('message[end]:0') && e('『计划完成』不能为空。'); // 当计划完成为空时更新项目集信息 +r($programTester->updateTest(1, $realBeganProgram)) && p('status') && e('doing'); // 更新未开始的项目集实际开始时间 From e9f88d3cbd476c6b40336c5b9252d1f733fb1922 Mon Sep 17 00:00:00 2001 From: Yagami Date: Thu, 5 Jan 2023 13:59:41 +0800 Subject: [PATCH 08/59] * Fix code error. --- module/execution/control.php | 9 ++++++--- module/tutorial/model.php | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index bb833b35e9..bdb1bbff66 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1760,10 +1760,13 @@ class execution extends control foreach($products as $productIndex => $product) { $productPlans[$productIndex] = array(); - foreach($branches[$productIndex] as $branchID => $branch) + if(isset($branches[$productIndex])) { - $linkedBranches[$productIndex][$branchID] = $branchID; - $productPlans[$productIndex] += isset($plans[$productIndex][$branchID]) ? $plans[$productIndex][$branchID] : array(); + foreach($branches[$productIndex] as $branchID => $branch) + { + $linkedBranches[$productIndex][$branchID] = $branchID; + $productPlans[$productIndex] += isset($plans[$productIndex][$branchID]) ? $plans[$productIndex][$branchID] : array(); + } } } diff --git a/module/tutorial/model.php b/module/tutorial/model.php index 41f2bc8358..d2b0a8b723 100644 --- a/module/tutorial/model.php +++ b/module/tutorial/model.php @@ -168,6 +168,7 @@ class tutorialModel extends model $project->deleted = '0'; $project->hasProduct = ''; $project->multiple = ''; + $project->division = 0; return $project; } From 71c7124fd7633a0e76004405809596e864229b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=B7=91=E6=9D=B0?= Date: Thu, 5 Jan 2023 13:59:55 +0800 Subject: [PATCH 09/59] * Add case for program model. --- test/class/program.class.php | 12 ++++++++++++ test/model/program/getbudgetunitlist.php | 19 ------------------ test/model/program/getchildren.php | 25 ++++++++++++++++-------- 3 files changed, 29 insertions(+), 27 deletions(-) delete mode 100755 test/model/program/getbudgetunitlist.php diff --git a/test/class/program.class.php b/test/class/program.class.php index 4551f246e7..36434cf37d 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -134,4 +134,16 @@ class programTest return $budget; } + + /** + * Get children. + * + * @param int $programID + * @access public + * @return int + */ + public function getChildrenTest($programID) + { + return $this->program->getChildren($programID); + } } diff --git a/test/model/program/getbudgetunitlist.php b/test/model/program/getbudgetunitlist.php deleted file mode 100755 index 367aa5677d..0000000000 --- a/test/model/program/getbudgetunitlist.php +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env php -> 人民币;美元 - -*/ - -global $tester; -$tester->loadModel('project'); - -r($tester->loadModel('program')->getBudgetUnitList()) && p('CNY;USD') && e('人民币;美元'); //获取货币类型列表 \ No newline at end of file diff --git a/test/model/program/getchildren.php b/test/model/program/getchildren.php index 61f6bb3ef8..d22267f467 100755 --- a/test/model/program/getchildren.php +++ b/test/model/program/getchildren.php @@ -1,23 +1,32 @@ #!/usr/bin/env php id->range('1-3'); +$program->name->range('父项目集1,子项目集1,子项目集2'); +$program->parent->range('0,1,1'); +$program->type->range('program'); +$program->path->setFields(array( + array('field' => 'path1', 'range' => '1', 'prefix' => ',', 'postfix' => ','), + array('field' => 'path2', 'range' => '[],2,3', 'postfix' => ',') +)); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->gen(3); + /** title=测试 programModel:: getChildren(); cid=1 pid=1 -通过id查找id=1的子项目集个数 >> 9 -通过id查找id=22的子项目集个数 >> 7 -通过id查找id=221的子项目集个数 >> 0 +通过id查找id=1的子项目集个数 >> 2 */ -global $tester; -$tester->loadModel('program'); +$programTester = new programTest(); -r($tester->program->getChildren(1)) && p() && e('9'); // 通过id查找id=1的子项目集个数 -r($tester->program->getChildren(22)) && p() && e('7'); // 通过id查找id=22的子项目集个数 -r($tester->program->getChildren(221)) && p() && e('0'); // 通过id查找id=221的子项目集个数 \ No newline at end of file +r($programTester->getChildrenTest(1)) && p() && e('2'); // 通过id查找id=1的子项目集个数 From 4ecf2050240da0e16892fe828a03d88dd9864304 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 5 Jan 2023 14:07:45 +0800 Subject: [PATCH 10/59] * Update test case for program settreepath. --- test/class/program.class.php | 15 +++++++++++++++ test/lib/yaml.class.php | 8 ++++---- test/model/program/settreepath.php | 28 ++++++++++++++++++---------- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/test/class/program.class.php b/test/class/program.class.php index 4551f246e7..20cb41b8e4 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -134,4 +134,19 @@ class programTest return $budget; } + + /** + * Set tree path. + * + * @param int $programID + * @access public + * @return void + */ + public function setTreePathTest($programID) + { + $this->program->setTreePath($programID); + $program = $this->program->getByID($programID); + + return $program; + } } diff --git a/test/lib/yaml.class.php b/test/lib/yaml.class.php index 2ce3f4ad97..a43dc5e9af 100644 --- a/test/lib/yaml.class.php +++ b/test/lib/yaml.class.php @@ -257,7 +257,7 @@ class yaml * @access public * @return void */ - public function gen($rows, $version = '') + public function gen($rows, $version = '1.0') { $runFileDir = dirname(getcwd() . DS . $_SERVER['SCRIPT_FILENAME']); $runFileName = str_replace(strrchr($_SERVER['SCRIPT_FILENAME'], "."), "", $_SERVER['SCRIPT_FILENAME']); @@ -268,9 +268,9 @@ class yaml $yamlDataArr = array(); - $yamlDataArr['title'] = "zt_{$this->tableName}"; - $yamlDataArr['author'] = "auto_{$runFileName}"; - $version ? $yamlDataArr['version'] = $version : $yamlDataArr['version'] = '1.0'; + $yamlDataArr['title'] = "zt_{$this->tableName}"; + $yamlDataArr['author'] = "auto_{$runFileName}"; + $yamlDataArr['version'] = $version; if(empty($this->fields->fieldArr)) { diff --git a/test/model/program/settreepath.php b/test/model/program/settreepath.php index 689014342c..76b79722ac 100755 --- a/test/model/program/settreepath.php +++ b/test/model/program/settreepath.php @@ -1,26 +1,34 @@ #!/usr/bin/env php id->range('1,10'); +$program->name->range('项目集1'); +$program->type->range('program'); +$program->parent->range('[],[1]'); +$program->path->range('1,10')->prefix(',')->postfix(','); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->gen(2); + /** title=测试 programModel::setTreePath(); cid=1 pid=1 -设置之前的项目集的path >> ,2,12, -设置之后的项目集的path >> ,2,12, +设置之前的项目集的path >> ,10, +设置之后的项目集的path >> ,1,10, */ -global $tester; -$tester->loadModel('program'); +$programTester = new programTest(); -$before = $tester->program->getById(12); -$tester->program->setTreePath(12); -$after = $tester->program->getById(12); +$before = $programTester->getByIDTest(10); +$after = $programTester->setTreePathTest(10); -r($before) && p('path') && e(',2,12,'); // 设置之前的项目集的path -r($after) && p('path') && e(',2,12,'); // 设置之后的项目集的path -$db->restoreDB(); \ No newline at end of file +r($before) && p('path') && e(',10,'); // 设置之前的项目集的path +r($after) && p('path') && e(',1,10,'); // 设置之后的项目集的path From 3090e4fbbae87f2bc916463045c378b64400e90f Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 5 Jan 2023 14:19:38 +0800 Subject: [PATCH 11/59] * Update test case for isclickable. --- test/class/program.class.php | 13 +++++++++++ test/model/program/isclickable.php | 37 +++++++++++++++++++----------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/test/class/program.class.php b/test/class/program.class.php index 3d27b86e9e..c65d29e731 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -161,4 +161,17 @@ class programTest { return $this->program->getChildren($programID); } + + /** + * Check clickable. + * + * @param int $programID + * @param string $status + * @access public + * @return int + */ + public function isClickableTest($programID, $status) + { + return $this->program->isClickable($programID, $status); + } } diff --git a/test/model/program/isclickable.php b/test/model/program/isclickable.php index 3d8904c401..75c9f3c4f4 100755 --- a/test/model/program/isclickable.php +++ b/test/model/program/isclickable.php @@ -2,6 +2,18 @@ id->range('1,2'); +$program->name->range('项目集1,项目集2'); +$program->type->range('program'); +$program->status->range('wait'); +$program->parent->range('0'); +$program->path->range('1,2')->prefix(',')->postfix(','); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->gen(2); /** @@ -9,24 +21,23 @@ title=测试 programModel::createStakeholder(); cid=1 pid=1 -传入项目集1,动作为closed,判断是否可点击 >> 1 +传入项目集1,动作为closed,判断是否可点击 >> 1 传入项目集1,动作为activate,判断是否可点击 >> 0 -传入项目集1,动作为suspend,判断是否可点击 >> 1 -传入项目集2,动作为closed,判断是否可点击 >> 1 +传入项目集1,动作为suspend,判断是否可点击 >> 1 +传入项目集2,动作为closed,判断是否可点击 >> 1 传入项目集2,动作为activate,判断是否可点击 >> 0 传入项目集2,动作为activate,判断是否可点击 >> 1 */ -global $tester; -$tester->loadModel('program'); +$programTester = new programTest(); -$program1 = $tester->program->getById(1); -$program2 = $tester->program->getById(2); +$program1 = $programTester->getByIDTest(1); +$program2 = $programTester->getByIDTest(2); -r($tester->program->isClickable($program1, 'close')) && p('') && e('1'); // 传入项目集1,动作为closed,判断是否可点击 -r($tester->program->isClickable($program1, 'activate')) && p('') && e('0'); // 传入项目集1,动作为activate,判断是否可点击 -r($tester->program->isClickable($program1, 'suspend')) && p('') && e('1'); // 传入项目集1,动作为suspend,判断是否可点击 -r($tester->program->isClickable($program2, 'close')) && p('') && e('1'); // 传入项目集2,动作为closed,判断是否可点击 -r($tester->program->isClickable($program2, 'activate')) && p('') && e('0'); // 传入项目集2,动作为activate,判断是否可点击 -r($tester->program->isClickable($program2, 'suspend')) && p('') && e('1'); // 传入项目集2,动作为activate,判断是否可点击 \ No newline at end of file +r($programTester->isClickableTest($program1, 'close')) && p('') && e('1'); // 传入项目集1,动作为closed,判断是否可点击 +r($programTester->isClickableTest($program1, 'activate')) && p('') && e('0'); // 传入项目集1,动作为activate,判断是否可点击 +r($programTester->isClickableTest($program1, 'suspend')) && p('') && e('1'); // 传入项目集1,动作为suspend,判断是否可点击 +r($programTester->isClickableTest($program2, 'close')) && p('') && e('1'); // 传入项目集2,动作为closed,判断是否可点击 +r($programTester->isClickableTest($program2, 'activate')) && p('') && e('0'); // 传入项目集2,动作为activate,判断是否可点击 +r($programTester->isClickableTest($program2, 'suspend')) && p('') && e('1'); // 传入项目集2,动作为activate,判断是否可点击 From af9a2f108cac9ce96d2d3d887a72d85313dd44cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E6=B7=91=E6=9D=B0?= Date: Thu, 5 Jan 2023 14:21:53 +0800 Subject: [PATCH 12/59] * Add case for program model. --- test/class/program.class.php | 12 ++++++++ test/model/program/getchildren.php | 6 ++-- test/model/program/getinvolvedprograms.php | 33 ++++++++++++++-------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/test/class/program.class.php b/test/class/program.class.php index c65d29e731..27412bcd18 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -174,4 +174,16 @@ class programTest { return $this->program->isClickable($programID, $status); } + + /** + * get involved programs. + * + * @param string $account + * @access public + * @return array + */ + public function getInvolvedProgramsTest($account) + { + return $this->program->getInvolvedPrograms($account); + } } diff --git a/test/model/program/getchildren.php b/test/model/program/getchildren.php index d22267f467..19605353f6 100755 --- a/test/model/program/getchildren.php +++ b/test/model/program/getchildren.php @@ -8,11 +8,9 @@ $program = zdTable('project'); $program->id->range('1-3'); $program->name->range('父项目集1,子项目集1,子项目集2'); $program->parent->range('0,1,1'); +$program->grade->range('1,2,2'); $program->type->range('program'); -$program->path->setFields(array( - array('field' => 'path1', 'range' => '1', 'prefix' => ',', 'postfix' => ','), - array('field' => 'path2', 'range' => '[],2,3', 'postfix' => ',') -)); +$program->path->range('`,1,`,`,1,2,`,`,1,3,`'); $program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); $program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); $program->gen(3); diff --git a/test/model/program/getinvolvedprograms.php b/test/model/program/getinvolvedprograms.php index e593aaf7d8..7f5bc688d6 100755 --- a/test/model/program/getinvolvedprograms.php +++ b/test/model/program/getinvolvedprograms.php @@ -1,8 +1,20 @@ #!/usr/bin/env php id->range('1-3'); +$program->name->range('1-3')->prefix('项目集'); +$program->type->range('program'); +$program->path->range('1-3')->prefix(',')->postfix(','); +$program->grade->range('1'); +$program->openedBy->range('admin,test1'); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->gen(3); + /** title=测试 programModel::getInvolvedPrograms(); @@ -10,18 +22,17 @@ cid=1 pid=1 获取admin参与的项目集数量 >> 2 -获取test2参与的项目集数量 >> 1 -获取admin参与的项目集ID >> 10 -获取test2参与的项目集ID >> 1 +获取test1参与的项目集数量 >> 1 +获取admin参与的项目集ID >> 1 +获取test1参与的项目集ID >> 2 */ -global $tester; -$tester->loadModel('program'); -$adminPrograms = $tester->program->getInvolvedPrograms('admin'); -$test2Programs = $tester->program->getInvolvedPrograms('test2'); +$programTester = new programTest(); +$adminPrograms = $programTester->getInvolvedProgramsTest('admin'); +$test1Programs = $programTester->getInvolvedProgramsTest('test1'); -r(count($adminPrograms)) && p() && e('2'); // 获取admin参与的项目集数量 -r(count($test2Programs)) && p() && e('1'); // 获取test2参与的项目集数量 -r($adminPrograms) && p('10') && e('10'); // 获取admin参与的项目集ID -r($test2Programs) && p('1') && e('1'); // 获取test2参与的项目集ID \ No newline at end of file +r(count($adminPrograms)) && p() && e('2'); // 获取admin参与的项目集数量 +r(count($test1Programs)) && p() && e('1'); // 获取test1参与的项目集数量 +r($adminPrograms) && p('1') && e('1'); // 获取admin参与的项目集ID +r($test1Programs) && p('2') && e('2'); // 获取test1参与的项目集ID From 3a8c6ac3410636ea8bc120e85d22e77f24415125 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 5 Jan 2023 14:27:00 +0800 Subject: [PATCH 13/59] * Update test case for hasunfinished. --- test/class/program.class.php | 13 +++++++++++++ test/model/program/hasunfinished.php | 25 +++++++++++++++++-------- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/test/class/program.class.php b/test/class/program.class.php index c65d29e731..3500eddca9 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -174,4 +174,17 @@ class programTest { return $this->program->isClickable($programID, $status); } + + /** + * Has unfinished. + * + * @param int $programID + * @access public + * @return int + */ + public function hasUnfinishedTest($programID) + { + $program = $this->program->getByID($programID); + return $this->program->hasUnfinished($program); + } } diff --git a/test/model/program/hasunfinished.php b/test/model/program/hasunfinished.php index 5a1cd2665c..ee4c1e7aa0 100755 --- a/test/model/program/hasunfinished.php +++ b/test/model/program/hasunfinished.php @@ -1,23 +1,32 @@ #!/usr/bin/env php id->range('1-5'); +$program->name->range('项目集1,项目集2'); +$program->type->range('program'); +$program->status->range('wait'); +$program->parent->range('0,0,1,1,2'); +$program->path->range('1,2,`1,3`,`1,4`,`2,5`')->prefix(',')->postfix(','); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->gen(5); + /** title=测试 programModel::hasUnfinished(); cid=1 pid=1 -获取项目集1下未完成的项目和项目集数量 >> 9 -获取项目集2下未完成的项目和项目集数量 >> 7 +获取项目集1下未完成的项目和项目集数量 >> 2 +获取项目集2下未完成的项目和项目集数量 >> 1 */ -global $tester; -$tester->loadModel('program'); -$program1 = $tester->program->getById(1); -$program2 = $tester->program->getById(2); +$programTester = new programTest(); -r($tester->program->hasUnfinished($program1)) && p() && e('9'); // 获取项目集1下未完成的项目和项目集数量 -r($tester->program->hasUnfinished($program2)) && p() && e('7'); // 获取项目集2下未完成的项目和项目集数量 \ No newline at end of file +r($programTester->hasUnfinishedTest(1)) && p() && e('2'); // 获取项目集1下未完成的项目和项目集数量 +r($programTester->hasUnfinishedTest(2)) && p() && e('1'); // 获取项目集2下未完成的项目和项目集数量 From ccbfbcf1d2ee3d3a5bf3b180dbb918ccb6faf660 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Thu, 5 Jan 2023 14:37:35 +0800 Subject: [PATCH 14/59] * Test case for gettreemenu. --- test/class/program.class.php | 12 ++++++++++++ test/model/program/gettreemenu.php | 23 +++++++++++++++++------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/test/class/program.class.php b/test/class/program.class.php index eea5e51baf..f223f5bce5 100644 --- a/test/class/program.class.php +++ b/test/class/program.class.php @@ -199,4 +199,16 @@ class programTest { return $this->program->getInvolvedPrograms($account); } + + /* + * Get Tree menu. + * + * @param string $programID + * @access public + * @return array + */ + public function getTreeMenuTest($programID) + { + return $this->program->getTreeMenu($programID); + } } diff --git a/test/model/program/gettreemenu.php b/test/model/program/gettreemenu.php index f73d77e4e4..e9a4504fc4 100755 --- a/test/model/program/gettreemenu.php +++ b/test/model/program/gettreemenu.php @@ -1,6 +1,19 @@ #!/usr/bin/env php id->range('1-5'); +$program->name->range('项目集1,项目集2'); +$program->type->range('program'); +$program->status->range('wait'); +$program->parent->range('0,0,1,1,2'); +$program->path->range('1,2,`1,3`,`1,4`,`2,5`')->prefix(',')->postfix(','); +$program->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD'); +$program->gen(5); /** @@ -8,12 +21,10 @@ title=测试 programModel::getTreeMenu(); cid=1 pid=1 -查看返回的字符个数 >> 789 +查看返回的字符个数 >> 396 */ +$programTester = new programTest(); +$programs1 = $programTester->getTreeMenuTest(1); -global $tester; -$tester->loadModel('program'); -$programs1 = $tester->program->getTreeMenu(1); - -r(strlen($programs1)) && p() && e('789'); // 查看返回的字符个数 \ No newline at end of file +r(strlen($programs1)) && p() && e('396'); // 查看返回的字符个数 From 03d913eb7813fb214a77e408c3ca7adea0f31f14 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Thu, 5 Jan 2023 14:38:07 +0800 Subject: [PATCH 15/59] * Modify unit test of user. --- test/class/user.class.php | 30 ++++++++++++++----- test/model/user/getavatarpairs.php | 27 ++++++++++++++--- test/model/user/getcommiters.php | 12 ++++++-- test/model/user/getlist.php | 34 ++++++++++++++++----- test/model/user/getlistbyaccounts.php | 33 +++++++++++++++----- test/model/user/getpairs.php | 38 +++++++++++++++--------- test/model/user/getrealnameandemails.php | 26 ++++++++++++---- test/model/user/setuserlist.php | 34 +++++++++++++++++++++ 8 files changed, 187 insertions(+), 47 deletions(-) create mode 100755 test/model/user/setuserlist.php diff --git a/test/class/user.class.php b/test/class/user.class.php index dcf7725a2f..7f78827947 100755 --- a/test/class/user.class.php +++ b/test/class/user.class.php @@ -14,9 +14,9 @@ class userTest * @access public * @return void */ - public function getListTest($count = false) + public function getListTest($params = 'nodeleted', $count = false) { - $objects = $this->objectModel->getList(); + $objects = $this->objectModel->getList($params); if(dao::isError()) { $error = dao::getError(); @@ -32,13 +32,14 @@ class userTest * Test get user information by accounts. * * @param array $accounts + * @param string $keyField * @param bool $count * @access public * @return void */ - public function getListByAccountsTest($accounts = array(), $count = false) + public function getListByAccountsTest($accounts = array(), $keyField = 'id', $count = false) { - $objects = $this->objectModel->getListByAccounts($accounts); + $objects = $this->objectModel->getListByAccounts($accounts, $keyField); if(dao::isError()) { $error = dao::getError(); @@ -77,12 +78,13 @@ class userTest /** * Test get avatar pairs. * + * @param string $params * @access public - * @return void + * @return array */ - public function getAvatarPairsTest() + public function getAvatarPairsTest($param = 'nodeleted') { - $objects = $this->objectModel->getAvatarPairs(); + $objects = $this->objectModel->getAvatarPairs($param); if(dao::isError()) { $error = dao::getError(); @@ -955,4 +957,18 @@ class userTest { return $this->objectModel->processAccountSort($users); } + + /** + * Set users list. + * + * @param array $users + * @param string $account + * @access public + * @return string + */ + public function setUserListTest($users, $account) + { + $string = $this->objectModel->setUserList($users, $account); + return strpos($string, "