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

@@ -4,8 +4,8 @@
* @group taxonomy
*/
class Tests_Term_Cache extends WP_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
wp_cache_delete( 'last_changed', 'terms' );
}

View File

@@ -4,8 +4,8 @@
* @group taxonomy
*/
class Tests_Term_GetEditTermLink extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
register_taxonomy( 'wptests_tax', 'post' );
}

View File

@@ -4,8 +4,8 @@
* @group taxonomy
*/
class Tests_Term_GetTerm extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
register_taxonomy( 'wptests_tax', 'post' );
}

View File

@@ -7,8 +7,8 @@ class Tests_Term_getTermField extends WP_UnitTestCase {
public $taxonomy = 'wptests_tax';
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
register_taxonomy( $this->taxonomy, 'post' );
}

View File

@@ -5,8 +5,8 @@
*/
class Tests_Term_GetTermLink extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
register_taxonomy( 'wptests_tax', 'post' );
}

View File

@@ -24,8 +24,8 @@ class Tests_Terms_GetTermsParentsList extends WP_UnitTestCase {
wp_delete_term( self::$c2->term_id, 'wptests_tax' );
}
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
register_taxonomy( 'wptests_tax', 'post', array( 'hierarchical' => true ) );
}

View File

@@ -4,8 +4,8 @@
* @group taxonomy
*/
class Tests_Term_getTerms extends WP_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
_clean_term_filters();
wp_cache_delete( 'last_changed', 'terms' );

View File

@@ -13,8 +13,8 @@ class Tests_Term_Meta extends WP_UnitTestCase {
'args' => array(),
);
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
register_taxonomy( 'wptests_tax', 'post' );
}

View File

@@ -12,8 +12,8 @@ class Tests_Term_Slashes extends WP_Ajax_UnitTestCase {
self::$author_id = $factory->user->create( array( 'role' => 'administrator' ) );
}
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
wp_set_current_user( self::$author_id );

View File

@@ -19,10 +19,10 @@ class Tests_Term_SplitSharedTerm extends WP_UnitTestCase {
* 'wptests_tax_2' taxonomy. This term is a child of t2, and is used to test parent/child relationships
* after term splitting.
*/
public function setUp() {
public function set_up() {
global $wpdb;
parent::setUp();
parent::set_up();
register_taxonomy( 'wptests_tax', 'post' );
register_taxonomy(

View File

@@ -6,8 +6,8 @@
class Tests_Term_Tax_Query extends WP_UnitTestCase {
protected $q;
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
unset( $this->q );
$this->q = new WP_Query();
}

View File

@@ -62,8 +62,8 @@ class Tests_Term_termCount extends WP_UnitTestCase {
self::$tag_ids = $factory->term->create_many( 5 );
}
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
self::register_taxonomies();
}

View File

@@ -7,8 +7,8 @@
class Tests_Term_WpGetObjectTerms extends WP_UnitTestCase {
private $taxonomy = 'wptests_tax';
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
register_taxonomy( 'wptests_tax', 'post' );
}

View File

@@ -4,8 +4,8 @@
* @group taxonomy
*/
class Tests_Term_WpInsertTerm extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
_clean_term_filters();
// Insert one term into every post taxonomy.

View File

@@ -6,8 +6,8 @@
class Tests_Term_WpTerm extends WP_UnitTestCase {
protected static $term_id;
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
register_taxonomy( 'wptests_tax', 'post' );
}

View File

@@ -4,8 +4,8 @@
* @group taxonomy
*/
class Tests_Term_WpUniqueTermSlug extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
register_taxonomy( 'wptests_tax1', 'post', array( 'hierarchical' => false ) );
register_taxonomy( 'wptests_tax2', 'post', array( 'hierarchical' => true ) );
}