2017-12-09 22:39:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Integration\Models;
|
|
|
|
|
|
|
|
use App\Models\Song;
|
|
|
|
use App\Models\SongZipArchive;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class SongZipArchiveTest extends TestCase
|
|
|
|
{
|
2020-11-14 16:57:25 +00:00
|
|
|
public function testAddSongIntoArchive(): void
|
2017-12-10 00:23:37 +00:00
|
|
|
{
|
2021-07-26 21:21:36 +00:00
|
|
|
/** @var Song $song */
|
2024-01-06 11:31:50 +00:00
|
|
|
$song = Song::factory()->create(['path' => test_path('songs/full.mp3')]);
|
2017-12-10 00:23:37 +00:00
|
|
|
|
2019-06-30 10:49:41 +00:00
|
|
|
$songZipArchive = new SongZipArchive();
|
|
|
|
$songZipArchive->addSong($song);
|
2017-12-10 00:23:37 +00:00
|
|
|
|
2022-10-07 14:25:44 +00:00
|
|
|
self::assertSame(1, $songZipArchive->getArchive()->numFiles);
|
|
|
|
self::assertSame('full.mp3', $songZipArchive->getArchive()->getNameIndex(0));
|
2017-12-10 00:23:37 +00:00
|
|
|
}
|
|
|
|
|
2020-11-14 16:57:25 +00:00
|
|
|
public function testAddMultipleSongsIntoArchive(): void
|
2017-12-10 00:23:37 +00:00
|
|
|
{
|
|
|
|
$songs = collect([
|
2024-01-06 11:31:50 +00:00
|
|
|
Song::factory()->create(['path' => test_path('songs/full.mp3')]),
|
|
|
|
Song::factory()->create(['path' => test_path('songs/lorem.mp3')]),
|
2017-12-10 00:23:37 +00:00
|
|
|
]);
|
|
|
|
|
2019-06-30 10:49:41 +00:00
|
|
|
$songZipArchive = new SongZipArchive();
|
|
|
|
$songZipArchive->addSongs($songs);
|
2017-12-10 00:23:37 +00:00
|
|
|
|
2022-10-07 14:25:44 +00:00
|
|
|
self::assertSame(2, $songZipArchive->getArchive()->numFiles);
|
|
|
|
self::assertSame('full.mp3', $songZipArchive->getArchive()->getNameIndex(0));
|
|
|
|
self::assertSame('lorem.mp3', $songZipArchive->getArchive()->getNameIndex(1));
|
2017-12-10 00:23:37 +00:00
|
|
|
}
|
2017-12-09 22:39:34 +00:00
|
|
|
}
|