From db92bcb906faa1456fdbaa5eb2e9fa085db944b3 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Mon, 26 Jul 2021 17:28:06 +1200 Subject: [PATCH] Additional opt ins & outs on validateFinancials Ideally we opt in the class & opt out specific tests as an interim. Moving towards opt in everything & opt out specific tests --- tests/phpunit/CRM/Event/Form/ParticipantTest.php | 1 - .../CRM/Event/Form/Registration/ConfirmTest.php | 15 +++++++++++++++ tests/phpunit/api/v3/ACLPermissionTest.php | 10 ++++++++++ tests/phpunit/api/v3/MembershipPaymentTest.php | 11 +++++++++++ tests/phpunit/api/v3/ProfileTest.php | 2 ++ 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/CRM/Event/Form/ParticipantTest.php b/tests/phpunit/CRM/Event/Form/ParticipantTest.php index c406b743f6..f18c59c7b0 100644 --- a/tests/phpunit/CRM/Event/Form/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/Form/ParticipantTest.php @@ -21,7 +21,6 @@ class CRM_Event_Form_ParticipantTest extends CiviUnitTestCase { parent::setUp(); } - /** * Should financials be checked after the test but before tear down. * diff --git a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php index fb444eb4ff..aeb12efa16 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php @@ -10,6 +10,17 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase { use CRMTraits_Profile_ProfileTrait; + + /** + * Should financials be checked after the test but before tear down. + * + * Ideally all tests (or at least all that call any financial api calls ) should do this but there + * are some test data issues and some real bugs currently blocking. + * + * @var bool + */ + protected $isValidateFinancialsOnPostAssert = TRUE; + public function setUp(): void { $this->useTransaction(TRUE); parent::setUp(); @@ -95,6 +106,8 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase { * @dataProvider getThousandSeparators */ public function testPaidSubmit($thousandSeparator) { + // @todo - figure out why this doesn't pass validate financials + $this->isValidateFinancialsOnPostAssert = FALSE; $this->setCurrencySeparators($thousandSeparator); $mut = new CiviMailUtils($this); $paymentProcessorID = $this->processorCreate(); @@ -222,6 +235,8 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase { * @throws \Exception */ public function testTaxMultipleParticipant() { + // @todo - figure out why this doesn't pass validate financials + $this->isValidateFinancialsOnPostAssert = FALSE; $mut = new CiviMailUtils($this); $params = ['is_monetary' => 1, 'financial_type_id' => 1]; $event = $this->eventCreate($params); diff --git a/tests/phpunit/api/v3/ACLPermissionTest.php b/tests/phpunit/api/v3/ACLPermissionTest.php index 67877a67b7..d386372805 100644 --- a/tests/phpunit/api/v3/ACLPermissionTest.php +++ b/tests/phpunit/api/v3/ACLPermissionTest.php @@ -25,6 +25,16 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { use Civi\Test\ACLPermissionTrait; + /** + * Should financials be checked after the test but before tear down. + * + * The setup methodology in this class bypasses valid financial creation + * so we don't check. + * + * @var bool + */ + protected $isValidateFinancialsOnPostAssert = FALSE; + public $DBResetRequired = FALSE; protected $_entity; diff --git a/tests/phpunit/api/v3/MembershipPaymentTest.php b/tests/phpunit/api/v3/MembershipPaymentTest.php index 72d6610c6d..e84085d55d 100644 --- a/tests/phpunit/api/v3/MembershipPaymentTest.php +++ b/tests/phpunit/api/v3/MembershipPaymentTest.php @@ -23,6 +23,17 @@ class api_v3_MembershipPaymentTest extends CiviUnitTestCase { protected $_membershipStatusID; protected $_contribution = []; + /** + * Should financials be checked after the test but before tear down. + * + * This test class is opted out as this method should not be called outside + * of the LineItem::create function and the test is artificial & not creating + * valid financials. + * + * @var bool + */ + protected $isValidateFinancialsOnPostAssert = FALSE; + public function setUp(): void { parent::setUp(); $this->useTransaction(TRUE); diff --git a/tests/phpunit/api/v3/ProfileTest.php b/tests/phpunit/api/v3/ProfileTest.php index b9ea3ad0e3..30817bcc40 100644 --- a/tests/phpunit/api/v3/ProfileTest.php +++ b/tests/phpunit/api/v3/ProfileTest.php @@ -542,6 +542,8 @@ class api_v3_ProfileTest extends CiviUnitTestCase { * @throws \CiviCRM_API3_Exception */ public function testProfileSubmitMembershipBatch(): void { + // @todo - figure out why this doesn't pass validate financials + $this->isValidateFinancialsOnPostAssert = FALSE; $this->_contactID = $this->individualCreate(); $this->callAPISuccess('profile', 'submit', [ 'profile_id' => 'membership_batch_entry', -- 2.25.1