koel/tests/Feature/OverviewTest.php

32 lines
990 B
PHP
Raw Permalink Normal View History

2022-07-26 21:00:42 +00:00
<?php
2023-06-05 21:46:41 +00:00
namespace Tests\Feature;
2022-07-26 21:00:42 +00:00
use App\Http\Resources\AlbumResource;
use App\Http\Resources\ArtistResource;
use App\Http\Resources\SongResource;
2022-07-26 21:00:42 +00:00
use App\Models\Interaction;
2024-01-09 18:34:40 +00:00
use Tests\TestCase;
2022-07-26 21:00:42 +00:00
2024-01-11 12:41:33 +00:00
use function Tests\create_user;
2022-07-26 21:00:42 +00:00
class OverviewTest extends TestCase
{
public function testIndex(): void
{
2024-01-11 12:41:33 +00:00
$user = create_user();
2022-07-26 21:00:42 +00:00
2022-07-27 08:49:33 +00:00
Interaction::factory(20)->for($user)->create();
2022-07-26 21:00:42 +00:00
2022-07-27 08:49:33 +00:00
$this->getAs('api/overview', $user)
2022-07-26 21:00:42 +00:00
->assertJsonStructure([
'most_played_songs' => ['*' => SongResource::JSON_STRUCTURE],
'recently_played_songs' => ['*' => SongResource::JSON_STRUCTURE],
'recently_added_albums' => ['*' => AlbumResource::JSON_STRUCTURE],
'recently_added_songs' => ['*' => SongResource::JSON_STRUCTURE],
'most_played_artists' => ['*' => ArtistResource::JSON_STRUCTURE],
'most_played_albums' => ['*' => AlbumResource::JSON_STRUCTURE],
2022-07-26 21:00:42 +00:00
]);
}
}