Skip to content

Commit

Permalink
Merge pull request #22351 from demeritcowboy/membership-testfail
Browse files Browse the repository at this point in the history
Fix membership test fail for Dec 31
  • Loading branch information
totten authored Dec 31, 2021
2 parents 29cc02c + 11ec68f commit 631ea74
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tests/phpunit/CRM/Member/Form/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,13 @@ public function testSubmit(string $thousandSeparator): void {
$form->_contactID = $this->_individualId;
$form->testSubmit($params);
$membership = $this->callAPISuccessGetSingle('Membership', ['contact_id' => $this->_individualId]);
$this->assertEquals(date('Y') + 1 . '-12-31', $membership['end_date']);
$membershipEndYear = date('Y') + 1;
if (date('m-d') == '12-31') {
// If you join on Dec 31, then the first term would end right away, so
// add a year.
$membershipEndYear++;
}
$this->assertEquals($membershipEndYear . '-12-31', $membership['end_date']);
$this->callAPISuccessGetCount('ContributionRecur', ['contact_id' => $this->_individualId], 0);
$contribution = $this->callAPISuccess('Contribution', 'get', [
'contact_id' => $this->_individualId,
Expand Down Expand Up @@ -573,7 +579,7 @@ public function testSubmit(string $thousandSeparator): void {
$this->mut->stop();
$this->assertEquals([
[
'text' => 'AnnualFixed membership for Mr. Anthony Anderson II has been added. The new membership End Date is December 31st, ' . (date('Y') + 1) . '. A membership confirmation and receipt has been sent to anthony_anderson@civicrm.org.',
'text' => 'AnnualFixed membership for Mr. Anthony Anderson II has been added. The new membership End Date is December 31st, ' . $membershipEndYear . '. A membership confirmation and receipt has been sent to anthony_anderson@civicrm.org.',
'title' => 'Complete',
'type' => 'success',
'options' => NULL,
Expand Down

0 comments on commit 631ea74

Please sign in to comment.