Skip to content

Commit

Permalink
Merge pull request #19023 from eileenmcnaughton/tt
Browse files Browse the repository at this point in the history
Extend test to cover membership logs
  • Loading branch information
colemanw authored Dec 8, 2020
2 parents 9b67a62 + c1a187e commit 9dc7c39
Showing 1 changed file with 11 additions and 4 deletions.
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

0 comments on commit 9dc7c39

Please sign in to comment.