2020-04-27 18:55:12 +00:00
|
|
|
<?php
|
|
|
|
|
2020-11-14 16:57:25 +00:00
|
|
|
namespace Tests\Unit\Jobs;
|
2020-04-27 18:55:12 +00:00
|
|
|
|
|
|
|
use App\Jobs\ScrobbleJob;
|
|
|
|
use App\Models\Song;
|
|
|
|
use App\Services\LastfmService;
|
|
|
|
use Mockery;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
2024-01-11 12:41:33 +00:00
|
|
|
use function Tests\create_user;
|
|
|
|
|
2020-04-27 18:55:12 +00:00
|
|
|
class ScrobbleJobTest extends TestCase
|
|
|
|
{
|
2021-06-04 16:31:45 +00:00
|
|
|
public function testHandle(): void
|
2020-04-27 18:55:12 +00:00
|
|
|
{
|
2024-01-11 12:41:33 +00:00
|
|
|
$user = create_user();
|
2020-04-27 18:55:12 +00:00
|
|
|
|
2021-06-04 16:31:45 +00:00
|
|
|
/** @var Song $song */
|
|
|
|
$song = Song::factory()->make();
|
|
|
|
$job = new ScrobbleJob($user, $song, 100);
|
|
|
|
$lastfm = Mockery::mock(LastfmService::class);
|
|
|
|
|
|
|
|
$lastfm->shouldReceive('scrobble')
|
2020-04-27 18:55:12 +00:00
|
|
|
->once()
|
2022-08-08 16:00:59 +00:00
|
|
|
->with($song, $user, 100);
|
2020-04-27 18:55:12 +00:00
|
|
|
|
2021-06-04 16:31:45 +00:00
|
|
|
$job->handle($lastfm);
|
2020-04-27 18:55:12 +00:00
|
|
|
}
|
|
|
|
}
|