chore: clean up some tests

This commit is contained in:
Phan An 2021-06-04 18:31:45 +02:00
parent b45ad25dfc
commit d30c5986b3
No known key found for this signature in database
GPG key ID: A81E4477F0BB6FDC
2 changed files with 17 additions and 21 deletions

View file

@ -11,12 +11,12 @@ use App\Values\LastfmLoveTrackParameters;
use Mockery; use Mockery;
use Tests\Feature\TestCase; use Tests\Feature\TestCase;
class LoveTrackOnLastFmTest extends TestCase class LoveTrackOnLastfmTest extends TestCase
{ {
public function testHandle(): void public function testHandle(): void
{ {
/** @var User $user */ /** @var User $user */
$user = User::factory()->create(['preferences' => ['lastfm_session_key' => 'bar']]); $user = User::factory()->create();
/** @var Interaction $interaction */ /** @var Interaction $interaction */
$interaction = Interaction::factory()->create(); $interaction = Interaction::factory()->create();
@ -30,7 +30,7 @@ class LoveTrackOnLastFmTest extends TestCase
return true; return true;
}), }),
'bar', $user->lastfm_session_key,
$interaction->liked $interaction->liked
); );

View file

@ -11,26 +11,22 @@ use Tests\TestCase;
class ScrobbleJobTest extends TestCase class ScrobbleJobTest extends TestCase
{ {
private $job;
private $user;
private $song;
public function setUp(): void
{
parent::setUp();
$this->user = User::factory()->create(['preferences' => ['lastfm_session_key' => 'foo']]);
$this->song = Song::factory()->make();
$this->job = new ScrobbleJob($this->user, $this->song, 100);
}
public function testHandle(): void public function testHandle(): void
{ {
$lastFm = Mockery::mock(LastfmService::class); /** @var User $user */
$lastFm->shouldReceive('scrobble') $user = User::factory()->create();
->once()
->with($this->song->artist->name, $this->song->title, 100, $this->song->album->name, 'foo');
$this->job->handle($lastFm); /** @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);
} }
} }