Add return type setUp and tearDown methods in unit tests

After the bump to PHP 7.2 all the setUp and tearDown methods
in unit test classes need to have an explicit "void" return type
declaration.
This commit is contained in:
Nestor Soriano 2022-03-18 11:50:38 +01:00
parent 819494f2ed
commit 01073ec24f
No known key found for this signature in database
GPG Key ID: 08110F3518C12CAD
106 changed files with 128 additions and 128 deletions

View File

@ -21,7 +21,7 @@ class WC_API_Unit_Test_Case extends WC_Unit_Test_Case {
* @since 2.2
* @see WC_Unit_Test_Case::setUp()
*/
public function setUp() {
public function setUp(): void {
parent::setUp();

View File

@ -21,7 +21,7 @@ class WC_REST_Unit_Test_Case extends WC_Unit_Test_Case {
/**
* Setup our test server.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
global $wp_rest_server;
$wp_rest_server = new WP_Test_Spy_REST_Server();
@ -37,7 +37,7 @@ class WC_REST_Unit_Test_Case extends WC_Unit_Test_Case {
/**
* Unset the server.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
global $wp_rest_server;
unset( $this->server );

View File

@ -62,7 +62,7 @@ class WC_Unit_Test_Case extends WP_HTTP_TestCase {
*
* @since 2.2
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
@ -90,7 +90,7 @@ class WC_Unit_Test_Case extends WP_HTTP_TestCase {
*
* @since 3.5.0
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
// Terms are deleted in WP_UnitTestCase::tearDownAfterClass, then e.g. Uncategorized product_cat is missing.

View File

@ -134,7 +134,7 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
/**
* @since 1.3.0
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
if ( ! self::$did_init ) {
self::init();
@ -146,7 +146,7 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
/**
* @since 1.3.1
*/
public static function tearDownAfterClass() {
public static function tearDownAfterClass(): void {
self::save_cache();
@ -158,7 +158,7 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
*
* @since 1.0.0
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
@ -176,7 +176,7 @@ abstract class WP_HTTP_TestCase extends WP_UnitTestCase {
*
* @since 1.0.0
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();

View File

@ -13,7 +13,7 @@ class WC_Tests_Account_Permissions extends WC_Unit_Test_Case {
* Setup:
* 1. Set current user to zero to simulate not logged in state.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
wp_set_current_user( 0 );
}
@ -22,7 +22,7 @@ class WC_Tests_Account_Permissions extends WC_Unit_Test_Case {
* Teardown:
* 1. Set current user to 0 because we change current user in some tests.
*/
public function tearDown() {
public function tearDown(): void {
wp_set_current_user( 0 );
parent::tearDown();
}

View File

@ -13,7 +13,7 @@ class WC_Tests_Admin_Dashboard extends WC_Unit_Test_Case {
/**
* Set up for tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(
@ -28,7 +28,7 @@ class WC_Tests_Admin_Dashboard extends WC_Unit_Test_Case {
/**
* Tear down.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
remove_filter( 'rest_pre_dispatch', array( $this, 'mock_rest_responses' ), 10 );
}

View File

@ -16,7 +16,7 @@ class WC_Tests_Notes_Run_Db_Update extends WC_Unit_Test_Case {
* Load the necessary files, as they're not automatically loaded by WooCommerce.
*
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/wc-admin-functions.php';
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/notes/class-wc-notes-run-db-update.php';
@ -25,7 +25,7 @@ class WC_Tests_Notes_Run_Db_Update extends WC_Unit_Test_Case {
/**
* Clean up before each test.
*/
public function setUp() {
public function setUp(): void {
if ( ! WC()->is_wc_admin_active() ) {
$this->markTestSkipped( 'WC Admin is not active on WP versions < 5.3' );
return;

View File

@ -14,7 +14,7 @@ class WC_Tests_Admin_Report extends WC_Unit_Test_Case {
* Load the necessary files, as they're not automatically loaded by WooCommerce.
*
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/reports/class-wc-admin-report.php';
}

View File

@ -13,7 +13,7 @@ class WC_Tests_Report_Sales_By_Date extends WC_Unit_Test_Case {
/**
* Load the necessary files, as they're not automatically loaded by WooCommerce.
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/reports/class-wc-admin-report.php';
include_once WC_Unit_Tests_Bootstrap::instance()->plugin_dir . '/includes/admin/reports/class-wc-report-sales-by-date.php';
}

View File

@ -13,7 +13,7 @@ class WC_Tests_Cart extends WC_Unit_Test_Case {
/**
* tearDown.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
WC()->cart->empty_cart();

View File

@ -12,7 +12,7 @@ class WC_Tests_Checkout extends WC_Unit_Test_Case {
/**
* TearDown.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
WC()->cart->empty_cart();
}
@ -20,7 +20,7 @@ class WC_Tests_Checkout extends WC_Unit_Test_Case {
/**
* Setup.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
WC()->cart->empty_cart();
}

View File

@ -26,7 +26,7 @@ class WC_Test_WooCommerce extends WC_Unit_Test_Case {
*
* @since 2.2
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->wc = WC();
}

View File

@ -20,7 +20,7 @@ class WC_Test_Admin_Post_Types extends WC_Unit_Test_Case {
/**
* Setup. Create a instance to use throughout.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->wc_cpt = new WC_Admin_Post_Types();
}

View File

@ -15,7 +15,7 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
/**
* Sets up the test class.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Set a valid address for the customer so shipping rates will calculate.
@ -27,7 +27,7 @@ class WC_Tests_Coupon extends WC_Unit_Test_Case {
/**
* Cleans up after the test class.
*/
public function tearDown() {
public function tearDown(): void {
WC()->cart->empty_cart();
WC()->cart->remove_coupons();

View File

@ -13,7 +13,7 @@ class WC_Tests_CRUD_Data extends WC_Unit_Test_Case {
/**
* Restore UTC on failure.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
// @codingStandardsIgnoreStart
date_default_timezone_set( 'UTC' );

View File

@ -37,7 +37,7 @@ class WC_Tests_Customer_Download extends WC_Unit_Test_Case {
/**
* Tests set up.
*/
public function setUp() {
public function setUp(): void {
$this->customer_id = 1;
$this->customer_email = 'test@example.com';

View File

@ -14,7 +14,7 @@ class WC_Tests_Customer_Functions extends WC_Unit_Test_Case {
/**
* Perform any common setup work.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// For these tests, we are not concerned with Approved Download Directory functionality.

View File

@ -62,7 +62,7 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
/**
* Setup tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->products = array();
@ -74,7 +74,7 @@ class WC_Tests_Discounts extends WC_Unit_Test_Case {
/**
* Clean up after each test. DB changes are reverted in parent::tearDown().
*/
public function tearDown() {
public function tearDown(): void {
WC()->cart->empty_cart();
WC()->cart->remove_coupons();

View File

@ -14,7 +14,7 @@ class WC_Tests_WC_Emails extends WC_Unit_Test_Case {
/**
* Setup tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Load email classes.

View File

@ -9,7 +9,7 @@ class WC_Tests_Product_CSV_Exporter extends WC_Unit_Test_Case {
/**
* Load up the exporter classes since they aren't loaded by default.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$bootstrap = WC_Unit_Tests_Bootstrap::instance();

View File

@ -15,7 +15,7 @@ class WC_Tests_Formatting_Functions extends WC_Unit_Test_Case {
/**
* Set up.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Callback used by WP_HTTP_TestCase to decide whether to perform HTTP requests or to provide a mocked response.

View File

@ -81,7 +81,7 @@ class WC_Tests_Paypal_Gateway_Request extends WC_Unit_Test_Case {
/**
* Initialize the Paypal gateway and Request objects.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$bootstrap = WC_Unit_Tests_Bootstrap::instance();

View File

@ -25,7 +25,7 @@ class WC_Tests_Product_CSV_Importer extends WC_Unit_Test_Case {
/**
* Load up the importer classes since they aren't loaded by default.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$bootstrap = WC_Unit_Tests_Bootstrap::instance();

View File

@ -16,7 +16,7 @@ class WC_Tests_Tax_CSV_Importer extends WC_Unit_Test_Case {
/**
* Load up the importer classes since they aren't loaded by default.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->csv_file = dirname( __FILE__ ) . '/sample_tax_rates.csv';

View File

@ -13,7 +13,7 @@ class WC_Tests_MaxMind_Database extends WC_Unit_Test_Case {
/**
* Run setup code for unit tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Callback used by WP_HTTP_TestCase to decide whether to perform HTTP requests or to provide a mocked response.

View File

@ -20,7 +20,7 @@ class WC_Tests_MaxMind_Integration extends WC_Unit_Test_Case {
/**
* Run setup code for unit tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Override the filesystem method that we're using.

View File

@ -6,7 +6,7 @@
* @since 3.0.0
*/
class WC_Tests_Log_Handler_DB extends WC_Unit_Test_Case {
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->handler = new WC_Log_Handler_DB( array( 'threshold' => 'debug' ) );

View File

@ -15,7 +15,7 @@ class WC_Tests_Log_Handler_Email extends WC_Unit_Test_Case {
/**
* Test setup.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
reset_phpmailer_instance();
}
@ -23,7 +23,7 @@ class WC_Tests_Log_Handler_Email extends WC_Unit_Test_Case {
/**
* Test teardown.
*/
public function tearDown() {
public function tearDown(): void {
reset_phpmailer_instance();
parent::tearDown();
}

View File

@ -7,7 +7,7 @@
*/
class WC_Tests_Log_Handler_File extends WC_Unit_Test_Case {
public function tearDown() {
public function tearDown(): void {
$log_files = array(
'unit-tests',
'log',

View File

@ -10,7 +10,7 @@ class WC_Tests_Order_Item_Meta extends WC_Unit_Test_Case {
/**
* Suppress deprecation notice from WC_Order_Item_Meta constructor.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
wp_insert_term( 'Testing Categories', 'category', array( 'slug' => 'testing' ) );

View File

@ -15,7 +15,7 @@ class WC_Tests_Payment_Gateway_COD extends WC_Unit_Test_Case {
/**
* Clean up after each test.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
Constants::clear_constants();

View File

@ -11,7 +11,7 @@ class WC_Tests_Payment_Gateway extends WC_Unit_Test_Case {
/**
* Setup, enable payment gateways Cash on delivery and direct bank deposit.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
WC()->session = null;
$wc_payment_gateways = WC_Payment_Gateways::instance();
@ -26,7 +26,7 @@ class WC_Tests_Payment_Gateway extends WC_Unit_Test_Case {
/**
* Initialize session that some tests might have removed.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
WC()->initialize_session();
}

View File

@ -15,7 +15,7 @@ class WC_Tests_Payment_Tokens extends WC_Unit_Test_Case {
*
* @see WC_Unit_Test_Case::setUp()
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user_id = $this->login_as_role( 'shop_manager' );
}

View File

@ -27,7 +27,7 @@ class WC_Test_Privacy_Export extends WC_Unit_Test_Case {
/**
* Load up the importer classes since they aren't loaded by default.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$customer1 = WC_Helper_Customer::create_customer( 'customer1', 'password', 'test1@test.com' );

View File

@ -20,7 +20,7 @@ class WC_Tests_Product extends WC_Unit_Test_Case {
/**
* Runs before every test.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->product = new WC_Product();

View File

@ -12,7 +12,7 @@ class WC_Tests_Product_Simple extends WC_Unit_Test_Case {
*/
protected $product;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->product = WC_Helper_Product::create_simple_product();

View File

@ -70,7 +70,7 @@ abstract class AbstractRestApiTest extends WC_REST_Unit_Test_Case {
/**
* Setup test class.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
wp_set_current_user( self::$user );
}

View File

@ -12,7 +12,7 @@ class WC_Tests_API_Coupons_V2 extends WC_REST_Unit_Test_Case {
* Setup test coupon data.
* @since 3.0.0
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Coupons_Controller();
$this->user = $this->factory->user->create(

View File

@ -17,7 +17,7 @@ class Customers_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Customers_Controller();
}

View File

@ -20,7 +20,7 @@ class WC_Tests_API_Orders_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Orders_Controller();
$this->user = $this->factory->user->create(

View File

@ -14,7 +14,7 @@ class Payment_Gateways_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Payment_Gateways_Controller();
$this->user = $this->factory->user->create(

View File

@ -11,7 +11,7 @@ class WC_Tests_API_Product_Reviews_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(

View File

@ -12,7 +12,7 @@ class Product_Variations_API_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Product_Variations_Controller();
$this->user = $this->factory->user->create(

View File

@ -14,7 +14,7 @@ class Products_API_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Products_Controller();
$this->user = $this->factory->user->create(

View File

@ -14,7 +14,7 @@ class Settings_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Setting_Options_Controller();
\Automattic\WooCommerce\RestApi\UnitTests\Helpers\SettingsHelper::register();

View File

@ -11,7 +11,7 @@ class Shipping_Methods_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Shipping_Methods_Controller();
$this->user = $this->factory->user->create(

View File

@ -18,7 +18,7 @@ class WC_Tests_API_Shipping_Zones_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Shipping_Zones_Controller();
$this->user = $this->factory->user->create(

View File

@ -16,7 +16,7 @@ class WC_Tests_REST_System_Status_V2 extends WC_REST_Unit_Test_Case {
/**
* Setup our test server.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_System_Status_Controller();
$this->user = $this->factory->user->create(

View File

@ -25,7 +25,7 @@ class WC_Tests_API_Coupons extends WC_REST_Unit_Test_Case {
* Setup test coupon data.
* @since 3.5.0
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Coupons_Controller();
$this->user = $this->factory->user->create(

View File

@ -17,7 +17,7 @@ class Customers extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Customers_Controller();
}

View File

@ -28,7 +28,7 @@ class WC_Tests_API_Orders extends WC_REST_Unit_Test_Case {
/**
* Setup our test server.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Orders_Controller();
$this->user = $this->factory->user->create(

View File

@ -14,7 +14,7 @@ class Payment_Gateways extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Payment_Gateways_Controller();
$this->user = $this->factory->user->create(

View File

@ -11,7 +11,7 @@ class WC_Tests_API_Product_Reviews extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(

View File

@ -14,7 +14,7 @@ class Product_Variations_API extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Product_Variations_Controller();
$this->user = $this->factory->user->create(

View File

@ -19,7 +19,7 @@ class WC_Tests_API_Product extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Products_Controller();
$this->user = $this->factory->user->create(

View File

@ -11,7 +11,7 @@ class WC_Tests_API_Reports_Coupons_Totals extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(

View File

@ -11,7 +11,7 @@ class WC_Tests_API_Reports_Customers_Totals extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(

View File

@ -11,7 +11,7 @@ class WC_Tests_API_Reports_Orders_Totals extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(

View File

@ -11,7 +11,7 @@ class WC_Tests_API_Reports_Products_Totals extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(

View File

@ -11,7 +11,7 @@ class WC_Tests_API_Reports_Reviews_Totals extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(

View File

@ -14,7 +14,7 @@ class Settings extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Setting_Options_Controller();
\Automattic\WooCommerce\RestApi\UnitTests\Helpers\SettingsHelper::register();

View File

@ -11,7 +11,7 @@ class Shipping_Methods extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Shipping_Methods_Controller();
$this->user = $this->factory->user->create(

View File

@ -19,7 +19,7 @@ class WC_Tests_API_Shipping_Zones extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Shipping_Zones_Controller();
$this->user = $this->factory->user->create(

View File

@ -36,7 +36,7 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
/**
* Setup our test server.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
wp_set_current_user( self::$user );

View File

@ -13,7 +13,7 @@ class WC_Tests_Session_Handler extends WC_Unit_Test_Case {
/**
* Setup.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->handler = new WC_Session_Handler();

View File

@ -23,7 +23,7 @@ class WC_Tests_Register_WP_Admin_Settings extends WC_Unit_Test_Case {
/**
* Initialize a WC_Settings_Page for testing
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$mock_page = $this->getMockBuilder( 'WC_Settings_General' )->getMock();

View File

@ -14,7 +14,7 @@ class WC_Tests_Shipping_Zone extends WC_Unit_Test_Case {
/**
* Set up tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
WC_Helper_Shipping_Zones::create_mock_zones();

View File

@ -14,7 +14,7 @@ class WC_Tests_Shipping_Zones extends WC_Unit_Test_Case {
/**
* Set up tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
WC_Helper_Shipping_Zones::create_mock_zones();

View File

@ -27,7 +27,7 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
/**
* Setup the cart for totals calculation.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Set a valid address for the customer so shipping rates will calculate.
@ -115,7 +115,7 @@ class WC_Tests_Totals extends WC_Unit_Test_Case {
/**
* Clean up after test.
*/
public function tearDown() {
public function tearDown(): void {
WC()->cart->empty_cart();
WC()->session->set( 'chosen_shipping_methods', array() );
WC_Helper_Shipping::delete_simple_flat_rate();

View File

@ -29,7 +29,7 @@ class WC_Tests_API_Functions extends WC_Unit_Test_Case {
/**
* Run setup code for unit tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Callback used by WP_HTTP_TestCase to decide whether to perform HTTP requests or to provide a mocked response.
@ -44,7 +44,7 @@ class WC_Tests_API_Functions extends WC_Unit_Test_Case {
/**
* Run tear down code for unit tests.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
// remove files created in the wc_rest_upload_image_from_url() tests.

View File

@ -15,14 +15,14 @@ class WC_Tests_Rate_Limiter extends WC_Unit_Test_Case {
/**
* Run setup code for unit tests.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
}
/**
* Run tear down code for unit tests.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
}

View File

@ -18,7 +18,7 @@ class WC_Tests_Core_Functions extends WC_Unit_Test_Case {
*
* @return void
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->wc = WC();
}

View File

@ -51,7 +51,7 @@ class WC_Tests_Deprecated_Hooks extends WC_Unit_Test_Case {
/**
* Disable deprecation error trigger for this class.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
add_filter( 'deprecated_function_trigger_error', '__return_false' );
add_filter( 'deprecated_hook_trigger_error', '__return_false' );

View File

@ -15,7 +15,7 @@ class WC_Tests_Notice_Functions extends WC_Unit_Test_Case {
*
* @since 2.2
*/
public function tearDown() {
public function tearDown(): void {
WC()->session->set( 'wc_notices', null );
}

View File

@ -23,7 +23,7 @@ class WC_Tests_Plugin_Updates extends WC_Unit_Test_Case {
*
* @since 3.2.0
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
if ( ! class_exists( 'WC_Plugin_Updates' ) ) {

View File

@ -15,7 +15,7 @@ class WC_Admin_Dashboard_Setup_Test extends WC_Unit_Test_Case {
/**
* Set up
*/
public function setUp() {
public function setUp(): void {
// Set default country to non-US so that 'payments' task gets added but 'woocommerce-payments' doesn't,
// by default it won't be considered completed but we can manually change that as needed.
update_option( 'woocommerce_default_country', 'JP' );
@ -36,7 +36,7 @@ class WC_Admin_Dashboard_Setup_Test extends WC_Unit_Test_Case {
/**
* Tear down
*/
public function tearDown() {
public function tearDown(): void {
remove_all_filters( 'woocommerce_available_payment_gateways' );
parent::tearDown();

View File

@ -13,7 +13,7 @@ class WC_Admin_Functions_Test extends \WC_Unit_Test_Case {
/**
* Load up the importer classes since they aren't loaded by default.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$bootstrap = \WC_Unit_Tests_Bootstrap::instance();

View File

@ -8,7 +8,7 @@ class WC_Tests_Helper_API extends WC_Unit_Test_Case {
/**
* Set up mock responses for all API calls.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Callback used by WP_HTTP_TestCase to decide whether to perform HTTP requests or to provide a mocked response.

View File

@ -10,7 +10,7 @@ class WC_Product_CSV_Importer_Controller_Test extends WC_Unit_Test_Case {
/**
* Load up the importer classes since they aren't loaded by default.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$bootstrap = WC_Unit_Tests_Bootstrap::instance();

View File

@ -13,7 +13,7 @@ class WC_Cart_Test extends \WC_Unit_Test_Case {
/**
* tearDown.
*/
public function tearDown() {
public function tearDown(): void {
parent::tearDown();
WC()->cart->empty_cart();

View File

@ -20,7 +20,7 @@ class WC_Checkout_Test extends \WC_Unit_Test_Case {
/**
* Runs before each test.
*/
public function setUp() {
public function setUp(): void {
// phpcs:disable Generic.CodeAnalysis, Squiz.Commenting
$this->sut = new class() extends WC_Checkout {
public function validate_posted_data( &$data, &$errors ) {

View File

@ -20,7 +20,7 @@ class WC_Product_CSV_Exporter_Test extends \WC_Unit_Test_Case {
/**
* Load up the exporter classes since they aren't loaded by default.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$bootstrap = \WC_Unit_Tests_Bootstrap::instance();

View File

@ -13,7 +13,7 @@ class WC_Product_CSV_Importer_Test extends \WC_Unit_Test_Case {
/**
* Load up the importer classes since they aren't loaded by default.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$bootstrap = \WC_Unit_Tests_Bootstrap::instance();

View File

@ -9,7 +9,7 @@ class WC_REST_Product_Attributes_V1_Controller_Tests extends WC_Unit_Test_Case {
/**
* Runs before any test.
*/
public function setUp() {
public function setUp(): void {
// phpcs:disable Generic.CodeAnalysis, Squiz.Commenting
$this->sut = new class() extends WC_REST_Product_Attributes_V1_Controller {
public function get_taxonomy( $request ) {

View File

@ -40,7 +40,7 @@ class WC_REST_Product_Reviews_V1_Controller_Tests extends WC_Unit_Test_Case {
/**
* Creates test users with varying permissions.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->sut = new WC_REST_Product_Reviews_V1_Controller();

View File

@ -9,7 +9,7 @@ class WC_REST_Order_V2_Controller_Test extends WC_REST_Unit_Test_case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Orders_V2_Controller();
$this->user = $this->factory->user->create(

View File

@ -19,7 +19,7 @@ class WC_REST_Product_Reviews_V2_Controller_Test extends WC_REST_Unit_Test_case
*/
private $editor_id;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->sut = new WC_REST_Product_Reviews_V2_Controller();

View File

@ -9,7 +9,7 @@ class WC_REST_Products_V2_Controller_Test extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Products_V2_Controller();
$this->user = $this->factory->user->create(

View File

@ -9,7 +9,7 @@ class WC_REST_Coupons_Controller_Tests extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Coupons_Controller();
$this->user = $this->factory->user->create(

View File

@ -9,7 +9,7 @@ class WC_REST_Orders_Controller_Tests extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Orders_Controller();
$this->user = $this->factory->user->create(

View File

@ -33,7 +33,7 @@ class WC_REST_Product_Reviews_Controller_Tests extends WC_REST_Unit_Test_Case {
*/
private $review_id;
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->sut = new WC_REST_Product_Reviews_Controller();

View File

@ -9,7 +9,7 @@ class WC_REST_Products_Controller_Tests extends WC_REST_Unit_Test_Case {
/**
* Setup our test server, endpoints, and user info.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->endpoint = new WC_REST_Products_Controller();
$this->user = $this->factory->user->create(

View File

@ -9,7 +9,7 @@ class WC_REST_Taxes_Controller_Tests extends WC_REST_Unit_Test_Case {
/**
* Runs before any test.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
$this->user = $this->factory->user->create(
array(

View File

@ -9,7 +9,7 @@ class WC_REST_Terms_Controller_Tests extends WC_Unit_Test_Case {
/**
* Runs before any test.
*/
public function setUp() {
public function setUp(): void {
// phpcs:disable Generic.CodeAnalysis, Squiz.Commenting
$this->sut = new class() extends WC_REST_Terms_Controller {
public function get_taxonomy( $request ) {

View File

@ -22,7 +22,7 @@ class WC_Attribute_Functions_Test extends \WC_Unit_Test_Case {
/**
* Set up.
*/
public function setUp() {
public function setUp(): void {
parent::setUp();
// Tests will use this to verify the correct call count.
@ -42,7 +42,7 @@ class WC_Attribute_Functions_Test extends \WC_Unit_Test_Case {
/**
* Tear down.
*/
public function tearDown() {
public function tearDown(): void {
remove_all_filters( 'woocommerce_attribute_taxonomies' );
remove_all_filters( 'sanitize_taxonomy_name' );

View File

@ -39,7 +39,7 @@ class AbstractServiceProviderTest extends \WC_Unit_Test_Case {
/**
* Runs before each test.
*/
public function setUp() {
public function setUp(): void {
$this->container = new ExtendedContainer();
$this->sut = new class() extends AbstractServiceProvider {
@ -67,7 +67,7 @@ class AbstractServiceProviderTest extends \WC_Unit_Test_Case {
/**
* Runs before all the tests of the class.
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass(): void {
/**
* Return a new instance of ClassWithDependencies.
*

View File

@ -25,7 +25,7 @@ class ExtendedContainerTest extends \WC_Unit_Test_Case {
/**
* Runs before each test.
*/
public function setUp() {
public function setUp(): void {
$this->sut = new ExtendedContainer();
}

View File

@ -24,7 +24,7 @@ class DownloadPermissionsAdjusterTest extends \WC_Unit_Test_Case {
/**
* Runs before each test.
*/
public function setUp() {
public function setUp(): void {
$this->sut = new DownloadPermissionsAdjuster();
$this->sut->init();

View File

@ -40,7 +40,7 @@ class DataRegeneratorTest extends \WC_Unit_Test_Case {
/**
* Runs before each test.
*/
public function setUp() {
public function setUp(): void {
global $wpdb;
parent::setUp();

View File

@ -14,7 +14,7 @@ class FiltererTest extends \WC_Unit_Test_Case {
/**
* Runs before all the tests in the class.
*/
public static function setupBeforeClass() {
public static function setUpBeforeClass(): void {
global $wpdb, $wp_post_types;
parent::setUpBeforeClass();
@ -41,7 +41,7 @@ class FiltererTest extends \WC_Unit_Test_Case {
/**
* Runs after each test.
*/
public function tearDown() {
public function tearDown(): void {
global $wpdb;
parent::tearDown();

Some files were not shown because too many files have changed in this diff Show More