shouldReceive('mimeType')->andReturn('audio/mpeg'); collect(SongStorageType::cases()) ->each(static function (SongStorageType $type): void { /** @var Song $song */ $song = Song::factory()->create(['storage' => $type]); $streamer = new Streamer($song); switch ($type) { case SongStorageType::S3: case SongStorageType::S3_LAMBDA: self::assertInstanceOf(S3CompatibleStreamerAdapter::class, $streamer->getAdapter()); break; case SongStorageType::DROPBOX: self::assertInstanceOf(DropboxStreamerAdapter::class, $streamer->getAdapter()); break; case SongStorageType::LOCAL: self::assertInstanceOf(LocalStreamerAdapter::class, $streamer->getAdapter()); break; case SongStorageType::SFTP: self::assertInstanceOf(SftpStreamerAdapter::class, $streamer->getAdapter()); break; default: throw new Exception('Storage type not covered by tests: ' . $type->value); } }); } }