Skip to content

Commit

Permalink
fix: #72 get type status need id
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkcup committed Oct 22, 2021
1 parent 208ee18 commit 5f9c171
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 124 deletions.
3 changes: 2 additions & 1 deletion app/Coding/ProjectSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getIssueTypes($token, $projectName)
return $result['Response']['IssueTypes'];
}

public function getIssueTypeStatus(string $token, string $projectName, string $issueType)
public function getIssueTypeStatus(string $token, string $projectName, string $issueType, int $issueTypeId)
{
$response = $this->client->request('POST', 'https://e.coding.net/open-api', [
'headers' => [
Expand All @@ -33,6 +33,7 @@ public function getIssueTypeStatus(string $token, string $projectName, string $i
'Action' => 'DescribeProjectIssueStatusList',
'ProjectName' => $projectName,
'IssueType' => $issueType,
'IssueTypeId' => $issueTypeId,
],
]);
$result = json_decode($response->getBody(), true);
Expand Down
17 changes: 11 additions & 6 deletions app/Commands/IssueImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,21 @@ private function getIssueTypes(ProjectSetting $projectSetting, array $row): void
}
}

private function getStatusId(ProjectSetting $projectSetting, string $issueType, string $statusChinese): int
private function getStatusId(ProjectSetting $projectSetting, string $issueTypeName, string $statusName): int
{
if (!isset($this->issueTypeStatus[$issueType])) {
$result = $projectSetting->getIssueTypeStatus($this->codingToken, $this->codingProjectUri, $issueType);
if (!isset($this->issueTypeStatus[$issueTypeName])) {
$type = $this->issueTypes[$issueTypeName]['IssueType'];
$typeId = $this->issueTypes[$issueTypeName]['Id'];
$result = $projectSetting->getIssueTypeStatus($this->codingToken, $this->codingProjectUri, $type, $typeId);
foreach ($result as $item) {
$tmp = $item['IssueStatus'];
$this->issueTypeStatus[$issueType][$tmp['Name']] = $tmp['Id'];
$this->issueTypeStatus[$issueTypeName][$tmp['Name']] = $tmp['Id'];
}
}
return intval($this->issueTypeStatus[$issueType][$statusChinese]);
if (!isset($this->issueTypeStatus[$issueTypeName][$statusName])) {
throw new Exception('' . $statusName . '」不存在,请在设置中添加');
}
return intval($this->issueTypeStatus[$issueTypeName][$statusName]);
}

private function createIssueByRow(ProjectSetting $projectSetting, Issue $issue, Iteration $iteration, array $row)
Expand Down Expand Up @@ -127,7 +132,7 @@ private function createIssueByRow(ProjectSetting $projectSetting, Issue $issue,
}
}
if (!empty($row['状态'])) {
$data['StatusId'] = $this->getStatusId($projectSetting, $data['Type'], $row['状态']);
$data['StatusId'] = $this->getStatusId($projectSetting, $row['事项类型'], $row['状态']);
}
$result = $issue->create($this->codingToken, $this->codingProjectUri, $data);
if (isset($row['ID'])) {
Expand Down
1 change: 0 additions & 1 deletion app/Commands/ProjectGetIssueTypesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Commands;

use App\Coding\Issue;
use App\Coding\ProjectSetting;
use LaravelZero\Framework\Commands\Command;

Expand Down
18 changes: 6 additions & 12 deletions tests/Feature/IssueImportCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,8 @@ public function testImportSuccess()
$projectSettingMock->shouldReceive('getIssueTypeStatus')->times(5)->andReturn(
$requirementStatus,
$requirementStatus,
[
['IssueStatus' => ['Id' => 11, 'Name' => '已完成']],
['IssueStatus' => ['Id' => 12, 'Name' => '处理中']],
],
[
['IssueStatus' => ['Id' => 11, 'Name' => '未开始']],
['IssueStatus' => ['Id' => 12, 'Name' => '处理中']],
],
$requirementStatus,
$requirementStatus,
[
['IssueStatus' => ['Id' => 22, 'Name' => '处理中']],
['IssueStatus' => ['Id' => 23, 'Name' => '待处理']],
Expand Down Expand Up @@ -125,7 +119,7 @@ public function testImportUserStorySuccess()
'IterationCode' => 2746,
'DueDate' => '2021-10-21',
'StoryPoint' => '2',
'StatusId' => 9,
'StatusId' => 1227037,
]
])->andReturn($result);

Expand Down Expand Up @@ -168,7 +162,7 @@ public function testImportSubTask()
'Name' => '用户可通过手机号注册账户',
'DueDate' => '2021-10-21',
'StoryPoint' => '2',
'StatusId' => 9,
'StatusId' => 1227037,
]
])->andReturn($parentIssue);

Expand All @@ -183,7 +177,7 @@ public function testImportSubTask()
'Name' => '完成手机号注册的短信验证码发送接口',
'Priority' => "0",
'ParentCode' => 2742,
'StatusId' => 13,
'StatusId' => 1227058,
]
])->andReturn($subTask1);

Expand All @@ -198,7 +192,7 @@ public function testImportSubTask()
'Name' => '完成通过手机号注册用户的接口',
'Priority' => "1",
'ParentCode' => 2742,
'StatusId' => 13,
'StatusId' => 1227058,
]
])->andReturn($subTask2);

Expand Down
4 changes: 3 additions & 1 deletion tests/Unit/CodingProjectSettingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function testGetIssueTypeStatusSuccess()
$codingProjectUri = $this->faker->slug;

$issueType = $this->faker->randomElement(['DEFECT', 'REQUIREMENT', 'MISSION', 'EPIC', 'SUB_TASK']);
$issueTypeId = $this->faker->randomNumber();
$clientMock = $this->getMockBuilder(Client::class)->getMock();
$clientMock->expects($this->once())
->method('request')
Expand All @@ -62,12 +63,13 @@ public function testGetIssueTypeStatusSuccess()
'Action' => 'DescribeProjectIssueStatusList',
'ProjectName' => $codingProjectUri,
'IssueType' => $issueType,
'IssueTypeId' => $issueTypeId,
])
]
)
->willReturn(new Response(200, [], $responseBody));
$coding = new ProjectSetting($clientMock);
$result = $coding->getIssueTypeStatus($codingToken, $codingProjectUri, $issueType);
$result = $coding->getIssueTypeStatus($codingToken, $codingProjectUri, $issueType, $issueTypeId);
$this->assertEquals(json_decode($responseBody, true)['Response']['ProjectIssueStatusList'], $result);
}
}
136 changes: 68 additions & 68 deletions tests/data/coding/DescribeProjectIssueStatusListResponse.json
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
{
"Response": {
"RequestId": "dc827006-32db-a74f-eeae-13bec31c8b92",
"ProjectIssueStatusList": [
"Response" : {
"ProjectIssueStatusList" : [
{
"IssueType": "REQUIREMENT",
"IssueStatusId": 4,
"IsDefault": true,
"CreatedAt": 1597283400000,
"UpdatedAt": 1597283400000,
"Sort": 0,
"IssueStatus": {
"Id": 4,
"Index": 3,
"Name": "未开始",
"Type": "TODO",
"Description": "",
"IsSystem": true,
"CreatedAt": 1597283396000,
"UpdatedAt": 1597283396000
}
"CreatedAt" : 1634639726000,
"IsDefault" : true,
"IssueStatus" : {
"CreatedAt" : 1572178128000,
"Description" : "",
"Id" : 1227034,
"Index" : 3,
"IsSystem" : true,
"Name" : "未开始",
"Type" : "TODO",
"UpdatedAt" : 1572178128000
},
"IssueStatusId" : 1227034,
"IssueType" : "REQUIREMENT",
"Sort" : 0,
"UpdatedAt" : 1634639726000
},
{
"IssueType": "REQUIREMENT",
"IssueStatusId": 9,
"IsDefault": false,
"CreatedAt": 1597283400000,
"UpdatedAt": 1597283400000,
"Sort": 0,
"IssueStatus": {
"Id": 9,
"Index": 8,
"Name": "开发中",
"Type": "PROCESSING",
"Description": "",
"IsSystem": true,
"CreatedAt": 1597283396000,
"UpdatedAt": 1597283396000
}
"CreatedAt" : 1634639726000,
"IsDefault" : false,
"IssueStatus" : {
"CreatedAt" : 1572178128000,
"Description" : "",
"Id" : 1227037,
"Index" : 4,
"IsSystem" : true,
"Name" : "处理中",
"Type" : "PROCESSING",
"UpdatedAt" : 1572178128000
},
"IssueStatusId" : 1227037,
"IssueType" : "REQUIREMENT",
"Sort" : 0,
"UpdatedAt" : 1634639726000
},
{
"IssueType": "REQUIREMENT",
"IssueStatusId": 10,
"IsDefault": false,
"CreatedAt": 1597283400000,
"UpdatedAt": 1597283400000,
"Sort": 0,
"IssueStatus": {
"Id": 10,
"Index": 9,
"Name": "测试中",
"Type": "PROCESSING",
"Description": "",
"IsSystem": true,
"CreatedAt": 1597283396000,
"UpdatedAt": 1597283396000
}
"CreatedAt" : 1634639726000,
"IsDefault" : false,
"IssueStatus" : {
"CreatedAt" : 1572178128000,
"Description" : "",
"Id" : 1227040,
"Index" : 5,
"IsSystem" : true,
"Name" : "待验证",
"Type" : "PROCESSING",
"UpdatedAt" : 1572178128000
},
"IssueStatusId" : 1227040,
"IssueType" : "REQUIREMENT",
"Sort" : 0,
"UpdatedAt" : 1634639726000
},
{
"IssueType": "REQUIREMENT",
"IssueStatusId": 13,
"IsDefault": false,
"CreatedAt": 1597283400000,
"UpdatedAt": 1597283400000,
"Sort": 0,
"IssueStatus": {
"Id": 13,
"Index": 12,
"Name": "已完成",
"Type": "COMPLETED",
"Description": "",
"IsSystem": true,
"CreatedAt": 1597283396000,
"UpdatedAt": 1597283396000
}
"CreatedAt" : 1634639726000,
"IsDefault" : false,
"IssueStatus" : {
"CreatedAt" : 1572178128000,
"Description" : "",
"Id" : 1227058,
"Index" : 11,
"IsSystem" : true,
"Name" : "已完成",
"Type" : "COMPLETED",
"UpdatedAt" : 1572178128000
},
"IssueStatusId" : 1227058,
"IssueType" : "REQUIREMENT",
"Sort" : 0,
"UpdatedAt" : 1634639726000
}
]
],
"RequestId" : "3a8bb049-e28f-01c9-9990-0f17b92952c4"
}
}
4 changes: 2 additions & 2 deletions tests/data/coding/scrum-issue-5.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ID,事项类型,标题,描述,状态,创建时间,创建人,更新时间,所属迭代,故事点,处理人,缺陷类型,优先级,截止日期,模块,标签,关注人,开始日期
5,用户故事,用户可通过手机号注册账户,,开发中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,第 1 次迭代,2,sinkcup,,中,2021-10-21,,,,
ID,事项类型,标题,描述,状态,创建时间,创建人,更新时间,所属迭代,故事点,处理人,缺陷类型,优先级,截止日期,模块,标签,关注人,开始日期
5,用户故事,用户可通过手机号注册账户,,处理中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,第 1 次迭代,2,sinkcup,,中,2021-10-21,,,,
2 changes: 1 addition & 1 deletion tests/data/coding/scrum-issues-5-6-7.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ID,ParentCode,事项类型,标题,描述,状态,创建时间,创建人,更新时间,所属迭代,故事点,处理人,缺陷类型,优先级,截止日期,模块,标签,关注人,开始日期
7,5,子工作项,完成通过手机号注册用户的接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,中,,,,,
6,5,子工作项,完成手机号注册的短信验证码发送接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,低,,,,,
5,,用户故事,用户可通过手机号注册账户,,开发中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,2,sinkcup,,,2021-10-21,,,,
5,,用户故事,用户可通过手机号注册账户,,处理中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,2,sinkcup,,,2021-10-21,,,,
64 changes: 32 additions & 32 deletions tests/data/coding/scrum-issues.csv
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
ID,ParentCode,事项类型,标题,描述,状态,创建时间,创建人,更新时间,所属迭代,故事点,处理人,缺陷类型,优先级,截止日期,模块,标签,关注人,开始日期
23,,缺陷,商品详情页中商品价格字体应当显示为红色并且加粗,"步骤:
测试环境中,打开商品列表页;
点击任意商品进详情页。
测试结果:商品的价格字体显示为正常大小,颜色为黑色。
预期结果:商品价格字体为红色加粗。",待处理,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,,,中,,,,,
22,,缺陷,登录页输入正确的用户名和密码后提示“用户不存在”,"步骤:
测试环境中,输入URL https://mywebsite.com/login 进入登录页;
输入用户名 Admin 和密码 mypassword;
点击“登录”按钮。
测试结果:页面提示“用户不存在”。
预期结果:提示“登录成功”并且页面自动跳转到首页。",处理中,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,sinkcup,,中,,,,,
21,,任务,编制新功能的帮助文档并发布,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,,,中,,,,,
20,,任务,编写脚本将 Excel 中的线下订单转换为商城后台订单,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,,,中,,,,,
19,,任务,注册腾讯云账户,搭建测试环境和生产环境服务器,,处理中,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,第 1 次迭代,3,sinkcup,,中,2021-10-21,,,,
18,,用户故事,用户可对未支付的订单执行取消订单操作,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,,,中,,,,,
17,,用户故事,管理员可在商城后台对订单执行发货操作,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,3,,,中,,,,,
16,,用户故事,用户可在手机端搜索并查看指定的订单详情,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,1,,,中,,,,,
15,,用户故事,通过访问邀请链接可注册成为商城用户,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,,,中,,,,,
14,,用户故事,管理员可取消未发货且状态异常的订单,,未开始,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 2 次迭代,3,,,中,,,,,
13,,用户故事,用户可在“个人信息”中编辑个人基本信息,包括修改密码,,未开始,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 2 次迭代,2,sinkcup,,中,,,,,
12,,用户故事,管理员可在商城后台搜索订单,,未开始,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,2,,,中,,,,,
11,,用户故事,管理员可在商城后台手工为用户下单,,未开始,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,5,,,中,2021-10-26,,,,
10,,用户故事,用户可在个人中心的“个人信息”中查看个人信息,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,1,,,中,,,,,
9,,用户故事,用户可通过短信验证码登录商城,,开发中,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,,,,中,,,,,
8,5,子工作项,完成用户注册页面控件并集成后端接口,,处理中,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,,,,中,2021-10-21,,,,
7,5,子工作项,完成通过手机号注册用户的接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,,,,中,,,,,
6,5,子工作项,完成手机号注册的短信验证码发送接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,,,,中,,,,,
5,,用户故事,用户可通过手机号注册账户,,开发中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,第 1 次迭代,2,sinkcup,,中,2021-10-21,,,,
2,,史诗,订单管理,订单管理将实现用户的订单列表查询、订单详情、订单改价、订单地址修改、申请售后、订单取消等功能,未开始,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,,,,中,,,,,2021-10-19
1,,史诗,用户管理,用户管理将实现用户的注册、邀请、用户查询、个人信息管理、删除用户、注销账户等功能。,未开始,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,,,,中,,,,,2021-10-19
ID,ParentCode,事项类型,标题,描述,状态,创建时间,创建人,更新时间,所属迭代,故事点,处理人,缺陷类型,优先级,截止日期,模块,标签,关注人,开始日期
23,,缺陷,商品详情页中商品价格字体应当显示为红色并且加粗,"步骤:

测试环境中,打开商品列表页;
点击任意商品进详情页。
测试结果:商品的价格字体显示为正常大小,颜色为黑色。
预期结果:商品价格字体为红色加粗。",待处理,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,,,中,,,,,
22,,缺陷,登录页输入正确的用户名和密码后提示“用户不存在”,"步骤:
测试环境中,输入URL https://mywebsite.com/login 进入登录页;
输入用户名 Admin 和密码 mypassword;
点击“登录”按钮。
测试结果:页面提示“用户不存在”。
预期结果:提示“登录成功”并且页面自动跳转到首页。",处理中,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,sinkcup,,中,,,,,
21,,任务,编制新功能的帮助文档并发布,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,,,中,,,,,
20,,任务,编写脚本将 Excel 中的线下订单转换为商城后台订单,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,第 2 次迭代,5,,,中,,,,,
19,,任务,注册腾讯云账户,搭建测试环境和生产环境服务器,,处理中,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,第 1 次迭代,5,sinkcup,,中,,,,,
18,,用户故事,用户可对未支付的订单执行取消订单操作,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,,,,,中,,,,,
17,,用户故事,管理员可在商城后台对订单执行发货操作,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,第 2 次迭代,3,,,中,,,,,
16,,用户故事,用户可在手机端搜索并查看指定的订单详情,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,第 2 次迭代,1,,,中,,,,,
15,,用户故事,通过访问邀请链接可注册成为商城用户,,未开始,2021-10-19 11:26:39,sinkcup,2021-10-19 11:26:39,第 2 次迭代,2,,,中,,,,,
14,,用户故事,管理员可取消未发货且状态异常的订单,,未开始,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 2 次迭代,3,,,中,,,,,
13,,用户故事,用户可在“个人信息”中编辑个人基本信息,包括修改密码,,未开始,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 2 次迭代,2,sinkcup,,中,,,,,
12,,用户故事,管理员可在商城后台搜索订单,,未开始,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,2,,,中,,,,,
11,,用户故事,管理员可在商城后台手工为用户下单,,未开始,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,5,,,中,,,,,
10,,用户故事,用户可在个人中心的“个人信息”中查看个人信息,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,1,,,中,,,,,
9,,用户故事,用户可通过短信验证码登录商城,,处理中,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,1,,,中,,,,,
8,5,子工作项,完成用户注册页面控件并集成后端接口,,处理中,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,,,,中,,,,,
7,5,子工作项,完成通过手机号注册用户的接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,,,,中,,,,,
6,5,子工作项,完成手机号注册的短信验证码发送接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,第 1 次迭代,,,,中,,,,,
5,,用户故事,用户可通过手机号注册账户,,处理中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,第 1 次迭代,2,sinkcup,,中,,,,,
2,,史诗,订单管理,订单管理将实现用户的订单列表查询、订单详情、订单改价、订单地址修改、申请售后、订单取消等功能,未开始,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,,,,中,,,,,
1,,史诗,用户管理,用户管理将实现用户的注册、邀请、用户查询、个人信息管理、删除用户、注销账户等功能。,未开始,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,,,,中,,,,,

0 comments on commit 5f9c171

Please sign in to comment.