Build/Test Tools: Implement use of the void solution.

> PHPUnit 8.0.0 introduced a `void` return type declaration to the "fixture" methods – `setUpBeforeClass()`, `setUp()`, `tearDown()` and `tearDownAfterClass()`. As the `void` return type was not introduced until PHP 7.1, this makes it more difficult to create cross-version compatible tests when using fixtures, due to signature mismatches.
>
> The `Yoast\PHPUnitPolyfills\TestCases\TestCase` overcomes the signature mismatch by having two versions. The correct one will be loaded depending on the PHPUnit version being used.
>
> When using this TestCase, if an individual test, or another TestCase which extends this TestCase, needs to overload any of the "fixture" methods, it should do so by using a snake_case variant of the original fixture method name, i.e. `set_up_before_class()`, `set_up()`, `assert_pre_conditions()`, `assert_post_conditions()`, `tear_down()`, and `tear_down_after_class()`.
>
> The snake_case methods will automatically be called by PHPUnit.
>
> > IMPORTANT: The snake_case methods should not call the PHPUnit parent, i.e. do not use `parent::setUp()` from within an overloaded `set_up()` method. If necessary, DO call `parent::set_up()`.

Reference: https://github.com/Yoast/PHPUnit-Polyfills#testcases

This commit renames all declared fixture methods, and calls to parent versions of those fixture methods, from camelCase to snake_case.

Follow-up to [51559-51567].

Props jrf, hellofromTonya, johnbillion, netweb, dd32, pputzer, SergeyBiryukov.
See #46149.

git-svn-id: https://develop.svn.wordpress.org/trunk@51568 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2021-08-07 10:29:41 +00:00
parent cb6bf02638
commit ddb409edca
260 changed files with 726 additions and 726 deletions
@@ -11,16 +11,16 @@ if ( is_multisite() ) :
class Tests_Multisite_Dirsize_Cache extends WP_UnitTestCase {
protected $suppress = false;
function setUp() {
function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
}
function tearDown() {
function tear_down() {
global $wpdb;
$wpdb->suppress_errors( $this->suppress );
parent::tearDown();
parent::tear_down();
}
/**
@@ -10,17 +10,17 @@ if ( is_multisite() ) :
class Tests_Multisite_Get_Space_Allowed extends WP_UnitTestCase {
protected $suppress = false;
public function setUp() {
public function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
}
public function tearDown() {
public function tear_down() {
global $wpdb;
$wpdb->suppress_errors( $this->suppress );
parent::tearDown();
parent::tear_down();
}
/**
@@ -9,16 +9,16 @@ if ( is_multisite() ) :
class Tests_Multisite_Get_Space_Used extends WP_UnitTestCase {
protected $suppress = false;
function setUp() {
function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
}
function tearDown() {
function tear_down() {
global $wpdb;
$wpdb->suppress_errors( $this->suppress );
parent::tearDown();
parent::tear_down();
}
function test_get_space_used_switched_site() {
@@ -13,19 +13,19 @@ if ( is_multisite() ) :
class Tests_Multisite_Is_Upload_Space_Available extends WP_UnitTestCase {
protected $suppress = false;
public function setUp() {
public function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
update_site_option( 'upload_space_check_disabled', false );
}
public function tearDown() {
public function tear_down() {
global $wpdb;
$wpdb->suppress_errors( $this->suppress );
parent::tearDown();
parent::tear_down();
}
/**
@@ -14,21 +14,21 @@ if ( is_multisite() ) :
class Tests_Multisite_MS_Files_Rewriting extends WP_UnitTestCase {
protected $suppress = false;
function setUp() {
function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
update_site_option( 'ms_files_rewriting', 1 );
ms_upload_constants();
}
function tearDown() {
function tear_down() {
global $wpdb;
$wpdb->suppress_errors( $this->suppress );
parent::tearDown();
parent::tear_down();
}
function test_switch_upload_dir() {
+4 -4
View File
@@ -15,17 +15,17 @@ if ( is_multisite() ) :
protected static $different_network_id;
protected static $different_site_ids = array();
function setUp() {
function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
}
function tearDown() {
function tear_down() {
global $wpdb, $current_site;
$wpdb->suppress_errors( $this->suppress );
$current_site->id = 1;
parent::tearDown();
parent::tear_down();
}
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
@@ -14,16 +14,16 @@ if ( is_multisite() ) :
protected $suppress = false;
function setUp() {
function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
}
function tearDown() {
function tear_down() {
global $wpdb;
$wpdb->suppress_errors( $this->suppress );
parent::tearDown();
parent::tear_down();
}
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+4 -4
View File
@@ -17,16 +17,16 @@ if ( is_multisite() ) :
protected static $site_ids;
protected static $uninitialized_site_id;
function setUp() {
function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
}
function tearDown() {
function tear_down() {
global $wpdb;
$wpdb->suppress_errors( $this->suppress );
parent::tearDown();
parent::tear_down();
}
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
+4 -4
View File
@@ -14,16 +14,16 @@ if ( is_multisite() ) :
protected $suppress = false;
function setUp() {
function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
}
function tearDown() {
function tear_down() {
global $wpdb;
$wpdb->suppress_errors( $this->suppress );
parent::tearDown();
parent::tear_down();
}
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
@@ -13,18 +13,18 @@ if ( is_multisite() ) :
class Tests_Multisite_Upload_Is_User_Over_Quota extends WP_UnitTestCase {
protected $suppress = false;
public function setUp() {
public function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
$this->suppress = $wpdb->suppress_errors();
update_site_option( 'upload_space_check_disabled', false );
}
public function tearDown() {
public function tear_down() {
global $wpdb;
$wpdb->suppress_errors( $this->suppress );
parent::tearDown();
parent::tear_down();
}
public function test_upload_is_user_over_quota_allowed_0_used_5() {
@@ -14,8 +14,8 @@ if ( is_multisite() ) :
*/
public $table = false;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->table = _get_list_table( 'WP_MS_Sites_List_Table', array( 'screen' => 'ms-sites' ) );
}