Skip to content

Commit

Permalink
[PHPunit8] cleanup on tearDown functions
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Mar 26, 2021
1 parent 1f4a00a commit 6d666ae
Show file tree
Hide file tree
Showing 35 changed files with 30 additions and 142 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Activity/BAO/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase {
*
* @throws \CiviCRM_API3_Exception
*/
public function setUp() {
public function setUp():void {
parent::setUp();
$this->prepareForACLs();
CRM_Core_Config::singleton()->userPermissionClass->permissions = ['view all contacts', 'access CiviCRM'];
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Activity/Form/ActivityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
class CRM_Activity_Form_ActivityTest extends CiviUnitTestCase {

public function setUp() {
public function setUp():void {
parent::setUp();
$this->assignee1 = $this->individualCreate([
'first_name' => 'testassignee1',
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
class CRM_Case_BAO_CaseTypeForkTest extends CiviCaseTestCase {

public function setUp() {
public function setUp(): void {
parent::setUp();
CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Case/Form/CustomDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CRM_Case_Form_CustomDataTest extends CiviCaseTestCase {

protected $custom_group;

public function setUp() {
public function setUp(): void {
parent::setUp();
$this->custom_group = $this->customGroupCreate(['extends' => 'Case']);
$this->custom_group = $this->custom_group['values'][$this->custom_group['id']];
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Case/Form/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
class CRM_Case_Form_SearchTest extends CiviCaseTestCase {

public function setUp() {
public function setUp():void {
parent::setUp();
$this->quickCleanup(['civicrm_case_contact', 'civicrm_case', 'civicrm_contact']);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contribute/BAO/ContributionTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
class CRM_Contribute_BAO_ContributionTypeTest extends CiviUnitTestCase {

public function setUp() {
public function setUp(): void {
parent::setUp();
$this->organizationCreate();
}
Expand Down
4 changes: 0 additions & 4 deletions tests/phpunit/CRM/Contribute/BAO/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
class CRM_Contribute_BAO_ProductTest extends CiviUnitTestCase {

public function setUp() {
parent::setUp();
}

/**
* Check method add()
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Extension/Manager/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
class CRM_Extension_Manager_ModuleTest extends CiviUnitTestCase {

public function setUp() {
public function setUp():void {
parent::setUp();
// $query = "INSERT INTO civicrm_domain ( name, version ) VALUES ( 'domain', 3 )";
// $result = CRM_Core_DAO::executeQuery($query);
Expand Down
6 changes: 1 addition & 5 deletions tests/phpunit/CRM/Extension/Manager/ReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
class CRM_Extension_Manager_ReportTest extends CiviUnitTestCase {

public function setUp() {
public function setUp(): void {
parent::setUp();
//if (class_exists('test_extension_manager_reporttest')) {
// test_extension_manager_reporttest::$counts = array();
Expand All @@ -17,10 +17,6 @@ public function setUp() {
]);
}

public function tearDown() {
parent::tearDown();
}

/**
* Install an extension with a valid type name.
*/
Expand Down
6 changes: 1 addition & 5 deletions tests/phpunit/CRM/Extension/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ class CRM_Extension_ManagerTest extends CiviUnitTestCase {
const TESTING_TYPE = 'report';
const OTHER_TESTING_TYPE = 'module';

public function setUp() {
public function setUp(): void {
parent::setUp();
list ($this->basedir, $this->container) = $this->_createContainer();
$this->mapper = new CRM_Extension_Mapper($this->container);
}

public function tearDown() {
parent::tearDown();
}

/**
* Install an extension with an invalid type name.
*
Expand Down
6 changes: 1 addition & 5 deletions tests/phpunit/CRM/Extension/MapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CRM_Extension_MapperTest extends CiviUnitTestCase {
*/
protected $mapperWithSlash;

public function setUp() {
public function setUp(): void {
parent::setUp();
list ($this->basedir, $this->container) = $this->_createContainer();
$this->mapper = new CRM_Extension_Mapper($this->container);
Expand All @@ -45,10 +45,6 @@ public function setUp() {
$this->mapperWithSlash = new CRM_Extension_Mapper($this->containerWithSlash);
}

public function tearDown() {
parent::tearDown();
}

public function testClassToKey() {
$this->assertEquals("test.foo.bar", $this->mapper->classToKey('test_foo_bar'));
}
Expand Down
9 changes: 1 addition & 8 deletions tests/phpunit/CRM/Pledge/BAO/PledgeBlockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,12 @@ class CRM_Pledge_BAO_PledgeBlockTest extends CiviUnitTestCase {
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$contributionPage = $this->contributionPageCreate();
$this->_contributionPageId = $contributionPage['id'];
}

/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() {
}

/**
* create() and deletepledgeblock() method
*/
Expand Down
15 changes: 0 additions & 15 deletions tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,6 @@
*/
class CRM_Pledge_BAO_PledgePaymentTest 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() {
}

/**
* Test for Add/Update Pledge Payment.
*/
Expand Down
9 changes: 1 addition & 8 deletions tests/phpunit/CRM/Pledge/BAO/PledgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CRM_Pledge_BAO_PledgeTest extends CiviUnitTestCase {
*
* @throws \CiviCRM_API3_Exception
*/
protected function setUp() {
protected function setUp(): void {
parent::setUp();
$this->ids['Contact'][0] = $this->individualCreate();
$this->_params = [
Expand All @@ -43,13 +43,6 @@ protected function setUp() {
];
}

/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
protected function tearDown() {
}

/**
* Test for Add/Update Pledge.
*
Expand Down
13 changes: 0 additions & 13 deletions tests/phpunit/CRM/Price/BAO/PriceFieldValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@
*/
class CRM_Price_BAO_PriceFieldValueTest extends CiviUnitTestCase {

/**
* Sets up the fixtures.
*/
protected function setUp() {
parent::setUp();
}

/**
* Tears down the fixture.
*/
protected function tearDown() {
}

/**
* Verifies visibility field exists and is configured as a pseudoconstant
* referencing the 'visibility' option group.
Expand Down
13 changes: 0 additions & 13 deletions tests/phpunit/CRM/Price/BAO/PriceSetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@
*/
class CRM_Price_BAO_PriceSetTest extends CiviUnitTestCase {

/**
* Sets up the fixtures.
*/
protected function setUp() {
parent::setUp();
}

/**
* Tears down the fixture.
*/
protected function tearDown() {
}

/**
* Test the correct amount level is returned for an event which is not presented as a price set event.
*
Expand Down
6 changes: 1 addition & 5 deletions tests/phpunit/CRM/Report/Form/ContactSummaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@ class CRM_Report_Form_ContactSummaryTest extends CiviReportTestCase {
'civicrm_address',
];

public function setUp() {
public function setUp(): void {
parent::setUp();
$this->quickCleanup($this->_tablesToTruncate);
}

public function tearDown() {
parent::tearDown();
}

/**
* Ensure the new Odd/Event street number sort column works correctly
*/
Expand Down
10 changes: 0 additions & 10 deletions tests/phpunit/CRM/Report/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@
*/
class CRM_Report_FormTest extends CiviUnitTestCase {

public function setUp() {
// There are only unit tests here at present, we can skip database loading.
return TRUE;
}

public function tearDown() {
// There are only unit tests here at present, we can skip database loading.
return TRUE;
}

/**
* Used by testGetFromTo
*/
Expand Down
8 changes: 0 additions & 8 deletions tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@
*/
class CRM_Utils_Cache_SqlGroupTest extends CiviUnitTestCase {

public function setUp() {
parent::setUp();
}

public function tearDown() {
parent::tearDown();
}

/**
* Add and remove two items from the same cache instance.
*/
Expand Down
10 changes: 0 additions & 10 deletions tests/phpunit/CRM/Utils/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,6 @@
*/
class CRM_Utils_DateTest extends CiviUnitTestCase {

public function setUp() {
// There are only unit tests here at present, we can skip database loading.
return TRUE;
}

public function tearDown() {
// There are only unit tests here at present, we can skip database loading.
return TRUE;
}

/**
* Used by testGetFromTo
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/Civi/CCase/SequenceListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class SequenceListenerTest extends \CiviCaseTestCase {

public function setUp() {
public function setUp(): void {
parent::setUp();
$this->_params = [
'case_type' => $this->caseType,
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/CiviTest/CiviCaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CiviCaseTestCase extends CiviUnitTestCase {

protected $_loggedInUser;

public function setUp() {
public function setUp(): void {
parent::setUp();

// CRM-9404 - set-up is a bit cumbersome but had to put something in place to set up activity types & case types
Expand Down Expand Up @@ -110,7 +110,7 @@ public function setUp() {
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown() {
public function tearDown(): void {
$this->quickCleanup($this->tablesToTruncate, TRUE);
$this->customDirectories(array('template_path' => FALSE));
CRM_Case_XMLRepository::singleton(TRUE);
Expand Down
7 changes: 1 addition & 6 deletions tests/phpunit/CiviTest/CiviReportTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@
*/
class CiviReportTestCase extends CiviUnitTestCase {

public function setUp() {
parent::setUp();
$this->_sethtmlGlobals();
}

public function tearDown() {
public function tearDown(): void {
// TODO Figure out how to automatically drop all temporary tables.
// Note that MySQL doesn't provide a way to list them, so we would need
// to keep track ourselves (eg CRM_Core_TemporaryTableManager) or reset
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ public function createDomainContacts() {
/**
* Common teardown functions for all unit tests.
*/
protected function tearDown() {
protected function tearDown(): void {
$this->_apiversion = 3;
$this->resetLabels();

Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/E2E/Cache/TieredTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class E2E_Cache_TieredTest extends E2E_Cache_CacheTestCase {
*/
protected $b;

protected function tearDown() {
protected function tearDown(): void {
if (function_exists('timecop_return')) {
timecop_return();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/E2E/Cache/TwoInstancesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function setUp() {
$this->a = $this->b = NULL;
}

protected function tearDown() {
protected function tearDown(): void {
parent::tearDown();
if ($this->a) {
$this->a->clear();
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/E2E/Core/PrevNextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function setUp() {
);
}

protected function tearDown() {
protected function tearDown(): void {
\Civi::service('prevnext')->deleteItem(NULL, $this->cacheKey);
\Civi::service('prevnext')->deleteItem(NULL, $this->cacheKeyB);
}
Expand Down
Loading

0 comments on commit 6d666ae

Please sign in to comment.