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\LoveTrackOnLastfmJob;
|
|
|
|
use App\Models\Interaction;
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Services\LastfmService;
|
|
|
|
use Mockery;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class LoveTrackOnLastfmJobTest extends TestCase
|
|
|
|
{
|
|
|
|
private $job;
|
|
|
|
private $user;
|
|
|
|
private $interaction;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2020-11-14 16:57:25 +00:00
|
|
|
$this->user = User::factory()->create(['preferences' => ['lastfm_session_key' => 'foo']]);
|
|
|
|
$this->interaction = Interaction::factory()->make();
|
2020-04-27 18:55:12 +00:00
|
|
|
$this->job = new LoveTrackOnLastfmJob($this->user, $this->interaction);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testHandle(): void
|
|
|
|
{
|
|
|
|
$lastFm = Mockery::mock(LastfmService::class);
|
|
|
|
$lastFm->shouldReceive('toggleLoveTrack')
|
|
|
|
->once()
|
|
|
|
->with(
|
|
|
|
$this->interaction->song->title,
|
|
|
|
$this->interaction->song->artist->name,
|
|
|
|
'foo',
|
|
|
|
$this->interaction->liked
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->job->handle($lastFm);
|
|
|
|
}
|
|
|
|
}
|