koel/tests/Feature/ObjectStorage/S3Test.php

55 lines
1.5 KiB
PHP
Raw Normal View History

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;
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
2017-02-14 06:53:02 +00:00
public function setUp()
{
parent::setUp();
2017-06-11 00:15:28 +00:00
$this->disableMiddlewareForAllTests();
2017-02-14 06:53:02 +00:00
}
2017-08-05 18:55:02 +00:00
/** @test */
public function a_song_can_be_added()
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']);
}
2017-08-05 18:55:02 +00:00
/** @test */
public function a_song_can_be_removed()
2016-06-13 09:04:42 +00:00
{
$this->expectsEvents(LibraryChanged::class);
$this->post('api/os/s3/song', [
'bucket' => 'koel',
'key' => 'sample.mp3',
'tags' => [
'lyrics' => '',
'duration' => 10,
],
])->seeInDatabase('songs', ['path' => 's3://koel/sample.mp3']);
$this->delete('api/os/s3/song', [
'bucket' => 'koel',
'key' => 'sample.mp3',
])->notSeeInDatabase('songs', ['path' => 's3://koel/sample.mp3']);
}
}