Skip to main content

Testing

Subscribd ships a fake gateway driver that processes all billing operations synchronously in-memory, with no HTTP calls. Use it in your test suite to test subscription creation, plan swaps, cancellations, invoices, and entitlements without mocking.

Setup

Set SUBSCRIBD_GATEWAY=fake in your phpunit.xml or pest.config.php:
Or configure it per-test in setUp():
The fake gateway is already registered in config/subscribd.php:

Creating a subscription in tests

Testing plan swaps

Testing cancellation

Testing invoices

Testing entitlements

Testing trials

Testing events

Use Laravel’s Event::fake() to assert events are fired:

Simulating payment failure

The FakeGateway can be instructed to fail on the next operation:

Time travel

Use Laravel’s $this->travel() or Pest’s freeze() to test time-dependent billing behaviour:

Using factories

Subscribd ships model factories for all its models. Use them directly in tests:

Next steps