From 94480e7eacf8d82a38f12f1cc6b8daf3bd305dfa Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Tue, 8 Nov 2016 12:15:45 -0500 Subject: [PATCH] 2.3 - Outlining the First Purchasing Test --- tests/features/PurchaseTicketsTest.php | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/features/PurchaseTicketsTest.php diff --git a/tests/features/PurchaseTicketsTest.php b/tests/features/PurchaseTicketsTest.php new file mode 100644 index 0000000..ce53c79 --- /dev/null +++ b/tests/features/PurchaseTicketsTest.php @@ -0,0 +1,33 @@ +create(['ticket_price' => 3250]); + + // Act + // Purchase concert tickets + $this->json('POST', "/concerts/{$concert->id}/orders", [ + 'email' => 'john@example.com', + 'ticket_quantity' => 3, + 'payment_token' => $paymentGateway->getValidTestToken(), + ]); + + // Assert + // Make sure the customer was charged the correct amount + $this->assertEquals(9750, $paymentGateway->totalCharges()); + + // Make sure that an order exists for this customer + $order = $concert->orders()->where('email', 'john@example.com')->first(); + $this->assertNotNull($order); + $this->assertEquals(3, $order->tickets->count()); + } +}