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-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
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
|
|
use Mockery as m;
|
|
|
|
|
2017-08-05 16:56:11 +00:00
|
|
|
class ScrobbleTest extends TestCase
|
2016-05-30 05:50:59 +00:00
|
|
|
{
|
2017-08-05 16:56:11 +00:00
|
|
|
use WithoutMiddleware;
|
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();
|
|
|
|
|
|
|
|
$ts = time();
|
|
|
|
|
2018-08-18 13:19:40 +00:00
|
|
|
m::mock(LastfmService::class, ['enabled' => true])
|
2016-11-24 04:07:57 +00:00
|
|
|
->shouldReceive('scrobble')
|
2016-05-30 05:50:59 +00:00
|
|
|
->with($song->album->artist->name, $song->title, $ts, $song->album->name, 'bar');
|
|
|
|
|
|
|
|
$this->post("/api/{$song->id}/scrobble/$ts");
|
|
|
|
}
|
|
|
|
}
|