Open wjgilmore opened 8 years ago
Hi,
we were debating about the best way to enable this but it seems that everything we come up with is kind of an ugly hack, at least in our opinion. Any way of tricking Laravel is a bit "shady" IMO but I would love to hear your ideas, maybe you have a clean approach we didn't think of yet :)
Laravel 5+ test framework supports making post requests as part of the TestCase class. See https://laravel.com/api/5.2/Illuminate/Foundation/Testing/TestCase.html#method_post
@rikh42 yap, you're right, in this case you could only use the loadEventData
method to load the webhook data and simply make a post request
I've also had this issue in Laravel, solved it by adding a method to TestCase class:
protected function triggerStripeWebhook($event)
{
$tester = (new WebhookTester())->setVersion('2018-05-21');
$data = $tester->loadEventData($event);
return $this->call('POST', route('stripe.webhook'), [], [], [], [], $data);
}
Now I can trigger a webhook with $this->triggerStripeWebhook('charge.succeeded');
in my tests.
Hi,
I'm finding this package useful, and plan on submitting a pull request soon which contains among other things an updated set of event templates for the 2015-10-12 API. I do have a question though: when a test is run, it makes a call to the webhook endpoint using
setEndpoint
, however when this call is made the webhook will be run using the local environment, which means the local (rather than testing) database is used. I can think of a few different ways to trick Laravel into using the test environment for such purposes, however wanted to ask what the Team TNT team is doing to resolve this issue.Jason