From e385beb7478d1e193be2a9f7622dae052af58e98 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 22 Nov 2022 21:25:27 +0000 Subject: [PATCH] Tests: Correct references to `set_up()` and `tear_down()` in various DocBlocks. The `setUp()` and `tearDown()` methods were renamed to `set_up()` and `tear_down()`, respectively, as part of implementing the `void` return type solution for PHPUnit 8.0. Follow-up to [29120], [29251], [30277], [32173], [32806], [38829], [42379], [50450], [51276], [51568]. See #56793. git-svn-id: https://develop.svn.wordpress.org/trunk@54865 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/includes/abstract-testcase.php | 15 ++++++++------- tests/phpunit/includes/testcase-canonical.php | 4 ++-- .../tests/customize/custom-css-setting.php | 2 +- .../tests/customize/nav-menu-item-setting.php | 2 +- .../phpunit/tests/customize/nav-menu-setting.php | 2 +- tests/phpunit/tests/customize/nav-menus.php | 2 +- tests/phpunit/tests/db/dbDelta.php | 2 +- tests/phpunit/tests/query/postStatus.php | 2 +- tests/phpunit/tests/user/capabilities.php | 2 +- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/tests/phpunit/includes/abstract-testcase.php b/tests/phpunit/includes/abstract-testcase.php index 38f846e541..6cfeaa307c 100644 --- a/tests/phpunit/includes/abstract-testcase.php +++ b/tests/phpunit/includes/abstract-testcase.php @@ -322,7 +322,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase { * Saves the action and filter-related globals so they can be restored later. * * Stores $wp_actions, $wp_current_filter, and $wp_filter on a class variable - * so they can be restored on tearDown() using _restore_hooks(). + * so they can be restored on tear_down() using _restore_hooks(). * * @global array $wp_actions * @global array $wp_current_filter @@ -340,7 +340,7 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase { } /** - * Restores the hook-related globals to their state at setUp() + * Restores the hook-related globals to their state at set_up() * so that future tests aren't affected by hooks set during this last test. * * @global array $wp_actions @@ -1365,11 +1365,12 @@ abstract class WP_UnitTestCase_Base extends PHPUnit_Adapter_TestCase { /** * Deletes files added to the `uploads` directory during tests. * - * This method works in tandem with the `setUp()` and `rmdir()` methods: - * - `setUp()` scans the `uploads` directory before every test, and stores its contents inside of the - * `$ignore_files` property. - * - `rmdir()` and its helper methods only delete files that are not listed in the `$ignore_files` property. If - * called during `tearDown()` in tests, this will only delete files added during the previously run test. + * This method works in tandem with the `set_up()` and `rmdir()` methods: + * - `set_up()` scans the `uploads` directory before every test, and stores + * its contents inside of the `$ignore_files` property. + * - `rmdir()` and its helper methods only delete files that are not listed + * in the `$ignore_files` property. If called during `tear_down()` in tests, + * this will only delete files added during the previously run test. */ public function remove_added_uploads() { $uploads = wp_upload_dir(); diff --git a/tests/phpunit/includes/testcase-canonical.php b/tests/phpunit/includes/testcase-canonical.php index 833df23e5b..26916fac6e 100644 --- a/tests/phpunit/includes/testcase-canonical.php +++ b/tests/phpunit/includes/testcase-canonical.php @@ -37,7 +37,7 @@ abstract class WP_Canonical_UnitTestCase extends WP_UnitTestCase { /** * Generate fixtures to be shared between canonical tests. * - * Abstracted here because it's invoked by setUpBeforeClass() in more than one class. + * Abstracted here because it's invoked by wpSetUpBeforeClass() in more than one class. * * @since 4.1.0 */ @@ -46,7 +46,7 @@ abstract class WP_Canonical_UnitTestCase extends WP_UnitTestCase { self::$author_id = $factory->user->create( array( 'user_login' => 'canonical-author' ) ); /* - * Also set in self::setUp(), but we must configure here to make sure that + * Also set in self::set_up(), but we must configure here to make sure that * post authorship is properly attributed for fixtures. */ wp_set_current_user( self::$author_id ); diff --git a/tests/phpunit/tests/customize/custom-css-setting.php b/tests/phpunit/tests/customize/custom-css-setting.php index f651b509a8..015b6308af 100644 --- a/tests/phpunit/tests/customize/custom-css-setting.php +++ b/tests/phpunit/tests/customize/custom-css-setting.php @@ -25,7 +25,7 @@ class Test_WP_Customize_Custom_CSS_Setting extends WP_UnitTestCase { /** * Set up the test case. * - * @see WP_UnitTestCase::setup() + * @see WP_UnitTestCase_Base::set_up() */ public function set_up() { parent::set_up(); diff --git a/tests/phpunit/tests/customize/nav-menu-item-setting.php b/tests/phpunit/tests/customize/nav-menu-item-setting.php index 212f871747..256e5f577c 100644 --- a/tests/phpunit/tests/customize/nav-menu-item-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-item-setting.php @@ -16,7 +16,7 @@ class Test_WP_Customize_Nav_Menu_Item_Setting extends WP_UnitTestCase { /** * Set up a test case. * - * @see WP_UnitTestCase::setup() + * @see WP_UnitTestCase_Base::set_up() */ public function set_up() { parent::set_up(); diff --git a/tests/phpunit/tests/customize/nav-menu-setting.php b/tests/phpunit/tests/customize/nav-menu-setting.php index 4a727618eb..6d50c96ee0 100644 --- a/tests/phpunit/tests/customize/nav-menu-setting.php +++ b/tests/phpunit/tests/customize/nav-menu-setting.php @@ -17,7 +17,7 @@ class Test_WP_Customize_Nav_Menu_Setting extends WP_UnitTestCase { /** * Set up a test case. * - * @see WP_UnitTestCase::setup() + * @see WP_UnitTestCase_Base::set_up() */ public function set_up() { parent::set_up(); diff --git a/tests/phpunit/tests/customize/nav-menus.php b/tests/phpunit/tests/customize/nav-menus.php index 5785558103..7b8ee43396 100644 --- a/tests/phpunit/tests/customize/nav-menus.php +++ b/tests/phpunit/tests/customize/nav-menus.php @@ -17,7 +17,7 @@ class Test_WP_Customize_Nav_Menus extends WP_UnitTestCase { /** * Set up a test case. * - * @see WP_UnitTestCase::setup() + * @see WP_UnitTestCase_Base::set_up() */ public function set_up() { parent::set_up(); diff --git a/tests/phpunit/tests/db/dbDelta.php b/tests/phpunit/tests/db/dbDelta.php index 6667f9aba3..03426fa721 100644 --- a/tests/phpunit/tests/db/dbDelta.php +++ b/tests/phpunit/tests/db/dbDelta.php @@ -99,7 +99,7 @@ class Tests_DB_dbDelta extends WP_UnitTestCase { parent::tear_down(); - // This has to be called after the parent `tearDown()` method. + // This has to be called after the parent `tear_down()` method. $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}dbdelta_test" ); } diff --git a/tests/phpunit/tests/query/postStatus.php b/tests/phpunit/tests/query/postStatus.php index 1ab8aa849d..238551b524 100644 --- a/tests/phpunit/tests/query/postStatus.php +++ b/tests/phpunit/tests/query/postStatus.php @@ -87,7 +87,7 @@ class Tests_Query_PostStatus extends WP_UnitTestCase { * Register custom post types and statuses used in multiple tests. * * CPTs and CPSs are reset between each test run so need to be registered - * in both the wpSetUpBeforeClass() and setUp() methods. + * in both the wpSetUpBeforeClass() and set_up() methods. */ public static function register_custom_post_objects() { register_post_type( diff --git a/tests/phpunit/tests/user/capabilities.php b/tests/phpunit/tests/user/capabilities.php index c7e836f6e5..4583e0155b 100644 --- a/tests/phpunit/tests/user/capabilities.php +++ b/tests/phpunit/tests/user/capabilities.php @@ -1707,7 +1707,7 @@ class Tests_User_Capabilities extends WP_UnitTestCase { } public function nullify_current_user() { - // Prevents fatal errors in ::tearDown()'s and other uses of restore_current_blog(). + // Prevents fatal errors in ::tear_down()'s and other uses of restore_current_blog(). $function_stack = wp_debug_backtrace_summary( null, 0, false ); if ( in_array( 'restore_current_blog', $function_stack, true ) ) { return;