koel/tests/Integration/KoelPlus/Services/Streamer/StreamerTest.php

43 lines
1.5 KiB
PHP
Raw Normal View History

2024-02-24 07:28:49 +00:00
<?php
namespace Tests\Integration\KoelPlus\Services\Streamer;
2024-04-18 17:20:14 +00:00
use App\Enums\SongStorageType;
2024-02-24 07:28:49 +00:00
use App\Models\Song;
use App\Services\Streamer\Adapters\DropboxStreamerAdapter;
use App\Services\Streamer\Adapters\LocalStreamerAdapter;
use App\Services\Streamer\Adapters\S3CompatibleStreamerAdapter;
use App\Services\Streamer\Streamer;
use Illuminate\Support\Facades\File;
use Tests\PlusTestCase;
class StreamerTest extends PlusTestCase
{
public function testResolveAdapters(): void
{
File::partialMock()->shouldReceive('mimeType')->andReturn('audio/mpeg');
2024-04-18 17:20:14 +00:00
collect(SongStorageType::cases())
->each(static function (SongStorageType $type): void {
2024-02-24 07:28:49 +00:00
/** @var Song $song */
$song = Song::factory()->make(['storage' => $type]);
$streamer = new Streamer($song);
switch ($type) {
2024-04-18 17:20:14 +00:00
case SongStorageType::S3:
case SongStorageType::S3_LAMBDA:
2024-02-24 07:28:49 +00:00
self::assertInstanceOf(S3CompatibleStreamerAdapter::class, $streamer->getAdapter());
break;
2024-04-18 17:20:14 +00:00
case SongStorageType::DROPBOX:
2024-02-24 07:28:49 +00:00
self::assertInstanceOf(DropboxStreamerAdapter::class, $streamer->getAdapter());
break;
2024-04-18 17:20:14 +00:00
case SongStorageType::LOCAL:
2024-02-24 07:28:49 +00:00
self::assertInstanceOf(LocalStreamerAdapter::class, $streamer->getAdapter());
break;
}
});
}
}