Skip to content

Commit

Permalink
Merge pull request #9383 from jitendrapurohit/testfix
Browse files Browse the repository at this point in the history
Fix membership join_date test
  • Loading branch information
monishdeb authored Nov 14, 2016
2 parents fb8011b + 70a8770 commit 8f12417
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CRM/Member/BAO/MembershipType.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public static function getDatesForMembershipType($membershipTypeId, $joinDate =
* @param string $actualStartDate
* @return bool is this in the window where the membership gets an extra part-period added
*/
protected static function isDuringFixedAnnualRolloverPeriod($startDate, $membershipTypeDetails, $year, $actualStartDate) {
public static function isDuringFixedAnnualRolloverPeriod($startDate, $membershipTypeDetails, $year, $actualStartDate) {

$rolloverMonth = substr($membershipTypeDetails['fixed_period_rollover_day'], 0,
strlen($membershipTypeDetails['fixed_period_rollover_day']) - 2
Expand Down
17 changes: 14 additions & 3 deletions tests/phpunit/api/v3/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1150,14 +1150,25 @@ public function testMembershipJoinDateFixed() {
);
$result = $this->callAPISuccess('Membership', 'create', $memParams);

// Extend duration interval if join_date exceeds the rollover period.
$joinDate = date('Y-m-d');
$year = date('Y');
$startDate = date('Y-m-d', strtotime(date('Y-03-01')));
$membershipTypeDetails = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($this->_membershipTypeID2);
$fixedPeriodRollover = CRM_Member_BAO_MembershipType::isDuringFixedAnnualRolloverPeriod($joinDate, $membershipTypeDetails, $year, $startDate);
$y = 1;
if ($fixedPeriodRollover) {
$y += 1;
}

$expectedDates = array(
'join_date' => date('Ymd'),
'start_date' => date('Ymd', strtotime(date('Y-03-01'))),
'end_date' => date('Ymd', strtotime(date('Y-03-01') . '+ 1 year - 1 day')),
'start_date' => str_replace('-', '', $startDate),
'end_date' => date('Ymd', strtotime(date('Y-03-01') . "+ {$y} year - 1 day")),
);
foreach ($result['values'] as $values) {
foreach ($expectedDates as $date => $val) {
$this->assertEquals($val, $values[$date]);
$this->assertEquals($val, $values[$date], "Failed asserting {$date} values");
}
}
}
Expand Down

0 comments on commit 8f12417

Please sign in to comment.