-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathIssueCreateCommandTest.php
More file actions
executable file
·59 lines (49 loc) · 2.01 KB
/
IssueCreateCommandTest.php
File metadata and controls
executable file
·59 lines (49 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Tests\Feature;
use Coding\Issue;
use Tests\TestCase;
class IssueCreateCommandTest extends TestCase
{
private string $codingToken;
private string $codingTeamDomain;
private string $codingProjectUri;
protected function setUp(): void
{
parent::setUp();
$this->codingToken = $this->faker->md5;
config(['coding.token' => $this->codingToken]);
$this->codingTeamDomain = $this->faker->domainWord;
config(['coding.team_domain' => $this->codingTeamDomain]);
$this->codingProjectUri = $this->faker->slug;
config(['coding.project_uri' => $this->codingProjectUri]);
}
public function testCreateSuccess()
{
$mock = \Mockery::mock(Issue::class, [])->makePartial();
$this->instance(Issue::class, $mock);
$mock->shouldReceive('create')->times(1)->andReturn(json_decode(
file_get_contents($this->dataDir . 'coding/' . 'CreateIssueResponse.json'),
true
)['Response']['Issue']);
$this->artisan('issue:create')
->expectsQuestion('类型:', 'REQUIREMENT')
->expectsQuestion('标题:', $this->faker->title)
->expectsOutput('创建成功')
->expectsOutput("https://$this->codingTeamDomain.coding.net/p/$this->codingProjectUri/all/issues/2742")
->assertExitCode(0);
}
public function testCreateFailed()
{
$mock = \Mockery::mock(Issue::class, [])->makePartial();
$this->instance(Issue::class, $mock);
$mock->shouldReceive('create')->times(1)->andThrow(\Exception::class, json_decode(
file_get_contents($this->dataDir . 'coding/' . 'CreateIssueFailedResponse.json'),
true
)['Response']['Error']['Message']);
$this->artisan('issue:create')
->expectsQuestion('类型:', 'REQUIREMENT')
->expectsQuestion('标题:', $this->faker->title)
->expectsOutput('Error: issue_custom_field_required')
->assertExitCode(1);
}
}