From fda18dc31809d3a90ef1b1a8f4034acff87e6b25 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 15 Jun 2019 11:25:44 -0400 Subject: [PATCH] [test] Call parent tearDown more consistently Primarliy consistentcy - also supports checking nullArray is cleared per https://github.com/civicrm/civicrm-core/pull/14550 --- tests/phpunit/api/v3/AddressTest.php | 1 + tests/phpunit/api/v3/CRM11793Test.php | 1 + tests/phpunit/api/v3/ContributionPageTest.php | 4 ++++ tests/phpunit/api/v3/FinancialTypeACLTest.php | 3 +++ tests/phpunit/api/v3/GrantTest.php | 8 +++++++- tests/phpunit/api/v3/GroupNestingTest.php | 1 + tests/phpunit/api/v3/GroupTest.php | 3 +++ tests/phpunit/api/v3/JobTest.php | 1 + tests/phpunit/api/v3/MembershipStatusTest.php | 3 ++- tests/phpunit/api/v3/MembershipTest.php | 17 +++++------------ tests/phpunit/api/v3/PaymentTest.php | 3 +++ tests/phpunit/api/v3/PledgePaymentTest.php | 1 + tests/phpunit/api/v3/PriceFieldTest.php | 1 + tests/phpunit/api/v3/PriceSetTest.php | 3 --- tests/phpunit/api/v3/RelationshipTest.php | 1 + .../phpunit/api/v3/TaxContributionPageTest.php | 4 ++++ 16 files changed, 38 insertions(+), 17 deletions(-) diff --git a/tests/phpunit/api/v3/AddressTest.php b/tests/phpunit/api/v3/AddressTest.php index ec0b9e5601..c7f28d3132 100644 --- a/tests/phpunit/api/v3/AddressTest.php +++ b/tests/phpunit/api/v3/AddressTest.php @@ -68,6 +68,7 @@ class api_v3_AddressTest extends CiviUnitTestCase { $this->locationTypeDelete($this->_locationType->id); $this->contactDelete($this->_contactID); $this->quickCleanup(array('civicrm_address', 'civicrm_relationship')); + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/CRM11793Test.php b/tests/phpunit/api/v3/CRM11793Test.php index 61484322fe..b42cfc0f4e 100644 --- a/tests/phpunit/api/v3/CRM11793Test.php +++ b/tests/phpunit/api/v3/CRM11793Test.php @@ -27,6 +27,7 @@ class api_v3_CRM11793Test extends CiviUnitTestCase { } public function tearDown() { + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index 7329a193e8..95fc147494 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -87,6 +87,7 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { $this->callAPISuccess('contact', 'delete', array('id' => $id)); } $this->quickCleanUpFinancialEntities(); + parent::tearDown(); } /** @@ -1641,6 +1642,9 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase { // put stuff here that should happen before all tests in this unit } + /** + * @throws \Exception + */ public static function tearDownAfterClass() { $tablesToTruncate = array( 'civicrm_contact', diff --git a/tests/phpunit/api/v3/FinancialTypeACLTest.php b/tests/phpunit/api/v3/FinancialTypeACLTest.php index 5c25bf0f77..7c288f7b74 100644 --- a/tests/phpunit/api/v3/FinancialTypeACLTest.php +++ b/tests/phpunit/api/v3/FinancialTypeACLTest.php @@ -104,11 +104,14 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase { /** * Clean up after each test. + * + * @throws \Exception */ public function tearDown() { $this->quickCleanUpFinancialEntities(); $this->quickCleanup(array('civicrm_uf_match')); $this->disableFinancialACLs(); + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/GrantTest.php b/tests/phpunit/api/v3/GrantTest.php index a8d60af723..9de285880b 100644 --- a/tests/phpunit/api/v3/GrantTest.php +++ b/tests/phpunit/api/v3/GrantTest.php @@ -55,13 +55,19 @@ class api_v3_GrantTest extends CiviUnitTestCase { ); } + /** + * Cleanup after test. + * + * @throws \Exception + */ public function tearDown() { foreach ($this->ids as $entity => $entities) { foreach ($entities as $id) { $this->callAPISuccess($entity, 'delete', array('id' => $id)); } } - $this->quickCleanup(array('civicrm_grant')); + $this->quickCleanup(['civicrm_grant']); + parent::tearDown(); } public function testCreateGrant() { diff --git a/tests/phpunit/api/v3/GroupNestingTest.php b/tests/phpunit/api/v3/GroupNestingTest.php index 5b00f45629..dba8e57793 100644 --- a/tests/phpunit/api/v3/GroupNestingTest.php +++ b/tests/phpunit/api/v3/GroupNestingTest.php @@ -82,6 +82,7 @@ class api_v3_GroupNestingTest extends CiviUnitTestCase { 'civicrm_uf_match', ] ); + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/GroupTest.php b/tests/phpunit/api/v3/GroupTest.php index ee0b5f921b..3d077515a1 100644 --- a/tests/phpunit/api/v3/GroupTest.php +++ b/tests/phpunit/api/v3/GroupTest.php @@ -46,12 +46,15 @@ class api_v3_GroupTest extends CiviUnitTestCase { /** * Clean up after test. + * + * @throws \Exception */ public function tearDown() { CRM_Utils_Hook::singleton()->reset(); $config = CRM_Core_Config::singleton(); unset($config->userPermissionClass->permissions); $this->quickCleanup(['civicrm_group', 'civicrm_group_contact']); + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/JobTest.php b/tests/phpunit/api/v3/JobTest.php index 8e3f32b5e9..e3602fe523 100644 --- a/tests/phpunit/api/v3/JobTest.php +++ b/tests/phpunit/api/v3/JobTest.php @@ -78,6 +78,7 @@ class api_v3_JobTest extends CiviUnitTestCase { $this->membershipTypeDelete(array('id' => $this->membershipTypeID)); $this->cleanUpSetUpIDs(); $this->quickCleanup(['civicrm_contact', 'civicrm_address', 'civicrm_email', 'civicrm_website', 'civicrm_phone'], TRUE); + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/MembershipStatusTest.php b/tests/phpunit/api/v3/MembershipStatusTest.php index 7fd9f6714d..e9f205326d 100644 --- a/tests/phpunit/api/v3/MembershipStatusTest.php +++ b/tests/phpunit/api/v3/MembershipStatusTest.php @@ -50,8 +50,9 @@ class api_v3_MembershipStatusTest extends CiviUnitTestCase { public function tearDown() { $this->membershipStatusDelete($this->_membershipStatusID); - $this->membershipTypeDelete(array('id' => $this->_membershipTypeID)); + $this->membershipTypeDelete(['id' => $this->_membershipTypeID]); $this->contactDelete($this->_contactID); + parent::tearDown(); } ///////////////// civicrm_membership_status_get methods diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index 1cfd52ad02..5d01315c00 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -89,19 +89,10 @@ class api_v3_MembershipTest extends CiviUnitTestCase { * @throws \Exception */ public function tearDown() { - $this->quickCleanup(array( - 'civicrm_membership', - 'civicrm_membership_payment', - 'civicrm_membership_log', - 'civicrm_uf_match', - ), - TRUE - ); - $this->membershipStatusDelete($this->_membershipStatusID); - $this->membershipTypeDelete(array('id' => $this->_membershipTypeID2)); - $this->membershipTypeDelete(array('id' => $this->_membershipTypeID)); + $this->quickCleanUpFinancialEntities(); + $this->quickCleanup(['civicrm_uf_match'], TRUE); $this->contactDelete($this->_contactID); - + parent::tearDown(); } /** @@ -457,6 +448,8 @@ class api_v3_MembershipTest extends CiviUnitTestCase { /** * Test civicrm_membership_get with relationship. * get Memberships. + * + * @throws \CRM_Core_Exception */ public function testGetWithRelationship() { $membershipOrgId = $this->organizationCreate(NULL); diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 5b3104cbe3..a0b0c5154a 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -55,11 +55,14 @@ class api_v3_PaymentTest extends CiviUnitTestCase { /** * Clean up after each test. + * + * @throws \Exception */ public function tearDown() { $this->quickCleanUpFinancialEntities(); $this->quickCleanup(['civicrm_uf_match']); unset(CRM_Core_Config::singleton()->userPermissionClass->permissions); + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/PledgePaymentTest.php b/tests/phpunit/api/v3/PledgePaymentTest.php index fbf0f7b2ce..0a7f7d03d2 100644 --- a/tests/phpunit/api/v3/PledgePaymentTest.php +++ b/tests/phpunit/api/v3/PledgePaymentTest.php @@ -58,6 +58,7 @@ class api_v3_PledgePaymentTest extends CiviUnitTestCase { ); $this->quickCleanup($tablesToTruncate); + parent::tearDown(); } public function testGetPledgePayment() { diff --git a/tests/phpunit/api/v3/PriceFieldTest.php b/tests/phpunit/api/v3/PriceFieldTest.php index 8dd4a2db80..5f2d5d89cc 100644 --- a/tests/phpunit/api/v3/PriceFieldTest.php +++ b/tests/phpunit/api/v3/PriceFieldTest.php @@ -79,6 +79,7 @@ class api_v3_PriceFieldTest extends CiviUnitTestCase { )); $this->assertAPISuccess($delete); + parent::tearDown(); } public function testCreatePriceField() { diff --git a/tests/phpunit/api/v3/PriceSetTest.php b/tests/phpunit/api/v3/PriceSetTest.php index 5a8b728c9b..81a54f6dc6 100644 --- a/tests/phpunit/api/v3/PriceSetTest.php +++ b/tests/phpunit/api/v3/PriceSetTest.php @@ -56,9 +56,6 @@ class api_v3_PriceSetTest extends CiviUnitTestCase { ); } - public function tearDown() { - } - /** * Test create price set. */ diff --git a/tests/phpunit/api/v3/RelationshipTest.php b/tests/phpunit/api/v3/RelationshipTest.php index 5efa9756ca..e037d32465 100644 --- a/tests/phpunit/api/v3/RelationshipTest.php +++ b/tests/phpunit/api/v3/RelationshipTest.php @@ -102,6 +102,7 @@ class api_v3_RelationshipTest extends CiviUnitTestCase { $this->contactDelete($this->_cId_b2); $this->quickCleanup(array('civicrm_relationship'), TRUE); $this->relationshipTypeDelete($this->_relTypeID); + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/TaxContributionPageTest.php b/tests/phpunit/api/v3/TaxContributionPageTest.php index 7ceef97bd6..80798a2f18 100644 --- a/tests/phpunit/api/v3/TaxContributionPageTest.php +++ b/tests/phpunit/api/v3/TaxContributionPageTest.php @@ -166,8 +166,12 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase { $this->assertAPISuccess($result); } + /** + * Cleanup after function. + */ public function tearDown() { $this->quickCleanUpFinancialEntities(); + parent::tearDown(); } public function setUpContributionPage() { -- 2.25.1