mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
35 lines
837 B
PHP
35 lines
837 B
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Song;
|
|
use App\Models\User;
|
|
use App\Services\LastfmService;
|
|
use Exception;
|
|
|
|
class ScrobbleTest extends TestCase
|
|
{
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function testLastfmScrobble()
|
|
{
|
|
$this->withoutEvents();
|
|
$this->createSampleMediaSet();
|
|
|
|
$song = Song::first();
|
|
/** @var User $user */
|
|
$user = factory(User::class)->create();
|
|
$user->setPreference('lastfm_session_key', 'foo');
|
|
|
|
$ts = time();
|
|
|
|
$this->mockIocDependency(LastfmService::class)
|
|
->shouldReceive('scrobble')
|
|
->with($song->album->artist->name, $song->title, $ts, $song->album->name, 'foo')
|
|
->once();
|
|
|
|
$this->postAsUser("/api/{$song->id}/scrobble/$ts", [], $user)
|
|
->assertResponseOk();
|
|
}
|
|
}
|