57 - Don't Mock What You Don't Own

This commit is contained in:
Adam Wathan
2016-12-30 13:15:24 -05:00
parent 3472361c35
commit 7eb064a9ec
6 changed files with 294 additions and 6 deletions

View File

@@ -0,0 +1,21 @@
<?php
use App\Billing\Alternate\StripePaymentGateway;
class MockStripePaymentGatewayTest extends TestCase
{
/** @test */
function charges_with_a_valid_payment_token_are_successful()
{
$stripeClient = Mockery::spy(\Stripe\ApiClient::class);
$paymentGateway = new StripePaymentGateway($stripeClient);
$paymentGateway->charge(2500, 'valid-token');
$stripeClient->shouldHaveReceived('createCharge')->with([
'amount' => 2500,
'source' => 'valid-token',
'currency' => 'usd',
])->once();
}
}

View File

@@ -1,9 +1,6 @@
<?php
use App\Billing\StripePaymentGateway;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class StripePaymentGatewayTest extends TestCase
{