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\DatabaseTransactions;
|
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
|
|
use Mockery as m;
|
2017-02-14 06:53:02 +00:00
|
|
|
use Tests\BrowserKitTestCase;
|
2016-05-30 05:50:59 +00:00
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
class ScrobbleTest extends BrowserKitTestCase
|
2016-05-30 05:50:59 +00:00
|
|
|
{
|
|
|
|
use DatabaseTransactions, WithoutMiddleware;
|
|
|
|
|
|
|
|
public function testScrobble()
|
|
|
|
{
|
|
|
|
$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");
|
|
|
|
}
|
|
|
|
}
|