From: eileen Date: Thu, 25 Mar 2021 02:03:58 +0000 (+1300) Subject: More phpunit8 prep X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=cacd9d67bc23bcfef16c668ca34114017968ad4b;p=civicrm-core.git More phpunit8 prep --- diff --git a/ext/afform/mock/tests/phpunit/api/v4/AfformTestCase.php b/ext/afform/mock/tests/phpunit/api/v4/AfformTestCase.php index 4847abf604..a2dcb6af55 100644 --- a/ext/afform/mock/tests/phpunit/api/v4/AfformTestCase.php +++ b/ext/afform/mock/tests/phpunit/api/v4/AfformTestCase.php @@ -22,18 +22,10 @@ abstract class api_v4_AfformTestCase extends \PHPUnit\Framework\TestCase impleme /** * The setup() method is executed before the test is executed (optional). */ - public function setUp() { + public function setUp(): void { parent::setUp(); CRM_Core_Config::singleton()->userPermissionTemp = new CRM_Core_Permission_Temp(); CRM_Core_Config::singleton()->userPermissionTemp->grant('administer CiviCRM'); } - /** - * The tearDown() method is executed after the test was executed (optional) - * This can be used for cleanup. - */ - public function tearDown() { - parent::tearDown(); - } - } diff --git a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php index 80a030be6a..910a6d300f 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php @@ -26,7 +26,7 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase { /** * Set up function. */ - public function setUp() { + public function setUp(): void { parent::setUp(); $this->_paymentProcessorID = $this->paymentProcessorCreate(['is_test' => 0, 'payment_processor_type_id' => 'PayPal_Standard']); $this->_contactID = $this->individualCreate(); @@ -42,7 +42,7 @@ class CRM_Core_Payment_PayPalIPNTest extends CiviUnitTestCase { /** * Tear down function. */ - public function tearDown() { + public function tearDown(): void { $this->quickCleanUpFinancialEntities(); parent::tearDown(); } diff --git a/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php b/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php index 1d67e841c4..f70b6f9588 100644 --- a/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php +++ b/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php @@ -17,21 +17,6 @@ */ class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase { - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() { - parent::setUp(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() { - } - /** * create() and deleteParticipantStatusType() method */ diff --git a/tests/phpunit/CRM/Utils/versionCheckTest.php b/tests/phpunit/CRM/Utils/versionCheckTest.php index b8cdb51bf1..09292b514b 100644 --- a/tests/phpunit/CRM/Utils/versionCheckTest.php +++ b/tests/phpunit/CRM/Utils/versionCheckTest.php @@ -8,10 +8,6 @@ use Civi\Test\Invasive; */ class CRM_Utils_versionCheckTest extends CiviUnitTestCase { - public function setUp() { - parent::setUp(); - } - /** * @var array */ @@ -91,7 +87,7 @@ class CRM_Utils_versionCheckTest extends CiviUnitTestCase { ], ]; - public function tearDown() { + public function tearDown(): void { parent::tearDown(); $vc = new CRM_Utils_VersionCheck(); if (file_exists($vc->cacheFile)) { diff --git a/tests/phpunit/Civi/Core/CiviFacadeTest.php b/tests/phpunit/Civi/Core/CiviFacadeTest.php index 76dbc4bdbe..1fcae645d3 100644 --- a/tests/phpunit/Civi/Core/CiviFacadeTest.php +++ b/tests/phpunit/Civi/Core/CiviFacadeTest.php @@ -14,7 +14,7 @@ class CiviFacadeTest extends \CiviUnitTestCase { $this->mandates = []; } - public function tearDown() { + public function tearDown(): void { $GLOBALS['civicrm_setting'] = $this->origSetting; parent::tearDown(); } diff --git a/tests/phpunit/Civi/Core/Event/GenericHookEventTest.php b/tests/phpunit/Civi/Core/Event/GenericHookEventTest.php index 34bc465104..3ae516c552 100644 --- a/tests/phpunit/Civi/Core/Event/GenericHookEventTest.php +++ b/tests/phpunit/Civi/Core/Event/GenericHookEventTest.php @@ -3,7 +3,7 @@ namespace Civi\Core\Event; class GenericHookEventTest extends \CiviUnitTestCase { - public function tearDown() { + public function tearDown(): void { \CRM_Utils_Hook::singleton()->reset(); parent::tearDown(); } diff --git a/tests/phpunit/Civi/Core/SettingsBagTest.php b/tests/phpunit/Civi/Core/SettingsBagTest.php index 6271337b29..e68ac6f29e 100644 --- a/tests/phpunit/Civi/Core/SettingsBagTest.php +++ b/tests/phpunit/Civi/Core/SettingsBagTest.php @@ -14,7 +14,7 @@ class SettingsBagTest extends \CiviUnitTestCase { $this->mandates = []; } - public function tearDown() { + public function tearDown(): void { $GLOBALS['civicrm_setting'] = $this->origSetting; parent::tearDown(); } diff --git a/tests/phpunit/Civi/Core/SettingsManagerTest.php b/tests/phpunit/Civi/Core/SettingsManagerTest.php index 71be2b80a7..77b99ad115 100644 --- a/tests/phpunit/Civi/Core/SettingsManagerTest.php +++ b/tests/phpunit/Civi/Core/SettingsManagerTest.php @@ -38,7 +38,7 @@ class SettingsManagerTest extends \CiviUnitTestCase { ]; } - public function tearDown() { + public function tearDown(): void { $GLOBALS['civicrm_setting'] = $this->origSetting; parent::tearDown(); } diff --git a/tests/phpunit/Civi/Core/SettingsStackTest.php b/tests/phpunit/Civi/Core/SettingsStackTest.php index ac4cee9056..258c68d20e 100644 --- a/tests/phpunit/Civi/Core/SettingsStackTest.php +++ b/tests/phpunit/Civi/Core/SettingsStackTest.php @@ -3,15 +3,11 @@ namespace Civi\Core; class SettingsStackTest extends \CiviUnitTestCase { - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->useTransaction(TRUE); } - public function tearDown() { - parent::tearDown(); - } - /** * Temporarily modify -- then restore -- settings. */ diff --git a/tests/phpunit/Civi/Test/ExampleHookTest.php b/tests/phpunit/Civi/Test/ExampleHookTest.php index fb81845ccb..b84d80ceac 100644 --- a/tests/phpunit/Civi/Test/ExampleHookTest.php +++ b/tests/phpunit/Civi/Test/ExampleHookTest.php @@ -19,7 +19,7 @@ class ExampleHookTest extends \PHPUnit\Framework\TestCase implements HeadlessInt return \Civi\Test::headless()->apply(); } - protected function setUp() { + protected function setUp(): void { $this->contact = \CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact', [ 'contact_type' => 'Individual', ]); @@ -27,7 +27,7 @@ class ExampleHookTest extends \PHPUnit\Framework\TestCase implements HeadlessInt $session->set('userID', $this->contact->id); } - protected function tearDown() { + protected function tearDown(): void { $this->contact->delete(); } diff --git a/tests/phpunit/Civi/Test/ExampleTransactionalTest.php b/tests/phpunit/Civi/Test/ExampleTransactionalTest.php index 17a93264e9..b147434aea 100644 --- a/tests/phpunit/Civi/Test/ExampleTransactionalTest.php +++ b/tests/phpunit/Civi/Test/ExampleTransactionalTest.php @@ -21,7 +21,7 @@ class ExampleTransactionalTest extends \PHPUnit\Framework\TestCase implements He return \Civi\Test::headless()->apply(); } - protected function setUp() { + protected function setUp(): void { /** @var \CRM_Contact_DAO_Contact $contact */ $contact = \CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact', [ 'contact_type' => 'Individual', @@ -60,9 +60,6 @@ class ExampleTransactionalTest extends \PHPUnit\Framework\TestCase implements He $this->assertTrue((bool) $dao->find()); } - public function tearDown() { - } - /** * Both testDummy1 and testDummy2 have been created at some point (as part of the test runs), * but all the data was rolled-back diff --git a/tests/phpunit/api/v4/Action/ChainTest.php b/tests/phpunit/api/v4/Action/ChainTest.php index 00f6267c5c..16274b2ca1 100644 --- a/tests/phpunit/api/v4/Action/ChainTest.php +++ b/tests/phpunit/api/v4/Action/ChainTest.php @@ -30,8 +30,8 @@ use Civi\Api4\CustomGroup; */ class ChainTest extends UnitTestCase { - public function tearDown() { - $result = CustomField::delete() + public function tearDown(): void { + CustomField::delete() ->setCheckPermissions(FALSE) ->addWhere('name', '=', 'FavPerson') ->addChain('group', CustomGroup::delete()->addWhere('name', '=', 'TestActCus')) diff --git a/tests/phpunit/api/v4/Action/FkJoinTest.php b/tests/phpunit/api/v4/Action/FkJoinTest.php index fe5f4e8363..ed140f8738 100644 --- a/tests/phpunit/api/v4/Action/FkJoinTest.php +++ b/tests/phpunit/api/v4/Action/FkJoinTest.php @@ -39,7 +39,7 @@ class FkJoinTest extends UnitTestCase { return parent::setUpHeadless(); } - public function tearDown() { + public function tearDown(): void { $relatedTables = [ 'civicrm_activity', 'civicrm_phone', diff --git a/tests/phpunit/api/v4/Traits/OptionCleanupTrait.php b/tests/phpunit/api/v4/Traits/OptionCleanupTrait.php index c2571aa64e..52c012252d 100644 --- a/tests/phpunit/api/v4/Traits/OptionCleanupTrait.php +++ b/tests/phpunit/api/v4/Traits/OptionCleanupTrait.php @@ -35,7 +35,7 @@ trait OptionCleanupTrait { $this->optionValueMaxId = \CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_option_value'); } - public function tearDown() { + public function tearDown(): void { if ($this->optionValueMaxId) { \CRM_Core_DAO::executeQuery('DELETE FROM civicrm_option_value WHERE id > ' . $this->optionValueMaxId); } diff --git a/tests/phpunit/api/v4/UnitTestCase.php b/tests/phpunit/api/v4/UnitTestCase.php index 067417b1d8..9d91f0b582 100644 --- a/tests/phpunit/api/v4/UnitTestCase.php +++ b/tests/phpunit/api/v4/UnitTestCase.php @@ -48,15 +48,6 @@ class UnitTestCase extends \PHPUnit\Framework\TestCase implements HeadlessInterf return \Civi\Test::headless()->apply(); } - /** - * Tears down the fixture, for example, closes a network connection. - * - * This method is called after a test is executed. - */ - public function tearDown() { - parent::tearDown(); - } - /** * Quick clean by emptying tables created for the test. *