mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-04 11:48:30 +00:00
52 - Avoiding Service Classes with Method Injection
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
use App\Ticket;
|
||||
use App\Concert;
|
||||
use App\Reservation;
|
||||
use App\Billing\FakePaymentGateway;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
@@ -71,11 +72,13 @@ class ReservationTest extends TestCase
|
||||
$concert = factory(Concert::class)->create(['ticket_price' => 1200]);
|
||||
$tickets = factory(Ticket::class, 3)->create(['concert_id' => $concert->id]);
|
||||
$reservation = new Reservation($tickets, 'john@example.com');
|
||||
$paymentGateway = new FakePaymentGateway;
|
||||
|
||||
$order = $reservation->complete();
|
||||
$order = $reservation->complete($paymentGateway, $paymentGateway->getValidTestToken());
|
||||
|
||||
$this->assertEquals('john@example.com', $order->email);
|
||||
$this->assertEquals(3, $order->ticketQuantity());
|
||||
$this->assertEquals(3600, $order->amount);
|
||||
$this->assertEquals(3600, $paymentGateway->totalCharges());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user