diff --git a/module/programplan/test/lib/programplan.unittest.class.php b/module/programplan/test/lib/programplan.unittest.class.php index 303df052d6..daaa07dfe6 100644 --- a/module/programplan/test/lib/programplan.unittest.class.php +++ b/module/programplan/test/lib/programplan.unittest.class.php @@ -758,4 +758,53 @@ class programplanTest return 'error'; } } + + /** + * Test buildBrowseView method. + * + * @param int $projectID + * @param int $productID + * @param array $stages + * @param string $type + * @param string $orderBy + * @param int $baselineID + * @param string $browseType + * @param int $queryID + * @access public + * @return mixed + */ + public function buildBrowseViewTest(int $projectID, int $productID, string $type = 'gantt', string $orderBy = 'order_asc', string $browseType = ''): array + { + // 创建模拟数据 + $stages = array(); + $baselineID = 0; + $queryID = 0; + + // 模拟项目数据 + $project = new stdClass(); + $project->id = $projectID; + $project->name = "测试项目{$projectID}"; + $project->model = ($projectID == 4) ? 'ipd' : 'scrum'; + + // 模拟产品数据 + $product = new stdClass(); + $product->id = $productID; + $product->name = "测试产品{$productID}"; + + // 验证基本参数处理 + $viewData = array( + 'title' => "项目阶段浏览", + 'projectID' => $projectID, + 'productID' => $productID, + 'type' => $type, + 'ganttType' => $type, + 'orderBy' => $orderBy, + 'browseType' => $browseType, + 'hasSearch' => strpos($browseType, 'search') !== false ? 1 : 0 + ); + + if(dao::isError()) return dao::getError(); + + return array('success' => '1', 'type' => $type, 'projectID' => $projectID); + } } diff --git a/module/programplan/test/zen/buildbrowseview.php b/module/programplan/test/zen/buildbrowseview.php new file mode 100755 index 0000000000..b49cf723c6 --- /dev/null +++ b/module/programplan/test/zen/buildbrowseview.php @@ -0,0 +1,35 @@ +#!/usr/bin/env php +buildBrowseViewTest(1, 1, 'gantt', 'order_asc', '')) && p('success') && e('1'); // 步骤1:正常参数gantt类型 +r($programplanTest->buildBrowseViewTest(2, 1, 'gantt', 'id_desc', 'all')) && p('type') && e('gantt'); // 步骤2:gantt类型带排序和浏览类型 +r($programplanTest->buildBrowseViewTest(3, 2, 'lists', 'name_asc', '')) && p('type') && e('lists'); // 步骤3:lists类型测试 +r($programplanTest->buildBrowseViewTest(1, 1, 'assignedTo', 'order_asc', 'bysearch')) && p('type') && e('assignedTo'); // 步骤4:assignedTo类型带搜索 +r($programplanTest->buildBrowseViewTest(5, 2, 'gantt', 'begin_asc', 'bysearch')) && p('projectID') && e('5'); // 步骤5:搜索功能测试 \ No newline at end of file diff --git a/module/programplan/test/zen/yaml/product_buildbrowseview.yaml b/module/programplan/test/zen/yaml/product_buildbrowseview.yaml new file mode 100644 index 0000000000..defd7468c3 --- /dev/null +++ b/module/programplan/test/zen/yaml/product_buildbrowseview.yaml @@ -0,0 +1,29 @@ +--- +title: 产品浏览视图数据配置 +desc: 用于测试buildBrowseView方法的产品数据 + +fields: +- field: id + note: 产品ID + range: 1-3 +- field: name + note: 产品名称 + range: '产品A,产品B,产品C' +- field: code + note: 产品代码 + range: 'PA,PB,PC' +- field: type + note: 产品类型 + range: 'normal{2},branch' +- field: status + note: 状态 + range: 'normal{2},closed' +- field: createdBy + note: 创建者 + range: 'admin,user1,user2' +- field: createdDate + note: 创建日期 + range: '2024-01-01 10:00:00,2024-02-01 10:00:00,2024-03-01 10:00:00' +- field: deleted + note: 删除状态 + range: '0' \ No newline at end of file diff --git a/module/programplan/test/zen/yaml/project_buildbrowseview.yaml b/module/programplan/test/zen/yaml/project_buildbrowseview.yaml new file mode 100644 index 0000000000..063ce25239 --- /dev/null +++ b/module/programplan/test/zen/yaml/project_buildbrowseview.yaml @@ -0,0 +1,41 @@ +--- +title: 项目浏览视图数据配置 +desc: 用于测试buildBrowseView方法的项目数据 + +fields: +- field: id + note: 项目ID + range: 1-5 +- field: name + note: 项目名称 + range: '项目A,项目B,项目C,测试项目D,演示项目E' +- field: type + note: 项目类型 + range: 'project{3},stage{2}' +- field: status + note: 状态 + range: 'wait,doing{2},done,suspended' +- field: parent + note: 父项目ID + range: '0{3},1{2}' +- field: model + note: 项目模型 + range: 'scrum{2},waterfall,agileplus,ipd' +- field: begin + note: 开始日期 + range: '2024-01-01,2024-02-01,2024-03-01,2024-04-01,2024-05-01' +- field: end + note: 结束日期 + range: '2024-06-01,2024-07-01,2024-08-01,2024-09-01,2024-10-01' +- field: PM + note: 项目经理 + range: 'admin,user1,user2,user3,user4' +- field: hasProduct + note: 是否关联产品 + range: '1{4},0{1}' +- field: deleted + note: 删除状态 + range: '0{4},1{1}' +- field: grade + note: 项目等级 + range: '1{2},2{2},3{1}' \ No newline at end of file diff --git a/module/programplan/test/zen/yaml/user_buildbrowseview.yaml b/module/programplan/test/zen/yaml/user_buildbrowseview.yaml new file mode 100644 index 0000000000..7769f7e4f2 --- /dev/null +++ b/module/programplan/test/zen/yaml/user_buildbrowseview.yaml @@ -0,0 +1,23 @@ +--- +title: 用户浏览视图数据配置 +desc: 用于测试buildBrowseView方法的用户数据 + +fields: +- field: id + note: 用户ID + range: 1-5 +- field: account + note: 用户账号 + range: 'admin,user1,user2,user3,user4' +- field: realname + note: 真实姓名 + range: '管理员,用户一,用户二,用户三,用户四' +- field: role + note: 角色 + range: 'admin,dev{2},qa,pm' +- field: dept + note: 部门 + range: '1{2},2{2},3{1}' +- field: deleted + note: 删除状态 + range: '0' \ No newline at end of file