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

@ -60,7 +60,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
/**
* Runs the routine before setting up all tests.
*/
public static function setUpBeforeClass() {
public static function set_up_before_class() {
global $wpdb;
$wpdb->suppress_errors = false;
@ -68,7 +68,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
$wpdb->db_connect();
ini_set( 'display_errors', 1 );
parent::setUpBeforeClass();
parent::set_up_before_class();
$class = get_called_class();
@ -82,8 +82,8 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
/**
* Runs the routine after all tests have been run.
*/
public static function tearDownAfterClass() {
parent::tearDownAfterClass();
public static function tear_down_after_class() {
parent::tear_down_after_class();
_delete_all_data();
self::flush_cache();
@ -100,7 +100,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
/**
* Runs the routine before each test is executed.
*/
public function setUp() {
public function set_up() {
set_time_limit( 0 );
if ( ! self::$ignore_files ) {
@ -140,7 +140,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
/**
* After a test method runs, resets any state in WordPress the test method might have changed.
*/
public function tearDown() {
public function tear_down() {
global $wpdb, $wp_query, $wp;
$wpdb->query( 'ROLLBACK' );
if ( is_multisite() ) {
@ -535,7 +535,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase {
*
* @since 4.2.0
*/
protected function assertPostConditions() {
protected function assert_post_conditions() {
$this->expectedDeprecated();
}

View File

@ -115,8 +115,8 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
'wp-privacy-erase-personal-data',
);
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
public static function set_up_before_class() {
parent::set_up_before_class();
remove_action( 'admin_init', '_maybe_update_core' );
remove_action( 'admin_init', '_maybe_update_plugins' );
@ -135,8 +135,8 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
*
* Overrides wp_die(), pretends to be Ajax, and suppresses E_WARNINGs.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
add_filter( 'wp_doing_ajax', '__return_true' );
add_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 );
@ -156,7 +156,7 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
*
* Resets $_POST, removes the wp_die() override, restores error reporting.
*/
public function tearDown() {
public function tear_down() {
$_POST = array();
$_GET = array();
unset( $GLOBALS['post'] );
@ -165,7 +165,7 @@ abstract class WP_Ajax_UnitTestCase extends WP_UnitTestCase {
remove_action( 'clear_auth_cookie', array( $this, 'logout' ) );
error_reporting( $this->_error_level );
set_current_screen( 'front' );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -23,8 +23,8 @@ class WP_Canonical_UnitTestCase extends WP_UnitTestCase {
self::delete_shared_fixtures();
}
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
update_option( 'page_comments', true );
update_option( 'comments_per_page', 5 );

View File

@ -4,8 +4,8 @@ abstract class WP_Test_REST_Controller_Testcase extends WP_Test_REST_TestCase {
protected $server;
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
add_filter( 'rest_url', array( $this, 'filter_rest_url_for_leading_slash' ), 10, 2 );
/** @var WP_REST_Server $wp_rest_server */
global $wp_rest_server;
@ -13,12 +13,12 @@ abstract class WP_Test_REST_Controller_Testcase extends WP_Test_REST_TestCase {
do_action( 'rest_api_init', $wp_rest_server );
}
public function tearDown() {
public function tear_down() {
remove_filter( 'rest_url', array( $this, 'test_rest_url_for_leading_slash' ), 10, 2 );
/** @var WP_REST_Server $wp_rest_server */
global $wp_rest_server;
$wp_rest_server = null;
parent::tearDown();
parent::tear_down();
}
abstract public function test_register_routes();

View File

@ -6,20 +6,20 @@ require_once ABSPATH . WPINC . '/class-wp-xmlrpc-server.php';
class WP_XMLRPC_UnitTestCase extends WP_UnitTestCase {
protected $myxmlrpcserver;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
add_filter( 'pre_option_enable_xmlrpc', '__return_true' );
$this->myxmlrpcserver = new wp_xmlrpc_server();
}
function tearDown() {
function tear_down() {
remove_filter( 'pre_option_enable_xmlrpc', '__return_true' );
$this->remove_added_uploads();
parent::tearDown();
parent::tear_down();
}
protected static function make_user_by_role( $role ) {

View File

@ -31,8 +31,8 @@ class Test_WP_Community_Events extends WP_UnitTestCase {
*
* @since 4.8.0
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
require_once ABSPATH . 'wp-admin/includes/class-wp-community-events.php';

View File

@ -14,8 +14,8 @@ class Tests_Admin_includesListTable extends WP_UnitTestCase {
*/
protected $table;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->table = _get_list_table( 'WP_Posts_List_Table', array( 'screen' => 'edit-page' ) );
}

View File

@ -155,9 +155,9 @@ class Tests_Admin_includesScreen extends WP_UnitTestCase {
),
);
function tearDown() {
function tear_down() {
unset( $GLOBALS['wp_taxonomies']['old-or-new'] );
parent::tearDown();
parent::tear_down();
}
function test_set_current_screen_with_hook_suffix() {

View File

@ -4,8 +4,8 @@
*/
class Tests_Admin_includesTheme extends WP_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->theme_root = DIR_TESTDATA . '/themedir1';
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
@ -20,7 +20,7 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
unset( $GLOBALS['wp_themes'] );
}
function tearDown() {
function tear_down() {
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
remove_filter( 'theme_root', array( $this, '_theme_root' ) );
remove_filter( 'stylesheet_root', array( $this, '_theme_root' ) );
@ -28,7 +28,7 @@ class Tests_Admin_includesTheme extends WP_UnitTestCase {
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );
parent::tearDown();
parent::tear_down();
}
// Replace the normal theme root directory with our premade test directory.

View File

@ -14,8 +14,8 @@ class Tests_AdminBar extends WP_UnitTestCase {
protected static $user_ids = array();
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
public static function set_up_before_class() {
parent::set_up_before_class();
require_once ABSPATH . WPINC . '/class-wp-admin-bar.php';
}

View File

@ -50,17 +50,17 @@ class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
/**
* Set up the test fixture.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
}
/**
* Tear down.
*/
public function tearDown() {
public function tear_down() {
$_REQUEST = array();
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -49,8 +49,8 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
/**
* Set up the test fixture.
*/
public function setUp() {
parent::setUp();
public 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

@ -25,8 +25,8 @@ class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase {
/**
* Sets up the test fixture.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$post_id = self::factory()->post->create();
$this->_comments = self::factory()->comment->create_post_comments( $post_id, 15 );
$this->_comments = array_map( 'get_comment', $this->_comments );

View File

@ -25,8 +25,8 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase {
/**
* Sets up the test fixture.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$post_id = self::factory()->post->create();
self::factory()->comment->create_post_comments( $post_id, 5 );
$this->_comment_post = get_post( $post_id );

View File

@ -13,8 +13,8 @@ class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase {
private $orig_theme_dir;
private $theme_root;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->theme_root = DIR_TESTDATA . '/themedir1';
$this->orig_theme_dir = $GLOBALS['wp_theme_directories'];
@ -30,7 +30,7 @@ class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase {
unset( $GLOBALS['wp_themes'] );
}
function tearDown() {
function tear_down() {
$GLOBALS['wp_theme_directories'] = $this->orig_theme_dir;
remove_filter( 'theme_root', array( $this, 'filter_theme_root' ) );
remove_filter( 'stylesheet_root', array( $this, 'filter_theme_root' ) );
@ -38,7 +38,7 @@ class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase {
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -19,10 +19,10 @@ class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase {
/**
* Tear down the test fixture.
*/
public function tearDown() {
public function tear_down() {
// Cleanup.
$this->remove_added_uploads();
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -126,8 +126,8 @@ class Tests_Ajax_PrivacyErasePersonalData extends WP_Ajax_UnitTestCase {
/**
* Register a custom personal data eraser.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->key_to_unset = '';
@ -149,7 +149,7 @@ class Tests_Ajax_PrivacyErasePersonalData extends WP_Ajax_UnitTestCase {
/**
* Clean up after each test method.
*/
public function tearDown() {
public function tear_down() {
remove_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_custom_personal_data_eraser' ) );
$this->new_callback_value = '';
@ -157,7 +157,7 @@ class Tests_Ajax_PrivacyErasePersonalData extends WP_Ajax_UnitTestCase {
revoke_super_admin( get_current_user_id() );
}
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -140,8 +140,8 @@ class Tests_Ajax_PrivacyExportPersonalData extends WP_Ajax_UnitTestCase {
*
* @since 5.2.0
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->key_to_unset = '';
$this->new_callback_value = '';
@ -163,13 +163,13 @@ class Tests_Ajax_PrivacyExportPersonalData extends WP_Ajax_UnitTestCase {
/**
* Clean up after each test method.
*/
public function tearDown() {
public function tear_down() {
remove_filter( 'wp_privacy_personal_data_exporters', array( $this, 'filter_register_custom_personal_data_exporter' ) );
if ( is_multisite() ) {
revoke_super_admin( get_current_user_id() );
}
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -37,9 +37,9 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase {
self::$draft_post = $factory->post->create_and_get( array( 'post_status' => 'draft' ) );
}
public function tearDown() {
public function tear_down() {
remove_filter( 'query', array( $this, '_block_comments' ) );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -20,8 +20,8 @@ class Tests_Ajax_Response extends WP_UnitTestCase {
* Set up the test fixture.
* Override wp_die(), pretend to be ajax, and suppres E_WARNINGs
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
add_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 );
add_filter( 'wp_doing_ajax', '__return_true' );
@ -35,10 +35,10 @@ class Tests_Ajax_Response extends WP_UnitTestCase {
* Tear down the test fixture.
* Remove the wp_die() override, restore error reporting
*/
public function tearDown() {
public function tear_down() {
remove_filter( 'wp_die_ajax_handler', array( $this, 'getDieHandler' ), 1, 1 );
error_reporting( $this->_error_level );
parent::tearDown();
parent::tear_down();
}
/**

View File

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

View File

@ -32,8 +32,8 @@ class Tests_Auth extends WP_UnitTestCase {
self::$wp_hasher = new PasswordHash( 8, true );
}
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->user = clone self::$_user;
wp_set_current_user( self::$user_id );
@ -42,11 +42,11 @@ class Tests_Auth extends WP_UnitTestCase {
unset( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $GLOBALS['wp_rest_application_password_status'], $GLOBALS['wp_rest_application_password_uuid'] );
}
public function tearDown() {
public function tear_down() {
// Cleanup all the global state.
unset( $_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'], $GLOBALS['wp_rest_application_password_status'], $GLOBALS['wp_rest_application_password_uuid'] );
parent::tearDown();
parent::tear_down();
}
function test_auth_cookie_valid() {

View File

@ -35,7 +35,7 @@ class Block_Template_Test extends WP_UnitTestCase {
wp_delete_post( self::$post->ID );
}
public function tearDown() {
public function tear_down() {
global $_wp_current_template_content;
unset( $_wp_current_template_content );
}

View File

@ -26,10 +26,10 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
/**
* Sets up each test method.
*/
public function setUp() {
public function set_up() {
global $post;
parent::setUp();
parent::set_up();
$args = array(
'post_content' => 'example',
@ -43,13 +43,13 @@ class Tests_Blocks_Context extends WP_UnitTestCase {
/**
* Tear down each test method.
*/
public function tearDown() {
public function tear_down() {
while ( ! empty( $this->registered_block_names ) ) {
$block_name = array_pop( $this->registered_block_names );
unregister_block_type( $block_name );
}
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -19,10 +19,10 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
/**
* Sets up each test method.
*/
public function setUp() {
public function set_up() {
global $post;
parent::setUp();
parent::set_up();
$args = array(
'post_title' => 'Example',
@ -35,11 +35,11 @@ class Tests_Blocks_Editor extends WP_UnitTestCase {
do_action( 'rest_api_init', $wp_rest_server );
}
public function tearDown() {
public function tear_down() {
/** @var WP_REST_Server $wp_rest_server */
global $wp_rest_server;
$wp_rest_server = null;
parent::tearDown();
parent::tear_down();
}
function filter_set_block_categories_post( $block_categories, $post ) {

View File

@ -57,7 +57,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
*
* @since 5.0.0
*/
function tearDown() {
function tear_down() {
$registry = WP_Block_Type_Registry::get_instance();
foreach ( array( 'core/test-static', 'core/test-dynamic', 'tests/notice' ) as $block_name ) {
@ -66,7 +66,7 @@ class Tests_Blocks_Register extends WP_UnitTestCase {
}
}
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -37,7 +37,7 @@ class Tests_Blocks_Render extends WP_UnitTestCase {
*
* @since 5.0.0
*/
public function tearDown() {
public function tear_down() {
$this->test_block_instance_number = 0;
$registry = WP_Block_Type_Registry::get_instance();
@ -48,7 +48,7 @@ class Tests_Blocks_Render extends WP_UnitTestCase {
$registry->unregister( 'core/dynamic' );
}
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -39,13 +39,13 @@ class Tests_Blocks_SupportedStyles extends WP_UnitTestCase {
/**
* Tear down each test method.
*/
public function tearDown() {
public function tear_down() {
while ( ! empty( $this->registered_block_names ) ) {
$block_name = array_pop( $this->registered_block_names );
unregister_block_type( $block_name );
}
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -26,8 +26,8 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
/**
* Set up each test method.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->registry = new WP_Block_Type_Registry();
}
@ -35,10 +35,10 @@ class Tests_Blocks_wpBlock extends WP_UnitTestCase {
/**
* Tear down each test method.
*/
public function tearDown() {
public function tear_down() {
$this->registry = null;
parent::tearDown();
parent::tear_down();
}
function filter_render_block( $content, $parsed_block ) {

View File

@ -26,8 +26,8 @@ class Tests_Blocks_wpBlockList extends WP_UnitTestCase {
/**
* Set up each test method.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->registry = new WP_Block_Type_Registry();
$this->registry->register( 'core/example', array() );
@ -36,10 +36,10 @@ class Tests_Blocks_wpBlockList extends WP_UnitTestCase {
/**
* Tear down each test method.
*/
public function tearDown() {
public function tear_down() {
$this->registry = null;
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -29,8 +29,8 @@ class Tests_Blocks_wpBlockTypeRegistry extends WP_UnitTestCase {
*
* @since 5.0.0
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->registry = new WP_Block_Type_Registry();
}
@ -40,10 +40,10 @@ class Tests_Blocks_wpBlockTypeRegistry extends WP_UnitTestCase {
*
* @since 5.0.0
*/
public function tearDown() {
public function tear_down() {
$this->registry = null;
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -33,9 +33,9 @@ class Tests_Bookmark_GetBookmark extends WP_UnitTestCase {
/**
* Reset globals after each test.
*/
public function tearDown() {
public function tear_down() {
unset( $GLOBALS['link'] );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -6,16 +6,16 @@
class Tests_Cache extends WP_UnitTestCase {
public $cache = null;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
// Create two cache objects with a shared cache directory.
// This simulates a typical cache situation, two separate requests interacting.
$this->cache =& $this->init_cache();
}
function tearDown() {
function tear_down() {
$this->flush_cache();
parent::tearDown();
parent::tear_down();
}
function &init_cache() {

View File

@ -10,8 +10,8 @@
*/
class Tests_Canonical extends WP_Canonical_UnitTestCase {
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
wp_set_current_user( self::$author_id );
}

View File

@ -7,8 +7,8 @@
*/
class Tests_Canonical_CustomRules extends WP_Canonical_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
global $wp_rewrite;
// Add a custom Rewrite rule to test category redirections.
$wp_rewrite->add_rule( 'ccr/(.+?)/sort/(asc|desc)', 'index.php?category_name=$matches[1]&order=$matches[2]', 'top' ); // ccr = Custom_Cat_Rule.

View File

@ -6,8 +6,8 @@
* @group query
*/
class Tests_Canonical_HTTPS extends WP_Canonical_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
create_initial_taxonomies();

View File

@ -11,10 +11,10 @@ class Tests_Canonical_NoRewrite extends WP_Canonical_UnitTestCase {
// These test cases are run against the test handler in WP_Canonical.
public function setUp() {
public function set_up() {
global $wp_rewrite;
parent::setUp();
parent::set_up();
$wp_rewrite->init();
$wp_rewrite->set_permalink_structure( '' );

View File

@ -7,8 +7,8 @@
*/
class Tests_Canonical_PageOnFront extends WP_Canonical_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
update_option( 'show_on_front', 'page' );
update_option(

View File

@ -166,8 +166,8 @@ class Tests_Canonical_PostStatus extends WP_Canonical_UnitTestCase {
wp_trash_post( self::$posts['trash-page']->ID );
}
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
self::setup_custom_types();
}

View File

@ -8,8 +8,8 @@
*/
class Tests_Canonical_Sitemaps extends WP_Canonical_UnitTestCase {
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$wp_sitemaps = new WP_Sitemaps();
$wp_sitemaps->init();
}

View File

@ -9,9 +9,9 @@
*/
class Tests_Category extends WP_UnitTestCase {
function tearDown() {
function tear_down() {
_unregister_taxonomy( 'test_tax_cat' );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -7,8 +7,8 @@ class Tests_Category_GetCategoryParents extends WP_UnitTestCase {
protected $c1;
protected $c2;
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->c1 = self::factory()->category->create_and_get();
$this->c2 = self::factory()->category->create_and_get(

View File

@ -13,8 +13,8 @@ class Tests_Category_Walker_Category extends WP_UnitTestCase {
/**
* Setup.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
/** Walker_Category class */
require_once ABSPATH . 'wp-includes/class-walker-category.php';

View File

@ -34,8 +34,8 @@ class Tests_Comment_Submission extends WP_UnitTestCase {
self::delete_user( self::$editor_id );
}
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
require_once ABSPATH . WPINC . '/class-phpass.php';
}

View File

@ -8,8 +8,8 @@ class Tests_Comment extends WP_UnitTestCase {
protected static $post_id;
protected static $notify_message = '';
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
reset_phpmailer_instance();
}

View File

@ -17,8 +17,8 @@ class Tests_Comment_DateQuery extends WP_UnitTestCase {
public $posts = array();
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
// Just some dummy posts to use as parents for comments.
for ( $i = 1; $i <= 2; $i++ ) {

View File

@ -5,8 +5,8 @@
class Tests_Comment_GetCommentAuthorEmailLink extends WP_UnitTestCase {
public static $comment;
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
// Fake the 'comment' global.
$GLOBALS['comment'] = self::$comment;
@ -15,9 +15,9 @@ class Tests_Comment_GetCommentAuthorEmailLink extends WP_UnitTestCase {
remove_filter( 'comment_email', 'antispambot' );
}
public function tearDown() {
public function tear_down() {
unset( $GLOBALS['comment'] );
parent::tearDown();
parent::tear_down();
}
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {

View File

@ -13,8 +13,8 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
/**
* setUp options
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->option_page_comments = get_option( 'page_comments' );
$this->option_page_comments = get_option( 'comments_per_page' );
$this->option_page_comments = get_option( 'thread_comments' );
@ -26,12 +26,12 @@ class Tests_Comment_GetCommentsPagesCount extends WP_UnitTestCase {
/**
* tearDown options
*/
function tearDown() {
function tear_down() {
update_option( 'page_comments', $this->option_page_comments );
update_option( 'comments_per_page', $this->option_page_comments );
update_option( 'thread_comments', $this->option_page_comments );
update_option( 'posts_per_rss', $this->option_posts_per_rss );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -15,8 +15,8 @@ class Tests_Comment_Slashes extends WP_UnitTestCase {
self::$post_id = $factory->post->create();
}
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
wp_set_current_user( self::$author_id );

View File

@ -5,8 +5,8 @@
*/
class Tests_Comment_Walker extends WP_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->post_id = self::factory()->post->create();
}

View File

@ -16,18 +16,18 @@ class Tests_Cron extends WP_UnitTestCase {
*/
private $plus_thirty_minutes;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
// Make sure the schedule is clear.
_set_cron_array( array() );
$this->preflight_cron_array = array();
$this->plus_thirty_minutes = strtotime( '+30 minutes' );
}
function tearDown() {
function tear_down() {
// Make sure the schedule is clear.
_set_cron_array( array() );
parent::tearDown();
parent::tear_down();
}
function test_wp_get_schedule_empty() {

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 ) {

View File

@ -8,14 +8,14 @@
*/
class Tests_Date_GetFeedBuildDate extends WP_UnitTestCase {
function tearDown() {
function tear_down() {
global $wp_query;
update_option( 'timezone_string', 'UTC' );
unset( $wp_query );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -8,13 +8,13 @@
*/
class Tests_Date_GetPermalink extends WP_UnitTestCase {
function tearDown() {
function tear_down() {
delete_option( 'permalink_structure' );
update_option( 'timezone_string', 'UTC' );
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
date_default_timezone_set( 'UTC' );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -18,22 +18,22 @@ class Tests_Date_MaybeDeclineDate extends WP_UnitTestCase {
*/
private $wp_locale_original;
public function setUp() {
public function set_up() {
global $locale, $wp_locale;
parent::setUp();
parent::set_up();
$this->locale_original = $locale;
$this->wp_locale_original = clone $wp_locale;
}
public function tearDown() {
public function tear_down() {
global $locale, $wp_locale;
$locale = $this->locale_original;
$wp_locale = $this->wp_locale_original;
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -7,11 +7,11 @@
*/
class Tests_Date_mysql2date extends WP_UnitTestCase {
function tearDown() {
function tear_down() {
// phpcs:ignore WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set
date_default_timezone_set( 'UTC' );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -15,8 +15,8 @@ class Tests_Date_Query extends WP_UnitTestCase {
*/
public $q;
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
unset( $this->q );
$this->q = new WP_Date_Query( array( 'm' => 2 ) );
}

View File

@ -10,20 +10,20 @@ class Tests_Date_wpDate extends WP_UnitTestCase {
/** @var WP_Locale */
private $wp_locale_original;
public function setUp() {
public function set_up() {
global $wp_locale;
parent::setUp();
parent::set_up();
$this->wp_locale_original = clone $wp_locale;
}
public function tearDown() {
public function tear_down() {
global $wp_locale;
$wp_locale = $this->wp_locale_original;
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -21,16 +21,16 @@ class Tests_DB extends WP_UnitTestCase {
*/
protected static $_wpdb;
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
public static function set_up_before_class() {
parent::set_up_before_class();
self::$_wpdb = new WpdbExposedMethodsForTesting();
}
/**
* Set up the test fixture
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->_queries = array();
add_filter( 'query', array( $this, 'query_filter' ) );
}

View File

@ -22,8 +22,8 @@ class Tests_DB_Charset extends WP_UnitTestCase {
*/
private static $server_info;
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
public static function set_up_before_class() {
parent::set_up_before_class();
require_once dirname( __DIR__ ) . '/db.php';

View File

@ -32,9 +32,9 @@ class Tests_dbDelta extends WP_UnitTestCase {
/**
* Make sure the upgrade code is loaded before the tests are run.
*/
public static function setUpBeforeClass() {
public static function set_up_before_class() {
parent::setUpBeforeClass();
parent::set_up_before_class();
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
}
@ -42,7 +42,7 @@ class Tests_dbDelta extends WP_UnitTestCase {
/**
* Create a custom table to be used in each test.
*/
public function setUp() {
public function set_up() {
global $wpdb;
@ -81,17 +81,17 @@ class Tests_dbDelta extends WP_UnitTestCase {
// This has to be called after the `CREATE TABLE` above as the `_create_temporary_tables` filter
// causes it to create a temporary table, and a temporary table cannot use a FULLTEXT index.
parent::setUp();
parent::set_up();
}
/**
* Delete the custom table on teardown.
*/
public function tearDown() {
public function tear_down() {
global $wpdb;
parent::tearDown();
parent::tear_down();
// This has to be called after the parent `tearDown()` method.
$wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}dbdelta_test" );

View File

@ -14,8 +14,8 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase {
protected $wp_scripts_print_translations_output;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->old_wp_scripts = isset( $GLOBALS['wp_scripts'] ) ? $GLOBALS['wp_scripts'] : null;
remove_action( 'wp_default_scripts', 'wp_default_scripts' );
remove_action( 'wp_default_scripts', 'wp_default_packages' );
@ -34,10 +34,10 @@ JS;
$this->wp_scripts_print_translations_output .= "\n";
}
function tearDown() {
function tear_down() {
$GLOBALS['wp_scripts'] = $this->old_wp_scripts;
add_action( 'wp_default_scripts', 'wp_default_scripts' );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -12,8 +12,8 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
private $old_wp_styles;
private $old_wp_scripts;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
if ( empty( $GLOBALS['wp_styles'] ) ) {
$GLOBALS['wp_styles'] = null;
@ -37,7 +37,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
$GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' );
}
function tearDown() {
function tear_down() {
$GLOBALS['wp_styles'] = $this->old_wp_styles;
$GLOBALS['wp_scripts'] = $this->old_wp_scripts;
@ -48,7 +48,7 @@ class Tests_Dependencies_Styles extends WP_UnitTestCase {
remove_theme_support( 'wp-block-styles' );
}
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -56,8 +56,8 @@ class Tests_Feeds_Atom extends WP_UnitTestCase {
/**
* Setup.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->post_count = (int) get_option( 'posts_per_rss' );
$this->excerpt_only = get_option( 'rss_use_excerpt' );

View File

@ -63,8 +63,8 @@ class Tests_Feeds_RSS2 extends WP_UnitTestCase {
/**
* Setup.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->post_count = (int) get_option( 'posts_per_rss' );
$this->excerpt_only = get_option( 'rss_use_excerpt' );

View File

@ -16,8 +16,8 @@
* @since 5.6.1
*/
class Tests_WP_SimplePie_File extends WP_UnitTestCase {
public static function setUpBeforeClass() {
parent::setUpBeforeClass();
public static function set_up_before_class() {
parent::set_up_before_class();
require_once ABSPATH . '/wp-includes/class-simplepie.php';
require_once ABSPATH . '/wp-includes/class-wp-simplepie-file.php';

View File

@ -5,8 +5,8 @@
*/
class Tests_File extends WP_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->dir = untrailingslashit( get_temp_dir() );

View File

@ -4,20 +4,20 @@
* This class is designed to make use of MockFS, a Virtual in-memory filesystem compatible with WP_Filesystem
*/
abstract class WP_Filesystem_UnitTestCase extends WP_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
add_filter( 'filesystem_method_file', array( $this, 'filter_abstraction_file' ) );
add_filter( 'filesystem_method', array( $this, 'filter_fs_method' ) );
WP_Filesystem();
}
function tearDown() {
function tear_down() {
global $wp_filesystem;
remove_filter( 'filesystem_method_file', array( $this, 'filter_abstraction_file' ) );
remove_filter( 'filesystem_method', array( $this, 'filter_fs_method' ) );
unset( $wp_filesystem );
parent::tearDown();
parent::tear_down();
}
function filter_fs_method( $method ) {

View File

@ -59,8 +59,8 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase {
*
* @since 5.2.0
*/
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
self::$post_id = $this->factory()->post->create(
array(
'post_excerpt' => '', // Empty excerpt, so it has to be generated.
@ -80,11 +80,11 @@ class Tests_Formatting_ExcerptRemoveBlocks extends WP_UnitTestCase {
*
* @since 5.2.0
*/
function tearDown() {
function tear_down() {
$registry = WP_Block_Type_Registry::get_instance();
$registry->unregister( 'core/fake' );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -6,8 +6,8 @@
* @group redirect
*/
class Tests_Formatting_Redirect extends WP_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
add_filter( 'home_url', array( $this, 'home_url' ) );
}

View File

@ -37,8 +37,8 @@ class Tests_Functions_Deprecated extends WP_UnitTestCase {
/**
* Sets up the test fixture.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->_deprecated_functions = array();
$this->_deprecated_arguments = array();
$this->_deprecated_files = array();
@ -53,14 +53,14 @@ class Tests_Functions_Deprecated extends WP_UnitTestCase {
/**
* Tears down the test fixture.
*/
public function tearDown() {
public function tear_down() {
remove_action( 'deprecated_function_run', array( $this, 'deprecated_function' ), 10, 3 );
remove_action( 'deprecated_function_trigger_error', '__return_false' );
remove_action( 'deprecated_argument_run', array( $this, 'deprecated_argument' ), 10, 3 );
remove_action( 'deprecated_argument_trigger_error', '__return_false' );
remove_action( 'deprecated_file_included', array( $this, 'deprecated_argument' ), 10, 4 );
remove_action( 'deprecated_file_trigger_error', '__return_false' );
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -23,8 +23,8 @@ class Tests_Functions_DoEnclose extends WP_UnitTestCase {
*
* @since 5.3.0
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
add_filter( 'pre_http_request', array( $this, 'fake_http_request' ), 10, 3 );
}

View File

@ -21,17 +21,17 @@ class Tests_Functions_PluginBasename extends WP_UnitTestCase {
*/
protected $wp_plugin_path;
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->wp_plugin_paths_backup = $GLOBALS['wp_plugin_paths'];
$this->wp_plugin_path = wp_normalize_path( WP_PLUGIN_DIR );
}
public function tearDown() {
public function tear_down() {
$GLOBALS['wp_plugin_paths'] = $this->wp_plugin_paths_backup;
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -9,20 +9,20 @@
*/
class Tests_Functions_Referer extends WP_UnitTestCase {
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$_SERVER['HTTP_REFERER'] = '';
$_SERVER['REQUEST_URI'] = '';
$_REQUEST['_wp_http_referer'] = '';
}
public function tearDown() {
public function tear_down() {
$_SERVER['HTTP_REFERER'] = '';
$_SERVER['REQUEST_URI'] = '';
$_REQUEST['_wp_http_referer'] = '';
parent::tearDown();
parent::tear_down();
}
public function _fake_subfolder_install() {

View File

@ -9,8 +9,8 @@ class Tests_Functions_wpGetArchives extends WP_UnitTestCase {
protected $month_url;
protected $year_url;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->month_url = get_month_link( gmdate( 'Y' ), gmdate( 'm' ) );
$this->year_url = get_year_link( gmdate( 'Y' ) );

View File

@ -11,8 +11,8 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase {
public $object_list = array();
public $array_list = array();
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->array_list['foo'] = array(
'name' => 'foo',
'id' => 'f',

View File

@ -9,8 +9,8 @@ class Tests_General_PaginateLinks extends WP_UnitTestCase {
private $i18n_count = 0;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->go_to( home_url( '/' ) );
}

View File

@ -17,19 +17,19 @@ class Tests_General_Template extends WP_UnitTestCase {
public $custom_logo_id;
public $custom_logo_url;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->wp_site_icon = new WP_Site_Icon();
}
function tearDown() {
function tear_down() {
global $wp_customize;
$this->_remove_custom_logo();
$this->_remove_site_icon();
$wp_customize = null;
parent::tearDown();
parent::tear_down();
}
/**

View File

@ -20,8 +20,8 @@ class Tests_General_wpError extends WP_UnitTestCase {
/**
* Set up.
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->wp_error = new WP_Error();
}

View File

@ -6,8 +6,8 @@
* @covers ::wp_get_archives
*/
class Tests_General_wpGetArchives extends WP_UnitTestCase {
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
wp_cache_delete( 'last_changed', 'posts' );
}

View File

@ -43,8 +43,8 @@ class Tests_General_wpGetDocumentTitle extends WP_UnitTestCase {
);
}
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
add_action( 'after_setup_theme', array( $this, '_add_title_tag_support' ) );

View File

@ -10,8 +10,8 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase {
private $old_wp_scripts;
private $old_wp_styles;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$this->old_wp_scripts = isset( $GLOBALS['wp_scripts'] ) ? $GLOBALS['wp_scripts'] : null;
$this->old_wp_styles = isset( $GLOBALS['wp_styles'] ) ? $GLOBALS['wp_styles'] : null;
@ -24,10 +24,10 @@ class Tests_General_wpResourceHints extends WP_UnitTestCase {
$GLOBALS['wp_styles']->default_version = get_bloginfo( 'version' );
}
function tearDown() {
function tear_down() {
$GLOBALS['wp_scripts'] = $this->old_wp_scripts;
$GLOBALS['wp_styles'] = $this->old_wp_styles;
parent::tearDown();
parent::tear_down();
}
function test_should_have_defaults_on_frontend() {

View File

@ -11,8 +11,8 @@ class Tests_Hooks_DoAction extends WP_UnitTestCase {
private $action_output = '';
private $hook;
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
$this->events = array();
}

View File

@ -17,8 +17,8 @@ abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase {
protected $http_request_args;
function setUp() {
parent::setUp();
function set_up() {
parent::set_up();
$class = 'WP_Http_' . ucfirst( $this->transport );
if ( ! call_user_func( array( $class, 'test' ) ) ) {

View File

@ -9,8 +9,8 @@ class Tests_HTTP_wpGetHttpHeaders extends WP_UnitTestCase {
/**
* Set up the environment
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
// Hook a fake HTTP request response.
add_filter( 'pre_http_request', array( $this, 'fake_http_request' ), 10, 3 );

View File

@ -7,8 +7,8 @@ class Tests_HTTPS_Detection extends WP_UnitTestCase {
private $last_request_url;
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
remove_all_filters( 'option_home' );
remove_all_filters( 'option_siteurl' );

View File

@ -8,8 +8,8 @@ abstract class WP_Image_UnitTestCase extends WP_UnitTestCase {
/**
* Set the image editor engine according to the unit test's specification
*/
public function setUp() {
parent::setUp();
public function set_up() {
parent::set_up();
if ( ! call_user_func( array( $this->editor_engine, 'test' ) ) ) {
$this->markTestSkipped( sprintf( 'The image editor engine %s is not supported on this system.', $this->editor_engine ) );

View File

@ -14,13 +14,13 @@ class Tests_Image_Editor extends WP_Image_UnitTestCase {
/**
* Setup test fixture
*/
public function setUp() {
public function set_up() {
require_once ABSPATH . WPINC . '/class-wp-image-editor.php';
require_once DIR_TESTDATA . '/../includes/mock-image-editor.php';
// This needs to come after the mock image editor class is loaded.
parent::setUp();
parent::set_up();
}
/**

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