2
0
Fork 0
mirror of https://github.com/koel/koel synced 2025-01-10 19:58:46 +00:00
koel/tests/Feature/ScrobbleTest.php
2018-09-04 12:34:02 +07:00

31 lines
855 B
PHP

<?php
namespace Tests\Feature;
use App\Models\Song;
use App\Models\User;
use App\Services\LastfmService;
use Mockery;
class ScrobbleTest extends TestCase
{
public function testLastfmScrobble()
{
$song = factory(Song::class)->create();
$user = factory(User::class)->create();
$ts = time();
$lastfm = Mockery::mock(LastfmService::class)->makePartial();
$lastfm->shouldReceive('enabled')->andReturn(true);
$lastfm->shouldReceive('getUserSessionKey')->andReturn('foo');
$lastfm->shouldReceive('scrobble')
->with($song->album->artist->name, $song->title, $ts, $song->album->name, 'foo')
->once();
app()->instance(LastfmService::class, $lastfm);
$this->postAsUser("/api/{$song->id}/scrobble/$ts", [], $user)
->assertResponseOk();
}
}