Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Jobs/PaymentEmailTest.php
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | public function testHandle() | ||||
$job = new PaymentEmail($payment); | $job = new PaymentEmail($payment); | ||||
$job->handle(); | $job->handle(); | ||||
// Assert the email sending job was pushed once | // Assert the email sending job was pushed once | ||||
Mail::assertSent(PaymentSuccess::class, 1); | Mail::assertSent(PaymentSuccess::class, 1); | ||||
// Assert the mail was sent to the user's email | // Assert the mail was sent to the user's email | ||||
Mail::assertSent(PaymentSuccess::class, function ($mail) use ($user) { | Mail::assertSent(PaymentSuccess::class, function ($mail) { | ||||
return $mail->hasTo($user->email) && $mail->hasCc('ext@email.tld'); | return $mail->hasTo('ext@email.tld') && !$mail->hasCc('ext@email.tld'); | ||||
}); | }); | ||||
$payment->status = PaymentProvider::STATUS_FAILED; | $payment->status = PaymentProvider::STATUS_FAILED; | ||||
$payment->save(); | $payment->save(); | ||||
$job = new PaymentEmail($payment); | $job = new PaymentEmail($payment); | ||||
$job->handle(); | $job->handle(); | ||||
// Assert the email sending job was pushed once | // Assert the email sending job was pushed once | ||||
Mail::assertSent(PaymentFailure::class, 1); | Mail::assertSent(PaymentFailure::class, 1); | ||||
// Assert the mail was sent to the user's email | // Assert the mail was sent to the user's email | ||||
Mail::assertSent(PaymentFailure::class, function ($mail) use ($user) { | Mail::assertSent(PaymentFailure::class, function ($mail) { | ||||
return $mail->hasTo($user->email) && $mail->hasCc('ext@email.tld'); | return $mail->hasTo('ext@email.tld') && !$mail->hasCc('ext@email.tld'); | ||||
}); | }); | ||||
$payment->status = PaymentProvider::STATUS_EXPIRED; | $payment->status = PaymentProvider::STATUS_EXPIRED; | ||||
$payment->save(); | $payment->save(); | ||||
$job = new PaymentEmail($payment); | $job = new PaymentEmail($payment); | ||||
$job->handle(); | $job->handle(); | ||||
Show All 25 Lines |