Skip to content

Commit aa8e0fa

Browse files
committed
feat: #75 cli get project issue types
1 parent 1cfb571 commit aa8e0fa

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace App\Commands;
4+
5+
use App\Coding\Issue;
6+
use App\Coding\Project;
7+
use LaravelZero\Framework\Commands\Command;
8+
9+
class ProjectGetIssueTypesCommand extends Command
10+
{
11+
use WithCoding;
12+
13+
/**
14+
* The signature of the command.
15+
*
16+
* @var string
17+
*/
18+
protected $signature = 'project:get-issue-types
19+
{--coding_token= : CODING 令牌}
20+
{--coding_team_domain= : CODING 团队域名,如 xxx.coding.net 即填写 xxx}
21+
{--coding_project_uri= : CODING 项目标识,如 xxx.coding.net/p/yyy 即填写 yyy}
22+
';
23+
24+
/**
25+
* The description of the command.
26+
*
27+
* @var string
28+
*/
29+
protected $description = '获取项目下的事项类型';
30+
31+
/**
32+
* Execute the console command.
33+
*
34+
*/
35+
public function handle(Project $codingProject): int
36+
{
37+
$this->setCodingApi();
38+
39+
$result = $codingProject->getIssueTypes($this->codingToken, $this->codingProjectUri);
40+
41+
foreach ($result as $item) {
42+
$this->info($item['Id'] . ' ' . $item['Name']);
43+
}
44+
45+
return 0;
46+
}
47+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Tests\Feature;
4+
5+
use App\Coding\Project;
6+
use Tests\TestCase;
7+
8+
class ProjectGetIssueTypesCommandTest extends TestCase
9+
{
10+
protected function setUp(): void
11+
{
12+
parent::setUp();
13+
$codingToken = $this->faker->md5;
14+
config(['coding.token' => $codingToken]);
15+
$codingTeamDomain = $this->faker->domainWord;
16+
config(['coding.team_domain' => $codingTeamDomain]);
17+
$codingProjectUri = $this->faker->slug;
18+
config(['coding.project_uri' => $codingProjectUri]);
19+
}
20+
21+
public function testCreateSuccess()
22+
{
23+
$mock = \Mockery::mock(Project::class, [])->makePartial();
24+
$this->instance(Project::class, $mock);
25+
26+
$mock->shouldReceive('getIssueTypes')->times(1)->andReturn(json_decode(
27+
file_get_contents($this->dataDir . 'coding/' . 'DescribeProjectIssueTypeListResponse.json'),
28+
true
29+
)['Response']['IssueTypes']);
30+
31+
$this->artisan('project:get-issue-types')
32+
->expectsOutput('213217 史诗')
33+
->expectsOutput('213218 用户故事')
34+
->expectsOutput('213220 任务')
35+
->expectsOutput('213221 缺陷')
36+
->expectsOutput('213222 子工作项')
37+
->assertExitCode(0);
38+
}
39+
}

0 commit comments

Comments
 (0)