2016-05-30 05:50:59 +00:00
|
|
|
<?php
|
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
namespace Tests\Feature;
|
|
|
|
|
2016-05-30 05:50:59 +00:00
|
|
|
use App\Models\Song;
|
2018-08-24 15:27:19 +00:00
|
|
|
use App\Models\User;
|
2018-08-18 13:19:40 +00:00
|
|
|
use App\Services\LastfmService;
|
2018-08-19 21:17:05 +00:00
|
|
|
use Exception;
|
2016-05-30 05:50:59 +00:00
|
|
|
|
2017-08-05 16:56:11 +00:00
|
|
|
class ScrobbleTest extends TestCase
|
2016-05-30 05:50:59 +00:00
|
|
|
{
|
2018-08-19 21:17:05 +00:00
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function testLastfmScrobble()
|
2016-05-30 05:50:59 +00:00
|
|
|
{
|
|
|
|
$this->withoutEvents();
|
|
|
|
$this->createSampleMediaSet();
|
|
|
|
|
|
|
|
$song = Song::first();
|
2018-08-24 15:27:19 +00:00
|
|
|
/** @var User $user */
|
|
|
|
$user = factory(User::class)->create();
|
|
|
|
$user->setPreference('lastfm_session_key', 'foo');
|
2016-05-30 05:50:59 +00:00
|
|
|
|
|
|
|
$ts = time();
|
|
|
|
|
2018-08-24 15:27:19 +00:00
|
|
|
$this->mockIocDependency(LastfmService::class)
|
2016-11-24 04:07:57 +00:00
|
|
|
->shouldReceive('scrobble')
|
2018-08-24 15:27:19 +00:00
|
|
|
->with($song->album->artist->name, $song->title, $ts, $song->album->name, 'foo')
|
|
|
|
->once();
|
2016-05-30 05:50:59 +00:00
|
|
|
|
2018-08-24 15:27:19 +00:00
|
|
|
$this->postAsUser("/api/{$song->id}/scrobble/$ts", [], $user)
|
|
|
|
->assertResponseOk();
|
2016-05-30 05:50:59 +00:00
|
|
|
}
|
|
|
|
}
|