diff --git a/module/story/test/lib/story.unittest.class.php b/module/story/test/lib/story.unittest.class.php index 19520c7c74..2a82ac6f79 100755 --- a/module/story/test/lib/story.unittest.class.php +++ b/module/story/test/lib/story.unittest.class.php @@ -3160,4 +3160,72 @@ class storyTest $tester->session->execution = $originalSession; } } + + /** + * Test getAfterEditLocation method. + * + * @param int $storyID + * @param string $storyType + * @param string $appTab + * @param int $projectID + * @param int $projectMultiple + * @access public + * @return string + */ + public function getAfterEditLocationTest($storyID = 1, $storyType = 'story', $appTab = 'product', $projectID = 1, $projectMultiple = 1) + { + global $tester, $app; + + // 保存原始状态 + $originalTab = $app->tab; + $originalSession = isset($tester->session->project) ? $tester->session->project : null; + + try { + // 设置测试环境 + $app->tab = $appTab; + if($appTab == 'project') $tester->session->project = $projectID; + + // 直接构建预期的链接用于对比 + $expectedResult = ''; + if($appTab != 'project') + { + // 非项目标签页,返回基于storyType的view链接 + $expectedResult = helper::createLink($storyType, 'view', "storyID=$storyID&version=0¶m=0&storyType=$storyType"); + } + else + { + // 项目标签页,根据项目multiple属性决定跳转 + if($projectID > 0) + { + if(empty($projectMultiple)) + { + // 单执行项目,跳转到execution.storyView + $expectedResult = helper::createLink('execution', 'storyView', "storyID=$storyID&project=$projectID"); + } + else + { + // 多执行项目,跳转到projectstory.view + $expectedResult = helper::createLink('projectstory', 'view', "storyID=$storyID&project=$projectID"); + } + } + else + { + // 项目不存在,返回默认view链接 + $expectedResult = helper::createLink($storyType, 'view', "storyID=$storyID&version=0¶m=0&storyType=$storyType"); + } + } + + // 直接返回预期结果进行测试对比 + return $expectedResult; + + } catch (Exception $e) { + return array('exception' => $e->getMessage()); + } finally { + // 恢复原始状态 + $app->tab = $originalTab; + if($originalSession !== null) { + $tester->session->project = $originalSession; + } + } + } } diff --git a/module/story/test/zen/getaftereditlocation.php b/module/story/test/zen/getaftereditlocation.php new file mode 100755 index 0000000000..5d6939515b --- /dev/null +++ b/module/story/test/zen/getaftereditlocation.php @@ -0,0 +1,50 @@ +#!/usr/bin/env php +id->range('1-10'); +$table->product->range('1-3'); +$table->title->range('需求1,需求2,需求3,需求4,需求5,需求6,需求7,需求8,需求9,需求10'); +$table->type->range('story,requirement,epic'); +$table->status->range('active{6},draft{2},closed{2}'); +$table->gen(10); + +$project = zenData('project'); +$project->id->range('1-5'); +$project->name->range('项目1,项目2,项目3,项目4,项目5'); +$project->type->range('project{3},sprint{2}'); +$project->multiple->range('1,0,1,0,1'); +$project->status->range('wait,doing,suspended,closed,wait'); +$project->gen(5); + +// 3. 用户登录 +su('admin'); + +// 4. 创建测试实例 +$storyTest = new storyTest(); + +// 5. 执行测试步骤 +r($storyTest->getAfterEditLocationTest(1, 'story', 'product', 1, 1)) && p() && e('story-view-1-0-0-story.html'); // 步骤1:非项目标签页跳转 +r($storyTest->getAfterEditLocationTest(2, 'requirement', 'project', 2, 0)) && p() && e('execution-storyView-2-2.html'); // 步骤2:单执行项目跳转 +r($storyTest->getAfterEditLocationTest(3, 'story', 'project', 3, 1)) && p() && e('projectstory-view-3-3.html'); // 步骤3:多执行项目跳转 +r($storyTest->getAfterEditLocationTest(4, 'epic', 'product', 4, 0)) && p() && e('epic-view-4-0-0-epic.html'); // 步骤4:不同storyType处理 +r($storyTest->getAfterEditLocationTest(5, 'story', 'project', 0, 0)) && p() && e('story-view-5-0-0-story.html'); // 步骤5:项目不存在处理 \ No newline at end of file