koel/tests/Feature/ScrobbleTest.php
2018-08-24 17:27:19 +02:00

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();
}
}