From dac978ea8a36d1b583c20193a1a9aa7e79219e26 Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Fri, 10 Feb 2017 14:01:13 -0500 Subject: [PATCH] 70 - Driving out the Endpoint --- app/Http/Controllers/OrdersController.php | 13 +++++++++++++ .../2016_11_08_205823_create_orders_table.php | 1 + routes/web.php | 2 ++ tests/features/ViewOrderTest.php | 9 +++++++-- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 app/Http/Controllers/OrdersController.php diff --git a/app/Http/Controllers/OrdersController.php b/app/Http/Controllers/OrdersController.php new file mode 100644 index 0000000..99544a7 --- /dev/null +++ b/app/Http/Controllers/OrdersController.php @@ -0,0 +1,13 @@ +increments('id'); + $table->string('confirmation_number'); $table->integer('amount'); $table->string('email'); $table->timestamps(); diff --git a/routes/web.php b/routes/web.php index a1159b0..6c261db 100644 --- a/routes/web.php +++ b/routes/web.php @@ -18,3 +18,5 @@ Route::get('/mockups/order', function () { Route::get('/concerts/{id}', 'ConcertsController@show'); Route::post('/concerts/{id}/orders', 'ConcertOrdersController@store'); + +Route::get('/orders/{confirmationNumber}', 'OrdersController@show'); diff --git a/tests/features/ViewOrderTest.php b/tests/features/ViewOrderTest.php index 96f5492..cd2f4c4 100644 --- a/tests/features/ViewOrderTest.php +++ b/tests/features/ViewOrderTest.php @@ -14,16 +14,21 @@ class ViewOrderTest extends TestCase /** @test */ function user_can_view_their_order_confirmation() { + $this->disableExceptionHandling(); + $concert = factory(Concert::class)->create(); - $order = factory(Order::class)->create(); + $order = factory(Order::class)->create([ + 'confirmation_number' => 'ORDERCONFIRMATION1234' + ]); $ticket = factory(Ticket::class)->create([ 'concert_id' => $concert->id, 'order_id' => $order->id, ]); // Visit the order confirmation page - $this->get("/orders/{$order->id}"); + $response = $this->get("/orders/ORDERCONFIRMATION1234"); + $response->assertStatus(200); // Assert we see the correct order details } }