Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Membership tests and fix #44

Merged
merged 2 commits into from
Nov 15, 2018
Merged

Conversation

aydun
Copy link
Contributor

@aydun aydun commented Nov 13, 2018

I've added some tests for memberships in the first commit which shows a problem.
The second commit fixes that.

For background, see analysis by @wmortada in #42

@artfulrobot
Copy link
Owner

Looks great, will have proper look on Thursday. Thanks so much.

@artfulrobot
Copy link
Owner

artfulrobot commented Nov 15, 2018

Hi @aydun

Thanks for all the test code, the extension really needed a membership expert to write that stuff as I'm not familiar with the intricacies of it.

I confirm all the tests are passing for me. One question about the tests: you've added membership code to the existing testTransferCheckoutCompletesWithoutInstallments test, instead of having a separate test. At first I thought "Ah, but we still need to test the non-membership case", so I looked into it.

The code I was remembering is at
https://github.com/artfulrobot/uk.artfulrobot.civicrm.gocardless/blob/master/CRM/GoCardlessUtils.php#L225

Which has branches for membership. However, if I understand correctly, I don't think the membership elseif() of that code will ever be run, since there will always be a ContributionRecur record (since we don't do one-offs - yet).

So actually, that code (my code there) is pretty useless (until the extension does do one offs) and therfore it makes no difference adding to the existing test; so I think it's fine. Do you agree?

Also, I'm considering publishing this as 'stable' now these membership things have been fixed because it's been in use for years and the membership was the bit I was worried about. Thoughts on that anyone?

@aydun
Copy link
Contributor Author

aydun commented Nov 15, 2018

I wouldn't call myself a membership expert, but I know a bit about it!

As you say, I added membership tests to testTransferCheckoutCompletesWithoutInstallments. I started with a separate test and then found I was repeating most of what was there and just adding tests. I don't think it alters the validity of the existing tests. However, on reflection maybe we should keep the original as well so that we are also explicitly testing a non-membership scenario.

As regards the code you highlighted ... I couldn't see how that membership elseif() would get used since we're only dealing with recurring situations, but I assumed it was there for a reason! I think we can just remove the whole elseif() block at https://github.com/artfulrobot/uk.artfulrobot.civicrm.gocardless/blob/master/CRM/GoCardlessUtils.php#L237-L244

So, I'd suggest we remove that code and reshuffle the tests so that we explicitly test membership and non-membership scenarios. If you agree I'll push another commit. A 'stable' release would be good - perhaps we can get @wmortada and @Upperholme to confirm their issues are resolved first?

@artfulrobot
Copy link
Owner

I'd be tempted to comment the code out with a note, rather than remove it, just in case issue #12 ever gets implemented. V happy for you to do that.

Without that membership-specific thing in place I'm not so bothered about having a separate test for non memberships, since the membership one is identical but plus membership. So the membership test would still fail if the normal case was failling. And if there is a difference in future we can split the tests up then? Over to you.

Many thanks, and great work @wmortada for grok'ing the code to realise that one API call was causing all the problems!

Expect to see failures (fixed in next commits)

Add tests for issue artfulrobot#27.
For a existing membership (both Current & Grace) where payment was not GC and renewal is GC,
the dates and status should not be changed by setting up the mandate.

Modify testWebhookPaymentConfirmationFirst() to be more specific about dates
Not sure whether this is the _desired_ behaviour re dates, but it documents
the _current_ behaviour which should help if we want to change.
Comment out unused code
Add note re Membership Dates
@aydun aydun force-pushed the membership_testing branch from dbbf41c to a881a2a Compare November 15, 2018 18:29
@aydun
Copy link
Contributor Author

aydun commented Nov 15, 2018

Ok, I've reinstated the original test so we explicitly test both membership and non-membership. I've squashed the commits back to 2 so I think this ready to merge.

@artfulrobot artfulrobot merged commit 144a95b into artfulrobot:master Nov 15, 2018
@artfulrobot artfulrobot modified the milestone: Launch Nov 15, 2018
@artfulrobot artfulrobot added this to the v1.6 stable milestone Nov 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants