6.6 - Uh Oh, a Segault

This commit is contained in:
Adam Wathan
2016-11-20 17:46:56 -05:00
parent 85c79f32b8
commit 91672fef0b

View File

@@ -105,13 +105,31 @@ class PurchaseTicketsTest extends TestCase
/** @test */
function cannot_purchase_tickets_another_customer_is_already_trying_to_purchase()
{
$concert = factory(Concert::class)->states('published')->create()->addTickets(3);
$concert = factory(Concert::class)->states('published')->create([
'ticket_price' => 1200
])->addTickets(3);
$this->paymentGateway->beforeFirstCharge(function ($paymentGateway) use ($concert) {
$this->orderTickets($concert, [
'email' => 'personB@example.com',
'ticket_quantity' => 1,
'payment_token' => $this->paymentGateway->getValidTestToken(),
]);
$this->assertResponseStatus(422);
$this->assertFalse($concert->hasOrderFor('personB@example.com'));
$this->assertEquals(0, $this->paymentGateway->totalCharges());
});
$this->orderTickets($concert, [
'email' => 'personA@example.com',
'ticket_quantity' => 51,
'ticket_quantity' => 3,
'payment_token' => $this->paymentGateway->getValidTestToken(),
]);
$this->assertEquals(3600, $this->paymentGateway->totalCharges());
$this->assertTrue($concert->hasOrderFor('personA@example.com'));
$this->assertEquals(3, $concert->ordersFor('personA@example.com')->first()->ticketQuantity());
}
/** @test */