mirror of
https://github.com/koel/koel
synced 2025-02-16 05:18:37 +00:00
feat(test|api): add ArtistSong tests
This commit is contained in:
parent
2da3ddc23c
commit
a7b8f91fdc
3 changed files with 49 additions and 25 deletions
|
@ -7,30 +7,6 @@ use App\Models\Song;
|
|||
|
||||
class AlbumSongTest extends TestCase
|
||||
{
|
||||
private const JSON_STRUCTURE = [
|
||||
'type',
|
||||
'id',
|
||||
'title',
|
||||
'lyrics',
|
||||
'album_id',
|
||||
'album_name',
|
||||
'artist_id',
|
||||
'artist_name',
|
||||
'album_artist_id',
|
||||
'album_artist_name',
|
||||
'album_cover',
|
||||
'length',
|
||||
'liked',
|
||||
'play_count',
|
||||
'track',
|
||||
'disc',
|
||||
'created_at',
|
||||
];
|
||||
|
||||
private const JSON_COLLECTION_STRUCTURE = [
|
||||
'*' => self::JSON_STRUCTURE,
|
||||
];
|
||||
|
||||
public function testIndex(): void
|
||||
{
|
||||
/** @var Album $album */
|
||||
|
@ -41,6 +17,6 @@ class AlbumSongTest extends TestCase
|
|||
]);
|
||||
|
||||
$this->getAsUser('api/albums/' . $album->id . '/songs')
|
||||
->assertJsonStructure(self::JSON_COLLECTION_STRUCTURE);
|
||||
->assertJsonStructure(['*' => SongTest::JSON_STRUCTURE]);
|
||||
}
|
||||
}
|
||||
|
|
22
tests/Feature/V6/ArtistSongTest.php
Normal file
22
tests/Feature/V6/ArtistSongTest.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\V6;
|
||||
|
||||
use App\Models\Artist;
|
||||
use App\Models\Song;
|
||||
|
||||
class ArtistSongTest extends TestCase
|
||||
{
|
||||
public function testIndex(): void
|
||||
{
|
||||
/** @var Artist $artist */
|
||||
$artist = Artist::factory()->create();
|
||||
|
||||
Song::factory(5)->create([
|
||||
'artist_id' => $artist->id,
|
||||
]);
|
||||
|
||||
$this->getAsUser('api/artists/' . $artist->id . '/songs')
|
||||
->assertJsonStructure(['*' => SongTest::JSON_STRUCTURE]);
|
||||
}
|
||||
}
|
26
tests/Feature/V6/SongTest.php
Normal file
26
tests/Feature/V6/SongTest.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature\V6;
|
||||
|
||||
class SongTest
|
||||
{
|
||||
public const JSON_STRUCTURE = [
|
||||
'type',
|
||||
'id',
|
||||
'title',
|
||||
'lyrics',
|
||||
'album_id',
|
||||
'album_name',
|
||||
'artist_id',
|
||||
'artist_name',
|
||||
'album_artist_id',
|
||||
'album_artist_name',
|
||||
'album_cover',
|
||||
'length',
|
||||
'liked',
|
||||
'play_count',
|
||||
'track',
|
||||
'disc',
|
||||
'created_at',
|
||||
];
|
||||
}
|
Loading…
Add table
Reference in a new issue