koel/tests/Unit/Jobs/ScrobbleJobTest.php

33 lines
722 B
PHP
Raw Normal View History

<?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
{
2021-06-04 16:31:45 +00:00
public function testHandle(): void
{
2021-06-04 16:31:45 +00:00
/** @var User $user */
$user = User::factory()->create();
2021-06-04 16:31:45 +00:00
/** @var Song $song */
$song = Song::factory()->make();
2021-06-04 16:31:45 +00:00
$job = new ScrobbleJob($user, $song, 100);
$lastfm = Mockery::mock(LastfmService::class);
$lastfm->shouldReceive('scrobble')
->once()
2021-06-04 16:31:45 +00:00
->with($song->artist->name, $song->title, 100, $song->album->name, $user->lastfm_session_key);
2021-06-04 16:31:45 +00:00
$job->handle($lastfm);
}
}