6.5 - Hooking into Charges

This commit is contained in:
Adam Wathan
2016-11-19 20:50:31 -05:00
parent d855fa3e16
commit 85c79f32b8
2 changed files with 26 additions and 0 deletions

View File

@@ -30,4 +30,20 @@ class FakePaymentGatewayTest extends TestCase
$this->fail();
}
/** @test */
function running_a_hook_before_the_first_charge()
{
$paymentGateway = new FakePaymentGateway;
$callbackRan = false;
$paymentGateway->beforeFirstCharge(function ($paymentGateway) use (&$callbackRan) {
$callbackRan = true;
$this->assertEquals(0, $paymentGateway->totalCharges());
});
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken());
$this->assertTrue($callbackRan);
$this->assertEquals(2500, $paymentGateway->totalCharges());
}
}