mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-03-01 01:58:48 +00:00
65 - Extracting a Contract Test
This commit is contained in:
@@ -8,40 +8,13 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class FakePaymentGatewayTest extends TestCase
|
||||
{
|
||||
use PaymentGatewayContractTests;
|
||||
|
||||
protected function getPaymentGateway()
|
||||
{
|
||||
return new FakePaymentGateway;
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function can_fetch_charges_created_during_a_callback()
|
||||
{
|
||||
$paymentGateway = $this->getPaymentGateway();
|
||||
$paymentGateway->charge(2000, $paymentGateway->getValidTestToken());
|
||||
$paymentGateway->charge(3000, $paymentGateway->getValidTestToken());
|
||||
|
||||
$newCharges = $paymentGateway->newChargesDuring(function ($paymentGateway) {
|
||||
$paymentGateway->charge(4000, $paymentGateway->getValidTestToken());
|
||||
$paymentGateway->charge(5000, $paymentGateway->getValidTestToken());
|
||||
});
|
||||
|
||||
$this->assertCount(2, $newCharges);
|
||||
$this->assertEquals([4000, 5000], $newCharges->all());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function charges_with_a_valid_payment_token_are_successful()
|
||||
{
|
||||
$paymentGateway = $this->getPaymentGateway();
|
||||
|
||||
$newCharges = $paymentGateway->newChargesDuring(function ($paymentGateway) {
|
||||
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken());
|
||||
});
|
||||
|
||||
$this->assertCount(1, $newCharges);
|
||||
$this->assertEquals(2500, $newCharges->sum());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function charges_with_an_invalid_payment_token_fail()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user