mirror of
https://github.com/koel/koel
synced 2024-12-03 01:09:23 +00:00
32 lines
822 B
PHP
32 lines
822 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();
|
|
static::createSampleMediaSet();
|
|
|
|
$song = Song::first();
|
|
/** @var User $user */
|
|
$user = User::factory()->create();
|
|
$user->setPreference('lastfm_session_key', 'foo');
|
|
|
|
$timestamp = time();
|
|
|
|
self::mock(LastfmService::class)
|
|
->shouldReceive('scrobble')
|
|
->with($song->album->artist->name, $song->title, $timestamp, $song->album->name, 'foo')
|
|
->once();
|
|
|
|
$response = $this->postAsUser("/api/{$song->id}/scrobble", ['timestamp' => $timestamp], $user);
|
|
|
|
$response->assertStatus(204);
|
|
}
|
|
}
|