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;
|
|
|
|
use App\Services\Lastfm;
|
|
|
|
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
|
|
|
|
2017-08-05 18:55:02 +00:00
|
|
|
protected function tearDown()
|
|
|
|
{
|
|
|
|
m::close();
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
2017-12-09 18:34:27 +00:00
|
|
|
public function a_song_can_be_scrobbled_via_lastfm()
|
2016-05-30 05:50:59 +00:00
|
|
|
{
|
|
|
|
$this->withoutEvents();
|
|
|
|
$this->createSampleMediaSet();
|
|
|
|
|
|
|
|
$song = Song::first();
|
|
|
|
|
|
|
|
$ts = time();
|
|
|
|
|
2016-11-24 04:07:57 +00:00
|
|
|
m::mock(Lastfm::class, ['enabled' => true])
|
|
|
|
->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");
|
|
|
|
}
|
|
|
|
}
|