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

View File

@@ -24,8 +24,8 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
/**
* Set up.
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
@@ -172,9 +172,9 @@ class Test_WP_Customize_Control extends WP_UnitTestCase {
/**
* Tear down.
*/
function tearDown() {
function tear_down() {
$this->wp_customize = null;
unset( $GLOBALS['wp_customize'] );
parent::tearDown();
parent::tear_down();
}
}

View File

@@ -27,8 +27,8 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
*
* @see WP_UnitTestCase::setup()
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$user_id = self::factory()->user->create(
@@ -54,9 +54,9 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase {
/**
* Tear down the test case.
*/
function tearDown() {
function tear_down() {
$this->setting = null;
parent::tearDown();
parent::tear_down();
}
/**

View File

@@ -53,8 +53,8 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
/**
* Set up test.
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$this->manager = $this->instantiate();
$this->undefined = new stdClass();
@@ -70,11 +70,11 @@ class Tests_WP_Customize_Manager extends WP_UnitTestCase {
/**
* Tear down test.
*/
function tearDown() {
function tear_down() {
$this->manager = null;
unset( $GLOBALS['wp_customize'] );
$_REQUEST = array();
parent::tearDown();
parent::tear_down();
}
/**

View File

@@ -18,8 +18,8 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase {
*
* @see WP_UnitTestCase::setup()
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );

View File

@@ -19,8 +19,8 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase {
*
* @see WP_UnitTestCase::setup()
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );

View File

@@ -19,8 +19,8 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase {
*
* @see WP_UnitTestCase::setup()
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
global $wp_customize;

View File

@@ -12,18 +12,18 @@ class Tests_WP_Customize_Panel extends WP_UnitTestCase {
*/
protected $manager;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
$this->manager = $GLOBALS['wp_customize'];
$this->undefined = new stdClass();
}
function tearDown() {
function tear_down() {
$this->manager = null;
unset( $GLOBALS['wp_customize'] );
parent::tearDown();
parent::tear_down();
}
/**

View File

@@ -29,8 +29,8 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
/**
* Set up.
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
$this->wp_customize = $GLOBALS['wp_customize'];
@@ -390,9 +390,9 @@ class Test_WP_Customize_Partial extends WP_UnitTestCase {
/**
* Tear down.
*/
function tearDown() {
function tear_down() {
$this->wp_customize = null;
unset( $GLOBALS['wp_customize'] );
parent::tearDown();
parent::tear_down();
}
}

View File

@@ -19,18 +19,18 @@ class Tests_WP_Customize_Section extends WP_UnitTestCase {
*/
protected $manager;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
$this->manager = $GLOBALS['wp_customize'];
$this->undefined = new stdClass();
}
function tearDown() {
function tear_down() {
$this->manager = null;
unset( $GLOBALS['wp_customize'] );
parent::tearDown();
parent::tear_down();
}
/**

View File

@@ -34,8 +34,8 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
/**
* Set up the test fixture.
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
// Define wp_doing_ajax so that wp_die() will be used instead of die().
add_filter( 'wp_doing_ajax', '__return_true' );
@@ -509,11 +509,11 @@ class Test_WP_Customize_Selective_Refresh_Ajax extends WP_UnitTestCase {
/**
* Tear down.
*/
function tearDown() {
function tear_down() {
$this->expected_partial_ids = null;
$this->wp_customize = null;
unset( $GLOBALS['wp_customize'] );
unset( $GLOBALS['wp_scripts'] );
parent::tearDown();
parent::tear_down();
}
}

View File

@@ -29,8 +29,8 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
/**
* Set up the test fixture.
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
$this->wp_customize = $GLOBALS['wp_customize'];
@@ -255,11 +255,11 @@ class Test_WP_Customize_Selective_Refresh extends WP_UnitTestCase {
/**
* Tear down.
*/
function tearDown() {
function tear_down() {
$this->wp_customize = null;
unset( $GLOBALS['wp_customize'] );
unset( $GLOBALS['wp_scripts'] );
parent::tearDown();
parent::tear_down();
}
}

View File

@@ -17,18 +17,18 @@ class Tests_WP_Customize_Setting extends WP_UnitTestCase {
*/
public $undefined;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
$GLOBALS['wp_customize'] = new WP_Customize_Manager();
$this->manager = $GLOBALS['wp_customize'];
$this->undefined = new stdClass();
}
function tearDown() {
function tear_down() {
$this->manager = null;
unset( $GLOBALS['wp_customize'] );
parent::tearDown();
parent::tear_down();
}
function test_constructor_without_args() {

View File

@@ -20,8 +20,8 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
*/
protected $backup_registered_sidebars;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
add_theme_support( 'customize-selective-refresh-widgets' );
@@ -90,12 +90,12 @@ class Tests_WP_Customize_Widgets extends WP_UnitTestCase {
parent::clean_up_global_scope();
}
function tearDown() {
function tear_down() {
$this->manager = null;
unset( $GLOBALS['wp_customize'] );
unset( $GLOBALS['wp_scripts'] );
$GLOBALS['wp_registered_sidebars'] = $this->backup_registered_sidebars;
parent::tearDown();
parent::tear_down();
}
function set_customized_post_data( $customized ) {