Re-fix test
authoreileen <emcnaughton@wikimedia.org>
Fri, 31 Jul 2020 04:27:55 +0000 (16:27 +1200)
committerSeamus Lee <seamuslee001@gmail.com>
Mon, 3 Aug 2020 23:50:26 +0000 (09:50 +1000)
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

tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php

index 9d33072b48e75dc7dc52c7078e63bd90e839f303..4e018349cfab2d6a0fb1839a73dd599c935db816 100644 (file)
@@ -372,13 +372,14 @@ class CRM_Contribute_BAO_ContributionRecurTest extends CiviUnitTestCase {
     $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.