koel/tests/Feature/ScrobbleTest.php
2018-08-29 13:15:23 +07: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();
}
}