You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is probably never gonna reach the top of your list, but here you go. I discovered while trying to unit test an addon I'm writing for GetPaid, that it's very hard to unit test the checkout ajax callback. The reason is that the Wordpress unit test case for testing Ajax calls, quite sensibly and correctly prevents the script from dying when wp_send_json_* is called by registering a custom die handler that throws an exception instead, and is meant to be caught by the test case. However GetPaid's checkout process catches the base Exception class, which makes it impossible for a custom die handler to gracefully stop the ajax action without killing the script.
Given that you already have a custom GetPaid_Payment_Exception used in places, I suggest you change all other places that throw the base Exception class to throw GetPaid_Payment_Exception instead and only catch GetPaid_Payment_Exception and not other Exceptions. This is also good practice I believe, since unexpected exceptions that may result from other code shouldn't be caught by you.
The text was updated successfully, but these errors were encountered:
This is probably never gonna reach the top of your list, but here you go. I discovered while trying to unit test an addon I'm writing for GetPaid, that it's very hard to unit test the checkout ajax callback. The reason is that the Wordpress unit test case for testing Ajax calls, quite sensibly and correctly prevents the script from dying when
wp_send_json_*
is called by registering a custom die handler that throws an exception instead, and is meant to be caught by the test case. However GetPaid's checkout process catches the baseException
class, which makes it impossible for a custom die handler to gracefully stop the ajax action without killing the script.Given that you already have a custom
GetPaid_Payment_Exception
used in places, I suggest you change all other places that throw the baseException
class to throwGetPaid_Payment_Exception
instead and only catchGetPaid_Payment_Exception
and not other Exceptions. This is also good practice I believe, since unexpected exceptions that may result from other code shouldn't be caught by you.The text was updated successfully, but these errors were encountered: