-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hey,
I think we shouldn't directly call Stripe/Stripe::Method
or $stripeEventApi = new Stripe\Event();
because it is mockable and so untestable.
In Stripe folder we can create a StripeFactory which is a class declare as a service and we can inject it into our controller, service, ...
public function handleAction(Request $request, StripeFactory $stripeFactory)
And we can use $stripeFactory->createEvent();
Thanks to this pattern we can easily mock the StripeFactory and mock Stripe method in order to make tests.
Add to this, the factory can be exposed and used outside the bundle (in main App).
What do you think of this?
EDIT: we can be inspired by this StripeClient: https://github.com/flo-sch/stripe-bundle/blob/master/Stripe/StripeClient.php for our factory.