mirror of
https://github.com/koel/koel
synced 2024-11-14 00:17:13 +00:00
chore: clean up some tests
This commit is contained in:
parent
b45ad25dfc
commit
d30c5986b3
2 changed files with 17 additions and 21 deletions
|
@ -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
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue