Add song scrobble test

This commit is contained in:
An Phan 2016-05-27 16:45:45 +08:00
parent efe8b937d2
commit e5f77399fd

View file

@ -203,4 +203,21 @@ class LastfmTest extends TestCase
(new UpdateLastfmNowPlaying($lastfm))->handle(new SongStartedPlaying($song, $user));
}
public function testScrobble()
{
$this->withoutEvents();
$this->createSampleMediaSet();
$user = factory(User::class)->create(['preferences' => ['lastfm_session_key' => 'bar']]);
$song = Song::first();
$ts = time();
$lastfm = m::mock(Lastfm::class, ['enabled' => true]);
$lastfm->shouldReceive('scrobble')
->with($song->album->artist->name, $song->title, $ts, $song->album->name, 'bar');
$this->post("/api/{$song->id}/scrobble/$ts");
}
}