mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
2.3 - Outlining the First Purchasing Test
This commit is contained in:
33
tests/features/PurchaseTicketsTest.php
Normal file
33
tests/features/PurchaseTicketsTest.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
|
class PurchaseTicketsTest extends TestCase
|
||||||
|
{
|
||||||
|
/** @test */
|
||||||
|
function customer_can_purchase_concert_tickets()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
// Create a concert
|
||||||
|
$concert = factory(Concert::class)->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());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user