koel/tests/Feature/ScrobbleTest.php

37 lines
782 B
PHP
Raw Normal View History

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;
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
2017-08-05 18:55:02 +00:00
protected function tearDown()
{
m::close();
parent::tearDown();
}
/** @test */
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();
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");
}
}