koel/tests/ScrobbleTest.php

29 lines
686 B
PHP
Raw Normal View History

2016-05-30 05:50:59 +00:00
<?php
use App\Models\Song;
use App\Services\Lastfm;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Mockery as m;
class ScrobbleTest extends TestCase
{
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");
}
}