From 5bcbbc34bda1f9b024265cb7d4507e0a5f96a066 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 | 5 +++++ 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, 39 insertions(+), 17 deletions(-) diff --git a/tests/phpunit/api/v3/AddressTest.php b/tests/phpunit/api/v3/AddressTest.php index ec0b9e5601de..c7f28d313205 100644 --- a/tests/phpunit/api/v3/AddressTest.php +++ b/tests/phpunit/api/v3/AddressTest.php @@ -68,6 +68,7 @@ public function tearDown() { $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 61484322fe3f..b42cfc0f4e14 100644 --- a/tests/phpunit/api/v3/CRM11793Test.php +++ b/tests/phpunit/api/v3/CRM11793Test.php @@ -27,6 +27,7 @@ public function setUp() { } public function tearDown() { + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index 7329a193e806..637d9558bf77 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -87,6 +87,7 @@ public function tearDown() { $this->callAPISuccess('contact', 'delete', array('id' => $id)); } $this->quickCleanUpFinancialEntities(); + parent::tearDown(); } /** @@ -1641,6 +1642,9 @@ public static function setUpBeforeClass() { // put stuff here that should happen before all tests in this unit } + /** + * @throws \Exception + */ public static function tearDownAfterClass() { $tablesToTruncate = array( 'civicrm_contact', @@ -1650,6 +1654,7 @@ public static function tearDownAfterClass() { ); $unitTest = new CiviUnitTestCase(); $unitTest->quickCleanup($tablesToTruncate); + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/FinancialTypeACLTest.php b/tests/phpunit/api/v3/FinancialTypeACLTest.php index 5c25bf0f77b0..7c288f7b7467 100644 --- a/tests/phpunit/api/v3/FinancialTypeACLTest.php +++ b/tests/phpunit/api/v3/FinancialTypeACLTest.php @@ -104,11 +104,14 @@ public function setUp() { /** * 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 a8d60af72317..9de285880be9 100644 --- a/tests/phpunit/api/v3/GrantTest.php +++ b/tests/phpunit/api/v3/GrantTest.php @@ -55,13 +55,19 @@ public function setUp() { ); } + /** + * 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 5b00f456290c..dba8e5779374 100644 --- a/tests/phpunit/api/v3/GroupNestingTest.php +++ b/tests/phpunit/api/v3/GroupNestingTest.php @@ -82,6 +82,7 @@ protected function tearDown() { 'civicrm_uf_match', ] ); + parent::tearDown(); } /** diff --git a/tests/phpunit/api/v3/GroupTest.php b/tests/phpunit/api/v3/GroupTest.php index ee0b5f921b63..3d077515a1ce 100644 --- a/tests/phpunit/api/v3/GroupTest.php +++ b/tests/phpunit/api/v3/GroupTest.php @@ -46,12 +46,15 @@ public function setUp() { /** * 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 8e3f32b5e9e8..e3602fe523de 100644 --- a/tests/phpunit/api/v3/JobTest.php +++ b/tests/phpunit/api/v3/JobTest.php @@ -78,6 +78,7 @@ public function tearDown() { $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 7fd9f6714d73..e9f205326d97 100644 --- a/tests/phpunit/api/v3/MembershipStatusTest.php +++ b/tests/phpunit/api/v3/MembershipStatusTest.php @@ -50,8 +50,9 @@ public function setUp() { 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 1cfd52ad0294..5d01315c00d3 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -89,19 +89,10 @@ public function setUp() { * @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 @@ public function testGetNoContactExists() { /** * 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 5b3104cbe34f..a0b0c5154aca 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -55,11 +55,14 @@ public function setUp() { /** * 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 fbf0f7b2cec9..0a7f7d03d225 100644 --- a/tests/phpunit/api/v3/PledgePaymentTest.php +++ b/tests/phpunit/api/v3/PledgePaymentTest.php @@ -58,6 +58,7 @@ public function tearDown() { ); $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 8dd4a2db80ae..5f2d5d89cc8f 100644 --- a/tests/phpunit/api/v3/PriceFieldTest.php +++ b/tests/phpunit/api/v3/PriceFieldTest.php @@ -79,6 +79,7 @@ public function tearDown() { )); $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 5a8b728c9ba5..81a54f6dc647 100644 --- a/tests/phpunit/api/v3/PriceSetTest.php +++ b/tests/phpunit/api/v3/PriceSetTest.php @@ -56,9 +56,6 @@ public function setUp() { ); } - public function tearDown() { - } - /** * Test create price set. */ diff --git a/tests/phpunit/api/v3/RelationshipTest.php b/tests/phpunit/api/v3/RelationshipTest.php index 5efa9756cae2..e037d32465ab 100644 --- a/tests/phpunit/api/v3/RelationshipTest.php +++ b/tests/phpunit/api/v3/RelationshipTest.php @@ -102,6 +102,7 @@ public function tearDown() { $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 7ceef97bd627..80798a2f1897 100644 --- a/tests/phpunit/api/v3/TaxContributionPageTest.php +++ b/tests/phpunit/api/v3/TaxContributionPageTest.php @@ -166,8 +166,12 @@ public function setUp() { $this->assertAPISuccess($result); } + /** + * Cleanup after function. + */ public function tearDown() { $this->quickCleanUpFinancialEntities(); + parent::tearDown(); } public function setUpContributionPage() {