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

Extend test to cover membership logs #19023

Merged
merged 1 commit into from
Dec 8, 2020
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
15 changes: 11 additions & 4 deletions tests/phpunit/api/v3/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3432,9 +3432,14 @@ public function testCompleteTransactionMembershipPriceSet() {
}

/**
* Test if renewal activity is create after changing Pending contribution to Completed via offline
* Test if renewal activity is create after changing Pending contribution to
* Completed via offline
*
* @throws \CRM_Core_Exception
* @throws \CRM_Core_Exception
* @throws \CiviCRM_API3_Exception
*/
public function testPendingToCompleteContribution() {
public function testPendingToCompleteContribution(): void {
$this->createPriceSetWithPage('membership');
$this->setUpPendingContribution($this->_ids['price_field_value'][0]);
$this->callAPISuccess('membership', 'getsingle', ['id' => $this->_ids['membership']]);
Expand Down Expand Up @@ -3505,7 +3510,9 @@ public function testPendingToCompleteContribution() {
]);
$this->assertEquals(1, $activity['count']);
$this->assertEquals('Status changed from Grace to Current', $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']));
//Create another pending contribution for renewal
$contribution = $this->callAPISuccess('contribution', 'create', [
'domain_id' => 1,
Expand Down Expand Up @@ -3556,7 +3563,7 @@ public function testPendingToCompleteContribution() {
$form->testSubmit($form->_params, CRM_Core_Action::UPDATE);
//Existing membership should not get updated to expired.
$membership = $this->callAPISuccess('membership', 'getsingle', ['id' => $this->_ids['membership']]);
$this->assertNotEquals($membership['status_id'], 4);
$this->assertNotEquals(4, $membership['status_id']);
}

/**
Expand Down