Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Add cover for setting num_terms to 2 #20939

Merged
merged 1 commit into from
Jul 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions tests/phpunit/CRM/Member/Form/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,13 +499,11 @@ public function testSubmit(string $thousandSeparator): void {
'cid' => $this->_individualId,
'contact_id' => $this->_individualId,
'join_date' => date('Y-m-d'),
'start_date' => '',
'end_date' => '',
// This format reflects the organisation & then the type.
'membership_type_id' => [$this->ids['contact']['organization'], $this->ids['membership_type']['AnnualFixed']],
'auto_renew' => '0',
'max_related' => '',
'num_terms' => '1',
'num_terms' => 2,
'source' => '',
'total_amount' => $this->formatMoneyInput(1234.56),
//Member dues, see data.xml
Expand All @@ -522,7 +520,7 @@ public function testSubmit(string $thousandSeparator): void {
],
'credit_card_type' => 'Visa',
'billing_first_name' => 'Test',
'billing_middlename' => 'Last',
'billing_last_name' => 'Last',
'billing_street_address-5' => '10 Test St',
'billing_city-5' => 'Test',
'billing_state_province_id-5' => '1003',
Expand All @@ -534,18 +532,18 @@ 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']);
$this->callAPISuccessGetCount('ContributionRecur', ['contact_id' => $this->_individualId], 0);
$contribution = $this->callAPISuccess('Contribution', 'get', [
'contact_id' => $this->_individualId,
'is_test' => TRUE,
]);

//CRM-20264 : Check that CC type and number (last 4 digit) is stored during backoffice membership payment
$lastFinancialTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a silly complicated way to get the trxn - use Payment.get

$financialTrxn = $this->callAPISuccessGetSingle(
'FinancialTrxn',
'Payment',
[
'id' => $lastFinancialTrxnId['financialTrxnId'],
'contribution_id' => $contribution['id'],
'return' => ['card_type_id', 'pan_truncation'],
]
);
Expand Down Expand Up @@ -574,7 +572,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') . '. A membership confirmation and receipt has been sent to [email protected].',
'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 [email protected].',
'title' => 'Complete',
'type' => 'success',
'options' => NULL,
Expand Down