mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-20 19:24:32 +00:00
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:
@@ -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' );
|
||||
}
|
||||
|
||||
@@ -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' );
|
||||
}
|
||||
|
||||
@@ -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' );
|
||||
}
|
||||
|
||||
|
||||
@@ -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' );
|
||||
}
|
||||
|
||||
@@ -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' );
|
||||
}
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
|
||||
|
||||
@@ -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' );
|
||||
|
||||
@@ -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' );
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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' );
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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' );
|
||||
}
|
||||
|
||||
|
||||
@@ -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 ) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user