-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathWikiUploadCommandTest.php
More file actions
executable file
·44 lines (37 loc) · 1.42 KB
/
WikiUploadCommandTest.php
File metadata and controls
executable file
·44 lines (37 loc) · 1.42 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
<?php
namespace Tests\Feature;
use App\Coding\Wiki;
use Tests\TestCase;
class WikiUploadCommandTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
$codingToken = $this->faker->md5;
config(['coding.token' => $codingToken]);
$codingTeamDomain = $this->faker->domainWord;
config(['coding.team_domain' => $codingTeamDomain]);
$codingProjectUri = $this->faker->slug;
config(['coding.project_uri' => $codingProjectUri]);
}
public function testHandleFileNotExist()
{
$filePath = sys_get_temp_dir() . '/nothing-' . $this->faker->uuid;
$this->artisan('wiki:upload', ['file' => $filePath])
->expectsOutput("文件不存在:${filePath}")
->assertExitCode(1);
}
public function testHandleConfluenceHtmlSuccess()
{
$mock = \Mockery::mock(Wiki::class, [])->makePartial();
$this->instance(Wiki::class, $mock);
$mock->shouldReceive('createWikiByUploadZip')->times(1)->andReturn(json_decode(
file_get_contents($this->dataDir . 'coding/' . 'CreateWikiByZipResponse.json'),
true
)['Response']);
$filePath = $this->faker->filePath();
$this->artisan('wiki:upload', ['file' => $filePath])
->expectsOutput('上传成功,正在处理,任务 ID:a12353fa-f45b-4af2-83db-666bf9f66615')
->assertExitCode(0);
}
}