+ Add unit test for storyTao fixbranchstorystage method.

This commit is contained in:
wangyidong
2023-05-11 21:01:52 +08:00
parent c10ae12519
commit 714247463f
2 changed files with 53 additions and 0 deletions
+1
View File
@@ -570,6 +570,7 @@ class storyTao extends storyModel
*/
protected function fixBranchStoryStage(array $stories): array
{
if(empty($stories)) return array();
$rawQuery = $this->dao->get();
/* 获取阶段序列和关联的多分支产品需求。 */
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/story.class.php';
$product = zdTable('product');
$product->type->range('normal,branch');
$product->gen(2);
$projectproduct = zdTable('projectproduct');
$projectproduct->project->range('1-5');
$projectproduct->product->range('1-2');
$projectproduct->branch->range('0,1,2');
$projectproduct->gen(3);
$projectstory = zdTable('projectstory');
$projectstory->product->range('1-2');
$projectstory->story->range('1-50');
$projectstory->project->range('1-5');
$projectstory->branch->range('0{25},1{25}');
$projectstory->gen(50);
$storystage = zdTable('storystage');
$storystage->story->range('1-25{2}');
$storystage->branch->range('0,1');
$storystage->gen(50);
$story = zdTable('story');
$story->product->range('1');
$story->type->range('story');
$story->stage->range('wait,planned,projected,developing,developed,testing,tested,verified,released,closed');
$story->branch->range('0{25},1{25}');
$story->gen(50);
/**
title=测试 storyModel->fixBranchStoryStage();
cid=1
pid=1
*/
global $tester;
$storyModel = $tester->loadModel('story');
$stories = $storyModel->dao->select('*')->from(TABLE_STORY)->where('product')->eq(1)->andWhere('type')->eq('story')->fetchAll('id');
r($storyModel->fixBranchStoryStage(array())) && p() && e('0'); //不传入任何项目。
$oldStage = $stories[6]->stage;
$stories = $storyModel->fixBranchStoryStage($stories);
$newStage = $stories[6]->stage;
r(($oldStage == 'testing' && $newStage == 'wait')) && p() && e('1'); //传入需求,检查结果。