From 6a519279ce8040e687ac9d6ef56a9e7908259f99 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 22 Aug 2022 11:45:34 +1000 Subject: [PATCH] [REF]dev/core#2517 Remove tests from core test suites relating to membership cancellation process and update extension unit tests to cover for gaps in testing --- .../tests/phpunit/CancelTest.php | 8 ++++ .../CRM/Member/Form/MembershipTest.php | 32 ---------------- tests/phpunit/api/v3/MembershipTest.php | 38 ------------------- 3 files changed, 8 insertions(+), 70 deletions(-) diff --git a/ext/contributioncancelactions/tests/phpunit/CancelTest.php b/ext/contributioncancelactions/tests/phpunit/CancelTest.php index 30ed165d18..c1ca5f4df3 100644 --- a/ext/contributioncancelactions/tests/phpunit/CancelTest.php +++ b/ext/contributioncancelactions/tests/phpunit/CancelTest.php @@ -285,6 +285,14 @@ class CancelTest extends TestCase implements HeadlessInterface, HookInterface, T $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') diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index a9fe4f84a5..57ca755d7e 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -1419,38 +1419,6 @@ Expires: ', $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. * diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index 3c13d13eca..c8386b5789 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -147,44 +147,6 @@ class api_v3_MembershipTest extends CiviUnitTestCase { $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. */ -- 2.25.1