From 3b016424a88363545c2598351d9801b397173fba Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Wed, 26 May 2021 08:23:08 +1200 Subject: [PATCH] Add financial validation check (to the extent we can) Let's get to opt out not opt in on this check --- tests/phpunit/CRM/Core/BAO/NavigationTest.php | 1 + .../CRM/Event/BAO/ChangeFeeSelectionTest.php | 2 ++ tests/phpunit/CRM/Member/Form/MembershipTest.php | 13 +++++++++++-- tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 +- tests/phpunit/api/v3/MembershipTest.php | 4 ++++ tests/phpunit/api/v3/ParticipantTest.php | 2 ++ 6 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/CRM/Core/BAO/NavigationTest.php b/tests/phpunit/CRM/Core/BAO/NavigationTest.php index 86eb651744..e6fa7505ab 100644 --- a/tests/phpunit/CRM/Core/BAO/NavigationTest.php +++ b/tests/phpunit/CRM/Core/BAO/NavigationTest.php @@ -325,6 +325,7 @@ class CRM_Core_BAO_NavigationTest extends CiviUnitTestCase { CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviMail', 'delete in CiviMail']; CRM_Core_BAO_ConfigSetting::disableComponent('CiviMail'); $this->assertFalse(CRM_Core_BAO_Navigation::checkPermission($menuItem)); + CRM_Core_BAO_ConfigSetting::enableComponent('CiviContribute'); } } diff --git a/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php b/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php index 66bdd315ab..61952e14b8 100644 --- a/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php +++ b/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php @@ -481,6 +481,8 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase { * @throws \CiviCRM_API3_Exception */ public function testCRM17151() { + // @todo figure out the financial validation issue - likely a real bug. + $this->isValidateFinancialsOnPostAssert = FALSE; $this->registerParticipantAndPay(); $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index 65fb3bd061..74b51c473b 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -582,12 +582,14 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { /** * Test the submit function of the membership form on membership type change. - * Check if the related contribuion is also updated if the minimum_fee didn't match + * Check if the related contribution is also updated if the minimum_fee didn't match * * @throws \CRM_Core_Exception * @throws \CiviCRM_API3_Exception */ public function testContributionUpdateOnMembershipTypeChange(): void { + // @todo figure out why financial validation fails with this test. + $this->isValidateFinancialsOnPostAssert = FALSE; // Step 1: Create a Membership via backoffice whose with 50.00 payment $form = $this->getForm(); $this->mut = new CiviMailUtils($this, TRUE); @@ -863,6 +865,8 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { * @throws \CiviCRM_API3_Exception */ public function testFinancialEntriesOnCancelledContribution(): void { + // @todo figure out why financial validation fails with this test. + $this->isValidateFinancialsOnPostAssert = FALSE; // Create two memberships for individual $this->_individualId, via a price set in the back end. $this->createTwoMembershipsViaPriceSetInBackEnd($this->_individualId); @@ -1121,6 +1125,8 @@ Expires: ', * @throws \CiviCRM_API3_Exception */ public function testTwoInheritedMembershipsViaPriceSetInBackend(): void { + // @todo figure out why financial validation fails with this test. + $this->isValidateFinancialsOnPostAssert = FALSE; // Create an organization and give it a "Member of" relationship to $this->_individualId. $orgID = $this->organizationCreate(); $relationship = $this->callAPISuccess('Relationship', 'create', [ @@ -1201,6 +1207,8 @@ Expires: ', * @throws \CiviCRM_API3_Exception */ public function testTwoMembershipsViaPriceSetInBackendWithDiscount(): void { + // @todo figure out how to fix to pass valid financials. + $this->isValidateFinancialsOnPostAssert = FALSE; // Register buildAmount hook to apply discount. $this->hookClass->setHook('civicrm_buildAmount', [$this, 'buildAmountMembershipDiscount']); $this->enableTaxAndInvoicing(); @@ -1372,7 +1380,8 @@ Expires: ', * @throws \CiviCRM_API3_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(); diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index dc3cbf1848..4a75d3d886 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -159,7 +159,7 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * * @var bool */ - protected $isValidateFinancialsOnPostAssert = FALSE; + protected $isValidateFinancialsOnPostAssert = TRUE; /** * Should location types be checked to ensure primary addresses are correctly assigned after each test. diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index 31f06d7c90..2cb2d31be3 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -154,6 +154,8 @@ class api_v3_MembershipTest extends CiviUnitTestCase { * @throws \CiviCRM_API3_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(); @@ -184,6 +186,8 @@ class api_v3_MembershipTest extends CiviUnitTestCase { * Test Multiple Membership Status for same contribution id. */ public function testMultipleMembershipsContribution(): void { + // Set up for this test creates invalid financialts. + $this->isValidateFinancialsOnPostAssert = FALSE; // Main contact $memStatus = CRM_Member_PseudoConstant::membershipStatus(); // Pending Membership Status diff --git a/tests/phpunit/api/v3/ParticipantTest.php b/tests/phpunit/api/v3/ParticipantTest.php index a868a32fa2..1e8a3604f0 100644 --- a/tests/phpunit/api/v3/ParticipantTest.php +++ b/tests/phpunit/api/v3/ParticipantTest.php @@ -807,6 +807,8 @@ class api_v3_ParticipantTest extends CiviUnitTestCase { * Test participant invoke post hook after status update. */ public function testPostHookForAdditionalParticipant() { + // @todo - figure out why validation tests don't pass + $this->isValidateFinancialsOnPostAssert = FALSE; $participantID = $this->participantCreate([ 'contact_id' => $this->_contactID, 'status_id' => 5, -- 2.25.1