Files
ticketbeast/tests/unit/Billing/FakePaymentGatewayTest.php
2017-01-18 19:08:49 -05:00

35 lines
1.1 KiB
PHP

<?php
use App\Billing\FakePaymentGateway;
use App\Billing\PaymentFailedException;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class FakePaymentGatewayTest extends TestCase
{
use PaymentGatewayContractTests;
protected function getPaymentGateway()
{
return new FakePaymentGateway;
}
/** @test */
function running_a_hook_before_the_first_charge()
{
$paymentGateway = new FakePaymentGateway;
$timesCallbackRan = 0;
$paymentGateway->beforeFirstCharge(function ($paymentGateway) use (&$timesCallbackRan) {
$timesCallbackRan++;
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken());
$this->assertEquals(2500, $paymentGateway->totalCharges());
});
$paymentGateway->charge(2500, $paymentGateway->getValidTestToken());
$this->assertEquals(1, $timesCallbackRan);
$this->assertEquals(5000, $paymentGateway->totalCharges());
}
}