70 - Driving out the Endpoint

This commit is contained in:
Adam Wathan
2017-02-10 14:01:13 -05:00
parent b3ff9e8624
commit dac978ea8a
4 changed files with 23 additions and 2 deletions

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class OrdersController extends Controller
{
public function show()
{
}
}

View File

@@ -15,6 +15,7 @@ class CreateOrdersTable extends Migration
{ {
Schema::create('orders', function (Blueprint $table) { Schema::create('orders', function (Blueprint $table) {
$table->increments('id'); $table->increments('id');
$table->string('confirmation_number');
$table->integer('amount'); $table->integer('amount');
$table->string('email'); $table->string('email');
$table->timestamps(); $table->timestamps();

View File

@@ -18,3 +18,5 @@ Route::get('/mockups/order', function () {
Route::get('/concerts/{id}', 'ConcertsController@show'); Route::get('/concerts/{id}', 'ConcertsController@show');
Route::post('/concerts/{id}/orders', 'ConcertOrdersController@store'); Route::post('/concerts/{id}/orders', 'ConcertOrdersController@store');
Route::get('/orders/{confirmationNumber}', 'OrdersController@show');

View File

@@ -14,16 +14,21 @@ class ViewOrderTest extends TestCase
/** @test */ /** @test */
function user_can_view_their_order_confirmation() function user_can_view_their_order_confirmation()
{ {
$this->disableExceptionHandling();
$concert = factory(Concert::class)->create(); $concert = factory(Concert::class)->create();
$order = factory(Order::class)->create(); $order = factory(Order::class)->create([
'confirmation_number' => 'ORDERCONFIRMATION1234'
]);
$ticket = factory(Ticket::class)->create([ $ticket = factory(Ticket::class)->create([
'concert_id' => $concert->id, 'concert_id' => $concert->id,
'order_id' => $order->id, 'order_id' => $order->id,
]); ]);
// Visit the order confirmation page // 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 // Assert we see the correct order details
} }
} }