mirror of
https://github.com/koel/koel
synced 2024-11-28 15:00:42 +00:00
32 lines
722 B
PHP
32 lines
722 B
PHP
<?php
|
|
|
|
namespace Tests\Unit\Jobs;
|
|
|
|
use App\Jobs\ScrobbleJob;
|
|
use App\Models\Song;
|
|
use App\Models\User;
|
|
use App\Services\LastfmService;
|
|
use Mockery;
|
|
use Tests\TestCase;
|
|
|
|
class ScrobbleJobTest extends TestCase
|
|
{
|
|
public function testHandle(): void
|
|
{
|
|
/** @var User $user */
|
|
$user = User::factory()->create();
|
|
|
|
/** @var Song $song */
|
|
$song = Song::factory()->make();
|
|
|
|
$job = new ScrobbleJob($user, $song, 100);
|
|
|
|
$lastfm = Mockery::mock(LastfmService::class);
|
|
|
|
$lastfm->shouldReceive('scrobble')
|
|
->once()
|
|
->with($song->artist->name, $song->title, 100, $song->album->name, $user->lastfm_session_key);
|
|
|
|
$job->handle($lastfm);
|
|
}
|
|
}
|