Skip to content

Commit

Permalink
Re-fix test
Browse files Browse the repository at this point in the history
The strtotime calculation adds 4 months before setting the day of month. However

July 31 + 4 months is 1 Dec - ie the month is 12 not 11 due to there being only 30 days. So to
get 27 Nov we need to get the July month (7) and add 4 and voila 11, not 12
  • Loading branch information
eileenmcnaughton committed Jul 31, 2020
1 parent 640866c commit 2a610e3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,14 @@ public function testAutoRenewalWhenOneMemberIsDeceased() {
$this->validateAllCounts($membershipId1, 4);
$this->validateAllCounts($membershipId2, 4);

$expectedMonth = date('m') + 4;
// check membership end date.
foreach ([$membershipId1, $membershipId2] as $mId) {
$endDate = $this->callAPISuccessGetValue('Membership', [
'id' => $mId,
'return' => 'end_date',
]);
$this->assertEquals(date('Y-m', strtotime('+4 months')) . '-27', $endDate, ts('End date incorrect.'));
$this->assertEquals(date('Y-' . $expectedMonth . '-27'), $endDate, ts('End date incorrect.'));
}

// At this moment Contact 2 is deceased, but we wait until payment is recorded in civi before marking the contact deceased.
Expand Down

0 comments on commit 2a610e3

Please sign in to comment.