2021-10-25 19:17:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Integration\Services;
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
use App\Services\PlaylistService;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class PlaylistServiceTest extends TestCase
|
|
|
|
{
|
|
|
|
private PlaylistService $service;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->service = app(PlaylistService::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreatePlaylist(): void
|
|
|
|
{
|
|
|
|
/** @var User $user */
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
|
|
|
$playlist = $this->service->createPlaylist('foo', $user, []);
|
2022-07-18 11:00:37 +00:00
|
|
|
self::assertFalse($playlist->is_smart);
|
2021-10-25 19:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testCreateSmartPlaylist(): void
|
|
|
|
{
|
|
|
|
$rules = [
|
|
|
|
[
|
|
|
|
'id' => 1634756491129,
|
|
|
|
'model' => 'title',
|
|
|
|
'operator' => 'is',
|
|
|
|
'value' => ['foobar'],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
/** @var User $user */
|
|
|
|
$user = User::factory()->create();
|
|
|
|
|
|
|
|
$playlist = $this->service->createPlaylist('foo', $user, [], $rules);
|
2022-07-18 11:00:37 +00:00
|
|
|
self::assertTrue($playlist->is_smart);
|
2021-10-25 19:17:25 +00:00
|
|
|
}
|
|
|
|
}
|