mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
2.9 - Handling Failed Charges
This commit is contained in:
@@ -32,26 +32,37 @@ class PurchaseTicketsTest extends TestCase
|
||||
/** @test */
|
||||
function customer_can_purchase_concert_tickets()
|
||||
{
|
||||
// Arrange
|
||||
$concert = factory(Concert::class)->create(['ticket_price' => 3250]);
|
||||
|
||||
// Act
|
||||
$this->orderTickets($concert, [
|
||||
'email' => 'john@example.com',
|
||||
'ticket_quantity' => 3,
|
||||
'payment_token' => $this->paymentGateway->getValidTestToken(),
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$this->assertResponseStatus(201);
|
||||
|
||||
$this->assertEquals(9750, $this->paymentGateway->totalCharges());
|
||||
|
||||
$order = $concert->orders()->where('email', 'john@example.com')->first();
|
||||
$this->assertNotNull($order);
|
||||
$this->assertEquals(3, $order->tickets()->count());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function an_order_is_not_created_if_payment_fails()
|
||||
{
|
||||
$concert = factory(Concert::class)->create(['ticket_price' => 3250]);
|
||||
|
||||
$this->orderTickets($concert, [
|
||||
'email' => 'john@example.com',
|
||||
'ticket_quantity' => 3,
|
||||
'payment_token' => 'invalid-payment-token',
|
||||
]);
|
||||
|
||||
$this->assertResponseStatus(422);
|
||||
$order = $concert->orders()->where('email', 'john@example.com')->first();
|
||||
$this->assertNull($order);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function email_is_required_to_purchase_tickets()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user