From: Eileen McNaughton Date: Tue, 24 Aug 2021 04:57:43 +0000 (+1200) Subject: Merge pull request #21231 from civicrm/5.41 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=475a25f9d804730311e1420a92d18ac3aac5ce2d;p=civicrm-core.git Merge pull request #21231 from civicrm/5.41 5.41 --- 475a25f9d804730311e1420a92d18ac3aac5ce2d diff --cc tests/phpunit/api/v3/ContributionTest.php index 35282cf789,29e34da7f6..e66742f4df --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@@ -3528,16 -3536,71 +3528,31 @@@ class api_v3_ContributionTest extends C 'status_id' => 'Completed', ]); $this->assertEquals(1, $activity['count']); - $this->assertEquals('Status changed from Grace to Current', $activity['values'][$activity['id']]['subject']); + $this->assertEquals('Status changed from Pending to New', $activity['values'][$activity['id']]['subject']); $membershipLogs = $this->callAPISuccess('MembershipLog', 'get', ['sequential' => 1])['values']; - $this->assertEquals('Grace', CRM_Core_PseudoConstant::getName('CRM_Member_BAO_Membership', 'status_id', $membershipLogs[0]['status_id'])); - $this->assertEquals('Current', CRM_Core_PseudoConstant::getName('CRM_Member_BAO_Membership', 'status_id', $membershipLogs[1]['status_id'])); + $this->assertEquals('Pending', CRM_Core_PseudoConstant::getName('CRM_Member_BAO_Membership', 'status_id', $membershipLogs[0]['status_id'])); + $this->assertEquals('New', CRM_Core_PseudoConstant::getName('CRM_Member_BAO_Membership', 'status_id', $membershipLogs[1]['status_id'])); //Create another pending contribution for renewal - $contribution = $this->callAPISuccess('contribution', 'create', [ - 'domain_id' => 1, - 'contact_id' => $this->_ids['contact'], - 'receive_date' => date('Ymd'), - 'total_amount' => 20.00, - 'financial_type_id' => 1, - 'payment_instrument_id' => 'Credit Card', - 'non_deductible_amount' => 10.00, - 'trxn_id' => 'rdhfi88', - 'invoice_id' => 'dofhiewuyr', - 'source' => 'SSF', - 'contribution_status_id' => 2, - 'contribution_page_id' => $this->_ids['contribution_page'], - // We can't rely on contribution api to link line items correctly to membership - 'skipLineItem' => TRUE, - 'api.membership_payment.create' => ['membership_id' => $this->_ids['membership']], - ]); - - $this->callAPISuccess('line_item', 'create', [ - 'entity_id' => $contribution['id'], - 'entity_table' => 'civicrm_contribution', - 'contribution_id' => $contribution['id'], - 'price_field_id' => $this->_ids['price_field'][0], - 'qty' => 1, - 'unit_price' => 20, - 'line_total' => 20, - 'financial_type_id' => 1, - 'price_field_value_id' => $this->_ids['price_field_value']['cont'], - ]); - $this->callAPISuccess('line_item', 'create', [ - 'entity_id' => $this->_ids['membership'], - 'entity_table' => 'civicrm_membership', - 'contribution_id' => $contribution['id'], - 'price_field_id' => $this->_ids['price_field'][0], - 'qty' => 1, - 'unit_price' => 20, - 'line_total' => 20, - 'financial_type_id' => 1, - 'price_field_value_id' => $this->_ids['price_field_value'][0], - 'membership_type_id' => $this->_ids['membership_type'], - ]); + $this->setUpPendingContribution($this->_ids['price_field_value'][0], 'second', [], ['entity_id' => $this->getMembershipID()], ['id' => $this->getMembershipID()]); //Update it to Failed. - $form->_params['id'] = $contribution['id']; + $form->_params['id'] = $this->getContributionID('second'); $form->_params['contribution_status_id'] = 4; + // We now have 2 line items of $20 each. + // form params['total_amount'] is set to $20 but + // now that we have 2 line items of $20 it should be $40 + // this is an artificial test scenario. + // but we need to ensure it is valid enough to + // pass validation checks. Note the way these lines are created + // above is wrong wrong wrong - but the rc is not the place to fix. + // Also note that this test has historically created incorrect + // financial data. The financials check was enabled on it + // AFTER the code we are honing was merged. + // so it used to tolerate incorrect financials, then it started + // re-calculating them (correctly in this artificial scenario - but not for tax scenarios) + // but as of 5.41 it is 'accepting' the total_amount + // so we should pass in a correct one. + $form->_params['total_amount'] = 40; $form->testSubmit($form->_params, CRM_Core_Action::UPDATE); //Existing membership should not get updated to expired.