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
|
|
|
|
{
|
2017-12-10 00:23:37 +00:00
|
|
|
/** @test */
|
|
|
|
public function a_song_can_be_added_into_an_archive()
|
|
|
|
{
|
|
|
|
$song = factory(Song::class)->create([
|
|
|
|
'path' => realpath(__DIR__.'/../../songs/full.mp3'),
|
|
|
|
]);
|
|
|
|
|
2019-06-30 10:49:41 +00:00
|
|
|
$songZipArchive = new SongZipArchive();
|
|
|
|
$songZipArchive->addSong($song);
|
2017-12-10 00:23:37 +00:00
|
|
|
|
2019-06-30 10:49:41 +00:00
|
|
|
$this->assertEquals(1, $songZipArchive->getArchive()->numFiles);
|
|
|
|
$this->assertEquals('full.mp3', $songZipArchive->getArchive()->getNameIndex(0));
|
2017-12-10 00:23:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
|
|
|
public function multiple_songs_can_be_added_into_an_archive()
|
|
|
|
{
|
|
|
|
$songs = collect([
|
|
|
|
factory(Song::class)->create([
|
|
|
|
'path' => realpath(__DIR__.'/../../songs/full.mp3'),
|
|
|
|
]),
|
|
|
|
factory(Song::class)->create([
|
|
|
|
'path' => realpath(__DIR__.'/../../songs/lorem.mp3'),
|
|
|
|
]),
|
|
|
|
]);
|
|
|
|
|
2019-06-30 10:49:41 +00:00
|
|
|
$songZipArchive = new SongZipArchive();
|
|
|
|
$songZipArchive->addSongs($songs);
|
2017-12-10 00:23:37 +00:00
|
|
|
|
2019-06-30 10:49:41 +00:00
|
|
|
$this->assertEquals(2, $songZipArchive->getArchive()->numFiles);
|
|
|
|
$this->assertEquals('full.mp3', $songZipArchive->getArchive()->getNameIndex(0));
|
|
|
|
$this->assertEquals('lorem.mp3', $songZipArchive->getArchive()->getNameIndex(1));
|
2017-12-10 00:23:37 +00:00
|
|
|
}
|
2017-12-09 22:39:34 +00:00
|
|
|
}
|