diff --git a/database/migrations/2016_11_01_200307_create_concerts_table.php b/database/migrations/2016_11_01_200307_create_concerts_table.php index 85faced..6323cec 100644 --- a/database/migrations/2016_11_01_200307_create_concerts_table.php +++ b/database/migrations/2016_11_01_200307_create_concerts_table.php @@ -27,6 +27,7 @@ class CreateConcertsTable extends Migration $table->string('zip'); $table->integer('ticket_price'); $table->integer('ticket_quantity'); + $table->string('poster_image_path'); $table->datetime('published_at')->nullable(); $table->timestamps(); }); diff --git a/tests/Feature/Backstage/AddConcertTest.php b/tests/Feature/Backstage/AddConcertTest.php index e2098f9..5278b56 100644 --- a/tests/Feature/Backstage/AddConcertTest.php +++ b/tests/Feature/Backstage/AddConcertTest.php @@ -6,6 +6,8 @@ use App\User; use App\Concert; use Carbon\Carbon; use Tests\TestCase; +use Illuminate\Http\Testing\File; +use Illuminate\Support\Facades\Storage; use Illuminate\Foundation\Testing\DatabaseMigrations; class AddConcertTest extends TestCase @@ -367,4 +369,18 @@ class AddConcertTest extends TestCase $response->assertSessionHasErrors('ticket_quantity'); $this->assertEquals(0, Concert::count()); } + + /** @test */ + function poster_image_is_uploaded_if_included() + { + Storage::fake('s3'); + $user = factory(User::class)->create(); + + $response = $this->actingAs($user)->post('/backstage/concerts', $this->validParams([ + 'poster_image' => File::image('concert-poster.png'), + ])); + + $this->assertNotNull(Concert::first()->poster_image_path); + Storage::disk('s3')->assertExists(Concert::first()->poster_image_path); + } }