-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
CRM-21436: Fix exception on pay later contribution page. #11317
CRM-21436: Fix exception on pay later contribution page. #11317
Conversation
this looks good to me - code makes sense |
0f420a5
to
0c1663c
Compare
Jenkins re test this please |
try { | ||
$form->preProcess(); | ||
} | ||
catch (CRM_Core_Exception $e) { |
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 the expectation is that an extension is thrown here, this will still pass if one is not. You can add a return in the catch box & a $this->markFail('exception was expected'); to deal with that
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.
Oh Thanks, seems I was extra optimistic here ;-)
@jitendrapurohit the failing test is related |
(it might be a thing where the test works in isolation but in the test suite perhaps some data from another test interferes) |
Not sure whats wrong, the test passes on my local individually and also if I run the whole file. Jenkin seems to be failing because the contribution page which is in process is disabled. But Only thing I can see is that the contribution_page table might be having some extra rows in it. I've added this table in the teardown() function. Any more pointers? |
@jitendrapurohit i have been doing some looking into this on the jenkins test box So what I have found is that when you run ./tools/scripts/phpunit 'CRM_AllTests' which is essentially what Jenkins does, the test fails because even though
|
|
||
//Execute CRM_Contribute_Form_ContributionBase preProcess | ||
//and check the assignment of payment processors | ||
$form = new CRM_Contribute_Form_ContributionBase(); |
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.
maybe it would help to load the form 'Main' rather than it's parent? There is a helper 'getForm' which might set things that matter
I deployed the patch to our production testers, and so far so good. |
@jitendrapurohit if you are still struggling with the test after looking again today let's split this into 2 prs - a fix that I will merge against the rc and the unit test against master. We are getting tight on the rc timeframe now & I agree this is an essential patch to be in there. (not that I don't want the test finished - just creating an option if you think it might take longer than we really want this to be pending merging) |
CRM/Core/Form.php
Outdated
@@ -129,7 +129,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { | |||
* | |||
* @var int | |||
*/ | |||
protected $_is_pay_later_enabled; | |||
protected $isPayLaterEnabled; |
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 notice that this variable is not used in this class. Is it used anywhere else? i.e. any risk of breaking something else?
Also I notice that most protected variables start with _
, but there are exceptions. Are there coding guidelines on this?
(this is mostly out of curiosity, I would not block merging)
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.
@mlutfy it was an oldschool way of showing something was private https://stackoverflow.com/questions/663350/whats-the-deal-with-a-leading-underscore-in-php-class-methods
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.
Probably better to move any changes that are more clean up to a pr against master
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.
ie. this one could be used by any class that inherits from CRM_Core_Form so it might be better on master - the one below is fine as is as it is easy by reading it to feel confident about renaming that var
Thanks @seamuslee001 that is much helpful, and I'm still thinking why teardown() function wasn't able to handle that. Anyway, I've separated the unit test as mentioned by @eileenmcnaughton and have submitted it against master #11334. I can take a look later this week, as now we've steps for replicating it on my local :-). Will also consider @mlutfy comment about the variable on the master PR. |
@jitendra - if you want to pull out that very first change (the one to the name of the form property) I'll give this merge-on-pass & we can look at that line on master |
I thought I included that in my previous commit - done now. |
I just merged it - we've seen the test results enough times to know it's only the new test failing. Will up-merge to master now. Thanks @jitendrapurohit - I think this & the one you did earlier are solid fixes that improve the robustness & logic of the code |
* CRM-21436: Fix exception on pay later contribution page. * minor fix * move test against master * variable fix
Overview
This is an extension of #11286 and fixes exception on a pay later contribution page.
Before
If no payment processor is selected, contribution page displays the following exception.
After
Contribution page loads fine with pay later processor.
Technical Details
Assignment of pay_later was done after checking if there are any processors enabled on the contribution page. This PR assigns paylater processor just before the check so that it gets assigned correctly even if none of the payment processor is configured.
Comments
Added unit test.