GeezerVison is showing github.com — feat: #14 project setting get issue status · coding/coding-sdk-php@4bdc774
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/ProjectSetting.php +16Lines changed: 16 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | namespace Coding; | 4 | 4 |
| | 5 | +use Illuminate\Validation\Rule; | | 6 | + | 5 | 7 | class ProjectSetting extends Base | 6 | 8 | { | 7 | 9 | public function getIssueTypes(array $data) | @@ -12,4 +14,18 @@ public function getIssueTypes(array $data) | 12 | 14 | $response = $this->core->request('DescribeProjectIssueTypeList', $data); | 13 | 15 | return $response['IssueTypes']; | 14 | 16 | } | | 17 | + | | 18 | + public function getIssueStatus(array $data) | | 19 | + { | | 20 | + $this->validate($data, [ | | 21 | + 'ProjectName' => 'string|required', | | 22 | + 'IssueType' => [ | | 23 | + 'required', | | 24 | + Rule::in(Issue::TYPE), | | 25 | + ], | | 26 | + 'IssueTypeId' => 'nullable|integer', | | 27 | + ]); | | 28 | + $response = $this->core->request('DescribeProjectIssueStatusList', $data); | | 29 | + return $response['ProjectIssueStatusList']; | | 30 | + } | 15 | 31 | } |
Collapse file Copy file name to clipboardExpand all lines: tests/ProjectSettingTest.php +22Lines changed: 22 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | namespace Coding\Tests; | 4 | 4 |
| | 5 | +use Coding\Issue; | 5 | 6 | use Coding\ProjectSetting; | 6 | 7 |
| 7 | 8 | class ProjectSettingTest extends TestCase | @@ -24,4 +25,25 @@ public function testGetIssueTypes() | 24 | 25 | $result = $projectSetting->getIssueTypes($data); | 25 | 26 | $this->assertEquals($response['IssueTypes'], $result); | 26 | 27 | } | | 28 | + | | 29 | + public function testGetIssueStatus() | | 30 | + { | | 31 | + $response = json_decode( | | 32 | + file_get_contents($this->dataPath('DescribeProjectIssueStatusListResponse.json')), | | 33 | + true | | 34 | + )['Response']; | | 35 | + $data = [ | | 36 | + 'ProjectName' => $this->projectName, | | 37 | + 'IssueType' => $this->faker->randomElement(Issue::TYPE), | | 38 | + 'IssueTypeId' => $this->faker->randomNumber(), | | 39 | + ]; | | 40 | + $this->coreMock->shouldReceive('request')->times(1)->withArgs([ | | 41 | + 'DescribeProjectIssueStatusList', | | 42 | + $data | | 43 | + ])->andReturn($response); | | 44 | + | | 45 | + $projectSetting = new ProjectSetting($this->token, $this->coreMock); | | 46 | + $result = $projectSetting->getIssueStatus($data); | | 47 | + $this->assertEquals($response['ProjectIssueStatusList'], $result); | | 48 | + } | 27 | 49 | } |
Collapse file Copy file name to clipboard +79Lines changed: 79 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "Response" : { | | 3 | + "ProjectIssueStatusList" : [ | | 4 | + { | | 5 | + "CreatedAt" : 1634639726000, | | 6 | + "IsDefault" : true, | | 7 | + "IssueStatus" : { | | 8 | + "CreatedAt" : 1572178128000, | | 9 | + "Description" : "", | | 10 | + "Id" : 1227034, | | 11 | + "Index" : 3, | | 12 | + "IsSystem" : true, | | 13 | + "Name" : "未开始", | | 14 | + "Type" : "TODO", | | 15 | + "UpdatedAt" : 1572178128000 | | 16 | + }, | | 17 | + "IssueStatusId" : 1227034, | | 18 | + "IssueType" : "REQUIREMENT", | | 19 | + "Sort" : 0, | | 20 | + "UpdatedAt" : 1634639726000 | | 21 | + }, | | 22 | + { | | 23 | + "CreatedAt" : 1634639726000, | | 24 | + "IsDefault" : false, | | 25 | + "IssueStatus" : { | | 26 | + "CreatedAt" : 1572178128000, | | 27 | + "Description" : "", | | 28 | + "Id" : 1227037, | | 29 | + "Index" : 4, | | 30 | + "IsSystem" : true, | | 31 | + "Name" : "处理中", | | 32 | + "Type" : "PROCESSING", | | 33 | + "UpdatedAt" : 1572178128000 | | 34 | + }, | | 35 | + "IssueStatusId" : 1227037, | | 36 | + "IssueType" : "REQUIREMENT", | | 37 | + "Sort" : 0, | | 38 | + "UpdatedAt" : 1634639726000 | | 39 | + }, | | 40 | + { | | 41 | + "CreatedAt" : 1634639726000, | | 42 | + "IsDefault" : false, | | 43 | + "IssueStatus" : { | | 44 | + "CreatedAt" : 1572178128000, | | 45 | + "Description" : "", | | 46 | + "Id" : 1227040, | | 47 | + "Index" : 5, | | 48 | + "IsSystem" : true, | | 49 | + "Name" : "待验证", | | 50 | + "Type" : "PROCESSING", | | 51 | + "UpdatedAt" : 1572178128000 | | 52 | + }, | | 53 | + "IssueStatusId" : 1227040, | | 54 | + "IssueType" : "REQUIREMENT", | | 55 | + "Sort" : 0, | | 56 | + "UpdatedAt" : 1634639726000 | | 57 | + }, | | 58 | + { | | 59 | + "CreatedAt" : 1634639726000, | | 60 | + "IsDefault" : false, | | 61 | + "IssueStatus" : { | | 62 | + "CreatedAt" : 1572178128000, | | 63 | + "Description" : "", | | 64 | + "Id" : 1227058, | | 65 | + "Index" : 11, | | 66 | + "IsSystem" : true, | | 67 | + "Name" : "已完成", | | 68 | + "Type" : "COMPLETED", | | 69 | + "UpdatedAt" : 1572178128000 | | 70 | + }, | | 71 | + "IssueStatusId" : 1227058, | | 72 | + "IssueType" : "REQUIREMENT", | | 73 | + "Sort" : 0, | | 74 | + "UpdatedAt" : 1634639726000 | | 75 | + } | | 76 | + ], | | 77 | + "RequestId" : "3a8bb049-e28f-01c9-9990-0f17b92952c4" | | 78 | + } | | 79 | +} |
|