-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
170 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace Tests\Unit; | ||
|
||
use App\Coding\ProjectSetting; | ||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Psr7\Response; | ||
use Tests\TestCase; | ||
|
||
class CodingProjectSettingTest extends TestCase | ||
{ | ||
public function testGetIssueTypesSuccess() | ||
{ | ||
$responseBody = file_get_contents($this->dataDir . 'coding/DescribeProjectIssueTypeListResponse.json'); | ||
$codingToken = $this->faker->md5; | ||
$codingProjectUri = $this->faker->slug; | ||
|
||
$clientMock = $this->getMockBuilder(Client::class)->getMock(); | ||
$clientMock->expects($this->once()) | ||
->method('request') | ||
->with( | ||
'POST', | ||
'https://e.coding.net/open-api', | ||
[ | ||
'headers' => [ | ||
'Accept' => 'application/json', | ||
'Authorization' => "token ${codingToken}", | ||
'Content-Type' => 'application/json' | ||
], | ||
'json' => array_merge([ | ||
'Action' => 'DescribeProjectIssueTypeList', | ||
'ProjectName' => $codingProjectUri, | ||
]) | ||
] | ||
) | ||
->willReturn(new Response(200, [], $responseBody)); | ||
$coding = new ProjectSetting($clientMock); | ||
$result = $coding->getIssueTypes($codingToken, $codingProjectUri); | ||
$this->assertEquals(json_decode($responseBody, true)['Response']['IssueTypes'], $result); | ||
} | ||
|
||
public function testGetIssueTypeStatusSuccess() | ||
{ | ||
$responseBody = file_get_contents($this->dataDir . 'coding/DescribeProjectIssueStatusListResponse.json'); | ||
$codingToken = $this->faker->md5; | ||
$codingProjectUri = $this->faker->slug; | ||
|
||
$issueType = $this->faker->randomElement(['DEFECT', 'REQUIREMENT', 'MISSION', 'EPIC', 'SUB_TASK']); | ||
$clientMock = $this->getMockBuilder(Client::class)->getMock(); | ||
$clientMock->expects($this->once()) | ||
->method('request') | ||
->with( | ||
'POST', | ||
'https://e.coding.net/open-api', | ||
[ | ||
'headers' => [ | ||
'Accept' => 'application/json', | ||
'Authorization' => "token ${codingToken}", | ||
'Content-Type' => 'application/json' | ||
], | ||
'json' => array_merge([ | ||
'Action' => 'DescribeProjectIssueStatusList', | ||
'ProjectName' => $codingProjectUri, | ||
'IssueType' => $issueType, | ||
]) | ||
] | ||
) | ||
->willReturn(new Response(200, [], $responseBody)); | ||
$coding = new ProjectSetting($clientMock); | ||
$result = $coding->getIssueTypeStatus($codingToken, $codingProjectUri, $issueType); | ||
$this->assertEquals(json_decode($responseBody, true)['Response']['ProjectIssueStatusList'], $result); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
tests/data/coding/DescribeProjectIssueStatusListResponse.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
{ | ||
"Response": { | ||
"RequestId": "dc827006-32db-a74f-eeae-13bec31c8b92", | ||
"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 | ||
} | ||
}, | ||
{ | ||
"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 | ||
} | ||
}, | ||
{ | ||
"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 | ||
} | ||
}, | ||
{ | ||
"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 | ||
} | ||
} | ||
] | ||
} | ||
} |