这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions billing.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- [Payments Requiring Additional Confirmation](#payments-requiring-additional-confirmation)
- [Off-session Payment Notifications](#off-session-payment-notifications)
- [Stripe SDK](#stripe-sdk)
- [Testing](#testing)

<a name="introduction"></a>
## Introduction
Expand Down Expand Up @@ -928,3 +929,16 @@ Many of Cashier's objects are wrappers around Stripe SDK objects. If you would l
$stripeSubscription = $subscription->asStripeSubscription();

$stripeSubscription->update(['application_fee_percent' => 5]);

<a name="testing"></a>
## Testing

When testing an application that uses Cashier, you may mock the actual HTTP requests to the Stripe API; however, this requires you to partially re-implement Cashier's own behavior. Therefore, we recommend allowing your tests to hit the actual Stripe API. While this is slower, it provides more confidence that your application is working as expected and any slow tests may be placed within their own PHPUnit testing group.

When testing, remember that that Cashier itself already has a great test suite, so you should only focus on testing the subscription and payment flow of your own application and not every underlying Cashier behavior.

To get started, add the **testing** version of your Stripe secret to your `phpunit.xml` file:

<env name="STRIPE_SECRET" value="sk_test_<your-key>"/>

Now, whenever you interact with Cashier while testing, it will send actual API requests to your Stripe testing environment. For convenience, you should pre-fill your Stripe testing account with subscriptions / plans that you may then use during testing.
19 changes: 19 additions & 0 deletions http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,22 @@ The `assertSent` method accepts a callback which will be given an `Illuminate\Ht
$request['name'] == 'Taylor' &&
$request['role'] == 'Developer';
});

If needed, you may assert that a specific request was not sent using the `assertNotSent` method:

Http::fake();

Http::post('http://test.com/users', [
'name' => 'Taylor',
'role' => 'Developer',
]);

Http::assertNotSent(function (Request $request) {
return $request->url() === 'http://test.com/posts';
});

Or, if you would like to assert that no requests were sent, you may use the `assertNothingSent` method:

Http::fake();

Http::assertNothingSent();