-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Cancel Recur Subscription test & setter for supports
on Dummy processor
#21895
Conversation
(Standard links)
|
/** | ||
* Class CRM_Contribute_Form_CancelRecurSubscriptionTest | ||
*/ | ||
class CRM_Contribute_Form_CancelRecurSubscriptionTest extends CRM_Contribute_Form_RecurForms { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kartik1000 there is already a test class CRM_Contribute_Form_CancelSubscriptionTest
which covers this form (& better matches the form class name) - can you add your test to that rather than add this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kartik1000 please update per suggestion
CRM/Core/Payment/Manual.php
Outdated
@@ -17,6 +17,16 @@ | |||
class CRM_Core_Payment_Manual extends CRM_Core_Payment { | |||
|
|||
protected $result; | |||
protected $_supports = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach is generally fine - we have been moving away from the underscore in class property names though - see the property above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kartik1000 Sorry I gave you this example :-) Please change to protected $supports =
I think this makes sense. Minor comments inline |
@kartik1000 The changes for |
|
supports
on Dummy processor
@kartik1000 I updated the PR template slightly to reflect your setter for |
@eileenmcnaughton I agree, I will add a description both in template PR and the in code comments (above the support variable preferably). |
@eileenmcnaughton I have updated the PR description and added the same in in-code comments as well. |
CRM/Core/Payment/Manual.php
Outdated
@@ -17,6 +17,8 @@ | |||
class CRM_Core_Payment_Manual extends CRM_Core_Payment { | |||
|
|||
protected $result; | |||
// This support variable is used to allow the capabilities supported by the Dummy processor to be set from outside the class. | |||
// Initially these capabilities are set to TRUE, however they can be altered by calling the setSupports function directly from outside the class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kartik1000 can you go a bit further & explain why someone would wan to do that? Your use case.
I admit I'm confused by this
Wouldn't you just update the processor to support other capabilities? |
@demeritcowboy Normally yes. But dummy is being used here as a special case for testing. By "dynamically" updating the capabilities we can test multiple scenarios that would otherwise be untestable without finding/creating payment processors with specific combinations of "supportsX". And you get scenarios like eg. Stripe doesn't support updateSubscription but will do so if you chose that to test that "a processor does not support updateSubscription" the test would break once you introduce the new feature. |
Ok thanks I see. So then the remaining issues are:
I think using "settings" over the Power of OO can be justified to avoid hundreds of subclasses. Just at the point where some function starts getting nested |
test this please |
I'm actually OK with this being on Dummy or Manual or the parent class (would require a bit more care to ensure no defaults change) - but I don't know how interested @kartik1000 is in doing more on it |
Test fail is: Manual.php:22 | VariableComment | WrongStyle | Error |
CRM/Core/Payment/Manual.php
Outdated
@@ -18,6 +18,22 @@ class CRM_Core_Payment_Manual extends CRM_Core_Payment { | |||
|
|||
protected $result; | |||
|
|||
/** | |||
* This support variable is used to allow the capabilities supported by the Dummy processor to be set from outside the class. | |||
* Initially these capabilities are set to TRUE, however they can be altered by calling the setSupports function directly from outside the class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're updating this anyway can we add some more explanation, and it's not the Dummy processor. Maybe something like
This support variable is used to allow the capabilities supported by the Manual processor to be set from unit tests so that we don't need to create a lot of new processors to test combinations of features.
Now cleaned up and tests should pass. Changes should be on Dummy processor because that's what is usually used in tests and it already has other "infrastructure" for testing (eg. setting doPayment result). |
71f5b90
to
19c24ff
Compare
Overview
Added Test in follow up to #18196. Have also added a function in
CRM_Core_Payment_Dummy
to set the return value for support functions.This also allows the capabilities supported by the Dummy processor to be set from outside the class. This is done by adding a support array where the capabilities are initially set to
TRUE
but can be altered by using thesetSupports
Function. This can be highly useful to alter the capabilities of dummy processors from directly outside the class in future tests as well.Comments
Functions used within the test have been extended from
RecurForms.php
added in #21588