mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-01 19:47:29 +00:00
95 - Using a Fake to Intercept Email
This commit is contained in:
@@ -4,6 +4,8 @@ use App\Concert;
|
||||
use App\Facades\TicketCode;
|
||||
use App\Billing\PaymentGateway;
|
||||
use App\Billing\FakePaymentGateway;
|
||||
use App\Mail\OrderConfirmationEmail;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Facades\OrderConfirmationNumber;
|
||||
use App\OrderConfirmationNumberGenerator;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
@@ -53,6 +55,7 @@ class PurchaseTicketsTest extends TestCase
|
||||
function customer_can_purchase_tickets_to_a_published_concert()
|
||||
{
|
||||
$this->disableExceptionHandling();
|
||||
Mail::fake();
|
||||
|
||||
OrderConfirmationNumber::shouldReceive('generate')->andReturn('ORDERCONFIRMATION1234');
|
||||
TicketCode::shouldReceive('generateFor')->andReturn('TICKETCODE1', 'TICKETCODE2', 'TICKETCODE3');
|
||||
@@ -80,7 +83,14 @@ class PurchaseTicketsTest extends TestCase
|
||||
|
||||
$this->assertEquals(9750, $this->paymentGateway->totalCharges());
|
||||
$this->assertTrue($concert->hasOrderFor('john@example.com'));
|
||||
$this->assertEquals(3, $concert->ordersFor('john@example.com')->first()->ticketQuantity());
|
||||
|
||||
$order = $concert->ordersFor('john@example.com')->first();
|
||||
$this->assertEquals(3, $order->ticketQuantity());
|
||||
|
||||
Mail::assertSent(OrderConfirmationEmail::class, function ($mail) use ($order) {
|
||||
return $mail->hasTo('john@example.com')
|
||||
&& $mail->order->id == $order->id;
|
||||
});
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
||||
Reference in New Issue
Block a user