Files
ticketbeast/tests/features/ViewOrderTest.php
2017-02-10 20:45:38 -05:00

53 lines
1.6 KiB
PHP

<?php
use App\Order;
use App\Ticket;
use App\Concert;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class ViewOrderTest extends TestCase
{
use DatabaseMigrations;
/** @test */
function user_can_view_their_order_confirmation()
{
$this->disableExceptionHandling();
$concert = factory(Concert::class)->create();
$order = factory(Order::class)->create([
'confirmation_number' => 'ORDERCONFIRMATION1234',
'card_last_four' => '1881',
'amount' => 8500,
]);
$ticketA = factory(Ticket::class)->create([
'concert_id' => $concert->id,
'order_id' => $order->id,
'code' => 'TICKETCODE123'
]);
$ticketB = factory(Ticket::class)->create([
'concert_id' => $concert->id,
'order_id' => $order->id,
'code' => 'TICKETCODE456'
]);
// Visit the order confirmation page
$response = $this->get("/orders/ORDERCONFIRMATION1234");
$response->assertStatus(200);
// Assert we see the correct order details
$response->assertViewHas('order', function ($viewOrder) use ($order) {
return $order->id === $viewOrder->id;
});
$response->assertSee('ORDERCONFIRMATION1234');
$response->assertSee('$85.00');
$response->assertSee('**** **** **** 1881');
$response->assertSee('TICKETCODE123');
$response->assertSee('TICKETCODE456');
}
}