139 - Faking Uploads and File Systems

This commit is contained in:
Adam Wathan
2017-09-28 15:48:07 -04:00
parent d1fb33ed65
commit 7cded06a0b
2 changed files with 17 additions and 0 deletions

View File

@@ -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);
}
}