mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-03-08 04:02:27 +00:00
(add disableExceptionHandling helper, clean up comments)
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Exceptions\Handler;
|
||||||
|
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||||
|
|
||||||
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -22,4 +25,15 @@ abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
|
|||||||
|
|
||||||
return $app;
|
return $app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function disableExceptionHandling()
|
||||||
|
{
|
||||||
|
$this->app->instance(ExceptionHandler::class, new class extends Handler {
|
||||||
|
public function __construct() {}
|
||||||
|
public function report(Exception $e) {}
|
||||||
|
public function render($request, Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,13 @@ class PurchaseTicketsTest extends TestCase
|
|||||||
/** @test */
|
/** @test */
|
||||||
function customer_can_purchase_concert_tickets()
|
function customer_can_purchase_concert_tickets()
|
||||||
{
|
{
|
||||||
|
// Arrange
|
||||||
$paymentGateway = new FakePaymentGateway;
|
$paymentGateway = new FakePaymentGateway;
|
||||||
$this->app->instance(PaymentGateway::class, $paymentGateway);
|
$this->app->instance(PaymentGateway::class, $paymentGateway);
|
||||||
|
|
||||||
// Arrange
|
|
||||||
// Create a concert
|
|
||||||
$concert = factory(Concert::class)->create(['ticket_price' => 3250]);
|
$concert = factory(Concert::class)->create(['ticket_price' => 3250]);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
// Purchase concert tickets
|
|
||||||
$this->json('POST', "/concerts/{$concert->id}/orders", [
|
$this->json('POST', "/concerts/{$concert->id}/orders", [
|
||||||
'email' => 'john@example.com',
|
'email' => 'john@example.com',
|
||||||
'ticket_quantity' => 3,
|
'ticket_quantity' => 3,
|
||||||
@@ -32,10 +30,8 @@ class PurchaseTicketsTest extends TestCase
|
|||||||
// Assert
|
// Assert
|
||||||
$this->assertResponseStatus(201);
|
$this->assertResponseStatus(201);
|
||||||
|
|
||||||
// Make sure the customer was charged the correct amount
|
|
||||||
$this->assertEquals(9750, $paymentGateway->totalCharges());
|
$this->assertEquals(9750, $paymentGateway->totalCharges());
|
||||||
|
|
||||||
// Make sure that an order exists for this customer
|
|
||||||
$order = $concert->orders()->where('email', 'john@example.com')->first();
|
$order = $concert->orders()->where('email', 'john@example.com')->first();
|
||||||
$this->assertNotNull($order);
|
$this->assertNotNull($order);
|
||||||
$this->assertEquals(3, $order->tickets()->count());
|
$this->assertEquals(3, $order->tickets()->count());
|
||||||
|
|||||||
Reference in New Issue
Block a user