mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-07 19:50:39 +00:00
140 - Storing Files and Comparing Content
This commit is contained in:
@@ -53,6 +53,7 @@ class ConcertsController extends Controller
|
|||||||
'zip' => request('zip'),
|
'zip' => request('zip'),
|
||||||
'ticket_price' => request('ticket_price') * 100,
|
'ticket_price' => request('ticket_price') * 100,
|
||||||
'ticket_quantity' => (int) request('ticket_quantity'),
|
'ticket_quantity' => (int) request('ticket_quantity'),
|
||||||
|
'poster_image_path' => request('poster_image')->store('posters', 's3'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect()->route('backstage.concerts.index');
|
return redirect()->route('backstage.concerts.index');
|
||||||
|
|||||||
@@ -373,14 +373,23 @@ class AddConcertTest extends TestCase
|
|||||||
/** @test */
|
/** @test */
|
||||||
function poster_image_is_uploaded_if_included()
|
function poster_image_is_uploaded_if_included()
|
||||||
{
|
{
|
||||||
|
$this->disableExceptionHandling();
|
||||||
|
|
||||||
Storage::fake('s3');
|
Storage::fake('s3');
|
||||||
$user = factory(User::class)->create();
|
$user = factory(User::class)->create();
|
||||||
|
$file = File::image('concert-poster.png');
|
||||||
|
|
||||||
$response = $this->actingAs($user)->post('/backstage/concerts', $this->validParams([
|
$response = $this->actingAs($user)->post('/backstage/concerts', $this->validParams([
|
||||||
'poster_image' => File::image('concert-poster.png'),
|
'poster_image' => $file,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$this->assertNotNull(Concert::first()->poster_image_path);
|
tap(Concert::first(), function ($concert) use ($file) {
|
||||||
Storage::disk('s3')->assertExists(Concert::first()->poster_image_path);
|
$this->assertNotNull($concert->poster_image_path);
|
||||||
|
Storage::disk('s3')->assertExists($concert->poster_image_path);
|
||||||
|
$this->assertFileEquals(
|
||||||
|
$file->getPathname(),
|
||||||
|
Storage::disk('s3')->path($concert->poster_image_path)
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user