3.1 - Outlining the First Test Case

This commit is contained in:
Adam Wathan
2016-11-13 16:38:01 -05:00
parent a522b2389c
commit ce22ff1ec6

View File

@@ -79,6 +79,25 @@ class PurchaseTicketsTest extends TestCase
$this->assertNull($order);
}
/** @test */
function cannot_purchase_more_tickets_than_remain()
{
$concert = factory(Concert::class)->states('published')->create();
$concert->addTickets(50);
$this->orderTickets($concert, [
'email' => 'john@example.com',
'ticket_quantity' => 51,
'payment_token' => $this->paymentGateway->getValidTestToken(),
]);
$this->assertResponseStatus(422);
$order = $concert->orders()->where('email', 'john@example.com')->first();
$this->assertNull($order);
$this->assertEquals(0, $this->paymentGateway->totalCharges());
$this->assertEquals(50, $concert->ticketsRemaining());
}
/** @test */
function email_is_required_to_purchase_tickets()
{