2016-06-13 09:04:42 +00:00
|
|
|
<?php
|
|
|
|
|
2017-02-14 06:53:02 +00:00
|
|
|
namespace Tests\Feature\ObjectStorage;
|
|
|
|
|
2016-06-13 09:04:42 +00:00
|
|
|
use App\Events\LibraryChanged;
|
2018-08-24 15:27:19 +00:00
|
|
|
use App\Models\Song;
|
|
|
|
use Exception;
|
2016-06-13 09:04:42 +00:00
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
2017-08-05 16:56:11 +00:00
|
|
|
use Tests\Feature\TestCase;
|
2016-06-13 09:04:42 +00:00
|
|
|
|
2017-08-05 16:56:11 +00:00
|
|
|
class S3Test extends TestCase
|
2016-06-13 09:04:42 +00:00
|
|
|
{
|
2017-08-05 16:56:11 +00:00
|
|
|
use WithoutMiddleware;
|
2016-06-13 09:04:42 +00:00
|
|
|
|
2018-08-24 15:27:19 +00:00
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2019-07-22 07:03:23 +00:00
|
|
|
public function setUp(): void
|
2017-02-14 06:53:02 +00:00
|
|
|
{
|
|
|
|
parent::setUp();
|
2017-06-11 00:15:28 +00:00
|
|
|
$this->disableMiddlewareForAllTests();
|
2017-02-14 06:53:02 +00:00
|
|
|
}
|
|
|
|
|
2019-07-22 07:03:23 +00:00
|
|
|
public function testStoringASong(): void
|
2016-06-13 09:04:42 +00:00
|
|
|
{
|
|
|
|
$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']);
|
|
|
|
}
|
|
|
|
|
2018-08-24 15:27:19 +00:00
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2019-07-22 07:03:23 +00:00
|
|
|
public function testRemovingASong(): void
|
2016-06-13 09:04:42 +00:00
|
|
|
{
|
|
|
|
$this->expectsEvents(LibraryChanged::class);
|
2018-08-24 15:27:19 +00:00
|
|
|
|
|
|
|
factory(Song::class)->create([
|
|
|
|
'path' => 's3://koel/sample.mp3',
|
|
|
|
]);
|
2016-06-13 09:04:42 +00:00
|
|
|
|
|
|
|
$this->delete('api/os/s3/song', [
|
|
|
|
'bucket' => 'koel',
|
|
|
|
'key' => 'sample.mp3',
|
|
|
|
])->notSeeInDatabase('songs', ['path' => 's3://koel/sample.mp3']);
|
|
|
|
}
|
|
|
|
}
|