Skip to content

Commit a500117

Browse files
committed
test(Feature): fix music download error
- Mock the `download` method of `SequenceMusic` to throw a `RuntimeException` - Update the `MusicCommandTest` to test the error case
1 parent aadabf2 commit a500117

File tree

3 files changed

+23
-54
lines changed

3 files changed

+23
-54
lines changed

tests/Feature/MusicCommandTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
it('can search and download music', function (array $songs): void {
2525
$mockSequenceMusic = Mockery::mock(SequenceMusic::class);
2626
$mockSequenceMusic->allows('search')->andReturn(collect($songs));
27-
$mockSequenceMusic->allows('download')->andReturnUndefined();
27+
$mockSequenceMusic->allows('download')->andThrow(new RuntimeException());
2828
App\Facades\Music::shouldReceive('driver')->andReturn($mockSequenceMusic->makePartial());
2929

3030
$this
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
namespace Tests\Unit\Concerns;
14+
15+
use App\Concerns\Hydrator;
16+
use Illuminate\Support\Collection;
17+
18+
uses(Hydrator::class);
19+
20+
it('can batch sanitize songs', function (array $songs): void {
21+
expect($this)->hydrates(collect($songs), '腰乐队')->toBeInstanceOf(Collection::class);
22+
})->group(__DIR__, __FILE__)->with('songs');

tests/Unit/Concerns/SanitizerTest.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)