Skip to content

Commit

Permalink
Merge pull request #17605 from eileenmcnaughton/membertest
Browse files Browse the repository at this point in the history
[NFC] Add assertions to existing test to lock in current behaviour
  • Loading branch information
seamuslee001 authored Jun 14, 2020
2 parents 03e3335 + 5ea9c2b commit 283a260
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public function setUp() {
$this->_membershipID = $this->callAPISuccess('Membership', 'create', [
'contact_id' => $this->_individualId,
'membership_type_id' => $this->membershipTypeAnnualFixedID,
'join_date' => '2020-04-13',
'source' => 'original_source',
])['id'];

$this->paymentInstruments = $this->callAPISuccess('Contribution', 'getoptions', ['field' => 'payment_instrument_id'])['values'];
Expand Down Expand Up @@ -378,6 +380,19 @@ public function testSubmitRecurCompleteInstant() {

$form->testSubmit($params);
$membership = $this->callAPISuccessGetSingle('Membership', ['contact_id' => $this->_individualId]);
$this->assertEquals('2020-04-13', $membership['join_date']);
$this->assertEquals(date('Y-01-01'), $membership['start_date']);
$nextYear = date('Y') + 1;
$this->assertEquals(date($nextYear . '-01-31'), $membership['end_date']);
$this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Member_BAO_Membership', 'status_id', 'New'), $membership['status_id']);
$this->assertNotEmpty($membership['contribution_recur_id']);
$this->assertNotEmpty('original_source', $membership['source']);

$log = $this->callAPISuccessGetSingle('MembershipLog', ['membership_id' => $membership['id'], 'options' => ['limit' => 1, 'sort' => 'id DESC']]);
$this->assertEquals(date($nextYear . '-01-01'), $log['start_date']);
$this->assertEquals(date($nextYear . '-01-31'), $log['end_date']);
$this->assertEquals(date('Y-m-d'), $log['modified_date']);

$contributionRecur = $this->callAPISuccessGetSingle('ContributionRecur', ['contact_id' => $this->_individualId]);
$this->assertEquals($contributionRecur['id'], $membership['contribution_recur_id']);
$this->assertEquals(0, $contributionRecur['is_email_receipt']);
Expand Down Expand Up @@ -479,7 +494,6 @@ public function testSubmitPayLater() {
'auto_renew' => '0',
'max_related' => '',
'num_terms' => '2',
'source' => '',
'total_amount' => '50.00',
//Member dues, see data.xml
'financial_type_id' => '2',
Expand Down Expand Up @@ -533,7 +547,6 @@ public function testSubmitPayLaterWithBilling() {
'auto_renew' => '0',
'max_related' => '',
'num_terms' => '2',
'source' => '',
'total_amount' => '50.00',
//Member dues, see data.xml
'financial_type_id' => '2',
Expand Down Expand Up @@ -597,7 +610,6 @@ public function testSubmitComplete() {
'auto_renew' => '0',
'max_related' => '',
'num_terms' => '2',
'source' => '',
'total_amount' => '50.00',
//Member dues, see data.xml
'financial_type_id' => '2',
Expand Down Expand Up @@ -674,7 +686,6 @@ protected function getBaseSubmitParams() {
'is_recur' => 1,
'max_related' => 0,
'num_terms' => '1',
'source' => '',
'total_amount' => $this->formatMoneyInput('7800.90'),
//Member dues, see data.xml
'financial_type_id' => '2',
Expand Down

0 comments on commit 283a260

Please sign in to comment.