Skip to content
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

Fix membership test fail for Dec 31 #22351

Merged
merged 1 commit into from
Dec 31, 2021

Conversation

demeritcowboy
Copy link
Contributor

Overview

Tests are failing on Dec 31

Before

    CRM_Member_Form_MembershipTest.testSubmit with data set #0
    CRM_Member_Form_MembershipTest.testSubmit with data set #1

Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'2022-12-31'
+'2023-12-31'

After

Technical Details

I'm not sure what the real-life expectation is. Here it's for 2 terms, but let's say it's 1 term. If I join a fixed membership on Dec 31 that ends on Dec 31, does it end immediately, or should I expect a full year? What about Dec 30 - do I only get 1 day?

Comments

@civibot
Copy link

civibot bot commented Dec 31, 2021

(Standard links)

@civibot civibot bot added the master label Dec 31, 2021
@totten
Copy link
Member

totten commented Dec 31, 2021

I did an equivalent patch locally - so I basically agree with this. :)

I'm not sure what the real-life expectation is. Here it's for 2 terms, but let's say it's 1 term. If I join a fixed membership on Dec 31 that ends on Dec 31, does it end immediately, or should I expect a full year? What about Dec 30 - do I only get 1 day?

Right, any fixed-period policy (if strictly enforced) will have some yucky days (like 12/31) where paying gives the subscriber a terrible deal (eg 1 day of membership).

If you look at the membership type used for this unit-test (AnnualFixed), it declares:

      'fixed_period_start_day' => '101',
      'fixed_period_rollover_day' => '1231',

The key thing here appears to be the fixed_period_rollover_day.

Based on some r-run with different current-dates and different rollover-days, fixed_period_rollover_day defines a sort of hidden grace-period. So if you sign-up on 12/31 for 2 years of membership, you will get 1 day + 2 years (~729 days) of membership rather than 1 day + 1 year (~365 days).

@totten totten merged commit 631ea74 into civicrm:master Dec 31, 2021
@demeritcowboy
Copy link
Contributor Author

Thanks @totten

@demeritcowboy demeritcowboy deleted the membership-testfail branch January 1, 2022 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants