Testing
Subscribd ships afake 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
SetSUBSCRIBD_GATEWAY=fake in your phpunit.xml or pest.config.php:
setUp():
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’sEvent::fake() to assert events are fired:
Simulating payment failure
TheFakeGateway 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
- Hooks and Events — Full event reference for assertions
- Filament Integration — Testing Filament resources