Skip to content

Commit

Permalink
Merge pull request civicrm#24342 from seamuslee001/membership_cancel_…
Browse files Browse the repository at this point in the history
…tests_migrate

[REF]dev/core#2517 Remove tests from core test suites relating to mem…
  • Loading branch information
eileenmcnaughton authored Aug 22, 2022
2 parents e20ffe3 + 6a51927 commit 9b9c0c4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 70 deletions.
8 changes: 8 additions & 0 deletions ext/contributioncancelactions/tests/phpunit/CancelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,14 @@ public function testCancelFromContributionForm(): void {
$this->assertEquals('Cancelled', $contribution['contribution_status_id:name']);
$membership = $this->callAPISuccessGetSingle('Membership', []);
$this->assertEquals('Cancelled', CRM_Core_PseudoConstant::getName('CRM_Member_BAO_Membership', 'status_id', $membership['status_id']));
$this->assertEquals(TRUE, $membership['is_override']);
$membershipSignupActivity = Activity::get()
->addSelect('subject', 'source_record_id', 'status_id')
->addWhere('activity_type_id:name', '=', 'Membership Signup')
->execute();
$this->assertCount(1, $membershipSignupActivity);
$this->assertEquals($membership['id'], $membershipSignupActivity->first()['source_record_id']);
$this->assertEquals('General - Payment - Status: Pending', $membershipSignupActivity->first()['subject']);
$activity = Activity::get()
->addSelect('subject', 'source_record_id', 'status_id')
->addWhere('activity_type_id:name', '=', 'Change Membership Status')
Expand Down
32 changes: 0 additions & 32 deletions tests/phpunit/CRM/Member/Form/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1419,38 +1419,6 @@ protected function createTwoMembershipsViaPriceSetInBackEnd(int $contactId, $isT
$form->testSubmit($params);
}

/**
* Test membership status overrides when contribution is cancelled.
*
* @throws \CRM_Core_Exception
*/
public function testContributionFormStatusUpdate(): void {
// @todo figure out why financial validation fails with this test.
$this->isValidateFinancialsOnPostAssert = FALSE;
$this->_contactID = $this->ids['Contact']['order'] = $this->createLoggedInUser();
$this->createContributionAndMembershipOrder();

$params = [
'total_amount' => 50,
'financial_type_id' => 2,
'contact_id' => $this->_contactID,
'payment_instrument_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Check'),
'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Cancelled'),
];
$_REQUEST['action'] = 'update';
$_REQUEST['id'] = $this->ids['Contribution'][0];
$form = $this->getContributionForm($params);
$form->postProcess();
$membership = $this->callAPISuccessGetSingle('Membership', ['contact_id' => $this->_contactID]);

//Assert membership status overrides when the contribution cancelled.
$this->assertEquals(TRUE, $membership['is_override']);
$this->assertEquals($membership['status_id'], $this->callAPISuccessGetValue('MembershipStatus', [
'return' => 'id',
'name' => 'Cancelled',
]));
}

/**
* Get the contribution form object.
*
Expand Down
38 changes: 0 additions & 38 deletions tests/phpunit/api/v3/MembershipTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,44 +147,6 @@ public function testMembershipDeletePreserveContribution() {
$this->assertDBRowNotExist('CRM_Contribute_DAO_Contribution', $ContributionCreate['values'][0]['id']);
}

/**
* Test Activity creation on cancellation of membership contribution.
*
* @throws \CRM_Core_Exception
*/
public function testActivityForCancelledContribution(): void {
// @todo figure out why financial validation fails with this test.
$this->isValidateFinancialsOnPostAssert = FALSE;
$contactId = $this->ids['Contact']['order'] = $this->createLoggedInUser();

$this->createContributionAndMembershipOrder();
$membershipID = $this->callAPISuccessGetValue('MembershipPayment', ['return' => 'id']);

$_REQUEST['id'] = $this->ids['Contribution'][0];
$_REQUEST['action'] = 'update';
// change pending contribution to completed
/* @var CRM_Contribute_Form_Contribution $form */
$form = $this->getFormObject('CRM_Contribute_Form_Contribution', [
'total_amount' => 100,
'financial_type_id' => 1,
'contact_id' => $contactId,
'payment_instrument_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', 'Check'),
'contribution_status_id' => 3,
]);
$form->buildForm();
$form->postProcess();

$this->callAPISuccessGetSingle('Activity', [
'activity_type_id' => 'Membership Signup',
'source_record_id' => $membershipID,
'subject' => 'General - Payment - Status: Pending',
]);
$this->callAPISuccessGetSingle('Activity', [
'activity_type_id' => 'Change Membership Status',
'source_record_id' => $membershipID,
]);
}

/**
* Test Multiple Membership Status for same contribution id.
*/
Expand Down

0 comments on commit 9b9c0c4

Please sign in to comment.