2.9 - Handling Failed Charges

This commit is contained in:
Adam Wathan
2016-11-11 10:30:02 -05:00
parent 62bf031a17
commit 3f9ff57785
5 changed files with 47 additions and 9 deletions

View File

@@ -1,6 +1,7 @@
<?php
use App\Billing\FakePaymentGateway;
use App\Billing\PaymentFailedException;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@@ -16,4 +17,17 @@ class FakePaymentGatewayTest extends TestCase
$this->assertEquals(2500, $paymentGateway->totalCharges());
}
/** @test */
function charges_with_an_invalid_payment_token_fail()
{
try {
$paymentGateway = new FakePaymentGateway;
$paymentGateway->charge(2500, 'invalid-payment-token');
} catch (PaymentFailedException $e) {
return;
}
$this->fail();
}
}