mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-06 18:49:57 +00:00
66 - Extracting the Failure Case
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Billing\PaymentFailedException;
|
||||
|
||||
trait PaymentGatewayContractTests
|
||||
{
|
||||
abstract protected function getPaymentGateway();
|
||||
@@ -17,6 +19,24 @@ trait PaymentGatewayContractTests
|
||||
$this->assertEquals(2500, $newCharges->sum());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function charges_with_an_invalid_payment_token_fail()
|
||||
{
|
||||
$paymentGateway = $this->getPaymentGateway();
|
||||
|
||||
$newCharges = $paymentGateway->newChargesDuring(function ($paymentGateway) {
|
||||
try {
|
||||
$paymentGateway->charge(2500, 'invalid-payment-token');
|
||||
} catch (PaymentFailedException $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->fail("Charging with an invalid payment token did not throw a PaymentFailedException.");
|
||||
});
|
||||
|
||||
$this->assertCount(0, $newCharges);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function can_fetch_charges_created_during_a_callback()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user