2024-01-12 14:41:02 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Integration\KoelPlus\Services;
|
|
|
|
|
|
|
|
use App\Facades\License;
|
|
|
|
use App\Models\Song;
|
2024-01-18 11:13:05 +00:00
|
|
|
use App\Services\License\FakePlusLicenseService;
|
2024-01-12 14:41:02 +00:00
|
|
|
use Tests\Integration\Services\SmartPlaylistServiceTest as BaseSmartPlaylistServiceTest;
|
|
|
|
|
|
|
|
use function Tests\create_user;
|
|
|
|
|
|
|
|
class SmartPlaylistServiceTest extends BaseSmartPlaylistServiceTest
|
|
|
|
{
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2024-01-18 11:13:05 +00:00
|
|
|
License::swap(app()->make(FakePlusLicenseService::class));
|
2024-01-12 14:41:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testOwnSongsOnlyOption(): void
|
|
|
|
{
|
|
|
|
$owner = create_user();
|
|
|
|
$matches = Song::factory()->count(3)->for($owner, 'owner')->create(['title' => 'Foo Something']);
|
|
|
|
Song::factory()->count(2)->create(['title' => 'Foo Something']);
|
|
|
|
Song::factory()->count(3)->create(['title' => 'Bar Something']);
|
|
|
|
|
|
|
|
$this->assertMatchesAgainstRules(
|
|
|
|
matches: $matches,
|
|
|
|
rules: [
|
|
|
|
[
|
|
|
|
'id' => 'aaf61bc3-3bdf-4fa4-b9f3-f7f7838ed502',
|
|
|
|
'rules' => [
|
|
|
|
[
|
|
|
|
'id' => '70b08372-b733-4fe2-aedb-639f77120d6d',
|
|
|
|
'model' => 'title',
|
|
|
|
'operator' => 'is',
|
|
|
|
'value' => ['Foo Something'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
owner: $owner,
|
|
|
|
ownSongsOnly: true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|