mirror of
https://github.com/koel/koel
synced 2024-12-03 17:29:33 +00:00
31 lines
766 B
PHP
31 lines
766 B
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Song;
|
|
use App\Models\User;
|
|
use App\Services\LastfmService;
|
|
|
|
class ScrobbleTest extends TestCase
|
|
{
|
|
public function testLastfmScrobble(): void
|
|
{
|
|
$this->withoutEvents();
|
|
|
|
/** @var User $user */
|
|
$user = User::factory()->create();
|
|
|
|
/** @var Song $song */
|
|
$song = Song::factory()->create();
|
|
|
|
$timestamp = time();
|
|
|
|
self::mock(LastfmService::class)
|
|
->shouldReceive('scrobble')
|
|
->with($song->album->artist->name, $song->title, $timestamp, $song->album->name, $user->lastfm_session_key)
|
|
->once();
|
|
|
|
$this->postAsUser("/api/$song->id/scrobble", ['timestamp' => $timestamp], $user)
|
|
->assertNoContent();
|
|
}
|
|
}
|