mirror of
https://github.com/koel/koel
synced 2024-12-20 09:33:23 +00:00
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Integration\Models;
|
|
|
|
use App\Models\Song;
|
|
use App\Models\SongZipArchive;
|
|
use Tests\TestCase;
|
|
|
|
class SongZipArchiveTest extends TestCase
|
|
{
|
|
public function testAddSongIntoArchive(): void
|
|
{
|
|
/** @var Song $song */
|
|
$song = Song::factory()->create(['path' => realpath(__DIR__ . '/../../songs/full.mp3')]);
|
|
|
|
$songZipArchive = new SongZipArchive();
|
|
$songZipArchive->addSong($song);
|
|
|
|
self::assertEquals(1, $songZipArchive->getArchive()->numFiles);
|
|
self::assertEquals('full.mp3', $songZipArchive->getArchive()->getNameIndex(0));
|
|
}
|
|
|
|
public function testAddMultipleSongsIntoArchive(): void
|
|
{
|
|
$songs = collect([
|
|
Song::factory()->create(['path' => realpath(__DIR__ . '/../../songs/full.mp3')]),
|
|
Song::factory()->create(['path' => realpath(__DIR__ . '/../../songs/lorem.mp3')]),
|
|
]);
|
|
|
|
$songZipArchive = new SongZipArchive();
|
|
$songZipArchive->addSongs($songs);
|
|
|
|
self::assertEquals(2, $songZipArchive->getArchive()->numFiles);
|
|
self::assertEquals('full.mp3', $songZipArchive->getArchive()->getNameIndex(0));
|
|
self::assertEquals('lorem.mp3', $songZipArchive->getArchive()->getNameIndex(1));
|
|
}
|
|
}
|