koel/tests/Feature/ObjectStorage/S3Test.php
2019-07-22 09:03:23 +02:00

56 lines
1.4 KiB
PHP

<?php
namespace Tests\Feature\ObjectStorage;
use App\Events\LibraryChanged;
use App\Models\Song;
use Exception;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Tests\Feature\TestCase;
class S3Test extends TestCase
{
use WithoutMiddleware;
/**
* @throws Exception
*/
public function setUp(): void
{
parent::setUp();
$this->disableMiddlewareForAllTests();
}
public function testStoringASong(): void
{
$this->post('api/os/s3/song', [
'bucket' => 'koel',
'key' => 'sample.mp3',
'tags' => [
'title' => 'A Koel Song',
'album' => 'Koel Testing Vol. 1',
'artist' => 'Koel',
'lyrics' => "When you wake up, turn your radio on, and you'll hear this simple song",
'duration' => 10,
'track' => 5,
],
])->seeInDatabase('songs', ['path' => 's3://koel/sample.mp3']);
}
/**
* @throws Exception
*/
public function testRemovingASong(): void
{
$this->expectsEvents(LibraryChanged::class);
factory(Song::class)->create([
'path' => 's3://koel/sample.mp3',
]);
$this->delete('api/os/s3/song', [
'bucket' => 'koel',
'key' => 'sample.mp3',
])->notSeeInDatabase('songs', ['path' => 's3://koel/sample.mp3']);
}
}