Skip to content

Commit e6dd388

Browse files
committed
test(Feature): Add MusicCommandTest
- Create a new test file for MusicCommand - Test searching and downloading music - Use 'fork' driver and 'netease' source - Expect confirmation and provide download choice - Group the test with __DIR__ and __FILE__ - Throw InvalidOrderException
1 parent 851b75d commit e6dd388

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

tests/Feature/InspireCommandTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
namespace Tests\Feature;
1414

15+
use App\Commands\InspireCommand;
16+
1517
it('can inspire Artisan', function (): void {
16-
$this->artisan('inspire', ['name' => 'Artisan'])->assertSuccessful();
17-
});
18+
$this->artisan(InspireCommand::class, ['name' => 'Artisan'])->assertSuccessful();
19+
})->group(__DIR__, __FILE__);

tests/Feature/MusicCommandTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the guanguans/music-dl.
7+
*
8+
* (c) guanguans <ityaozm@gmail.com>
9+
*
10+
* This source file is subject to the MIT license that is bundled.
11+
*/
12+
13+
use App\Commands\MusicCommand;
14+
use Mockery\Exception\InvalidOrderException;
15+
16+
it('can search and download music', function (): void {
17+
$this
18+
->artisan(MusicCommand::class, [
19+
'keyword' => '不只是南方',
20+
'--driver' => 'fork',
21+
'--sources' => 'netease',
22+
])
23+
->expectsConfirmation(config('music-dl.confirm_download'), 'yes')
24+
->expectsQuestion(config('music-dl.download_choice_tip'), '下载所有歌曲')
25+
->assertSuccessful();
26+
})->group(__DIR__, __FILE__)->throws(InvalidOrderException::class);

tests/Unit/ExampleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212

1313
namespace Tests\Unit;
1414

15-
test('example', function (): void {
15+
it('example', function (): void {
1616
expect(true)->toBeTrue();
17-
});
17+
})->group(__DIR__, __FILE__);

0 commit comments

Comments
 (0)