Coding Standards: Add visibility to methods in tests/phpunit/tests/.

Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a `private` visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2021-11-04 15:22:47 +00:00
parent 80380cd374
commit 40ac5de838
327 changed files with 3656 additions and 3969 deletions
+28 -28
View File
@@ -10,7 +10,7 @@ class Tests_Actions extends WP_UnitTestCase {
/**
* @covers ::do_action
*/
function test_simple_action() {
public function test_simple_action() {
$a = new MockAction();
$tag = __FUNCTION__;
@@ -30,7 +30,7 @@ class Tests_Actions extends WP_UnitTestCase {
/**
* @covers ::remove_action
*/
function test_remove_action() {
public function test_remove_action() {
$a = new MockAction();
$tag = __FUNCTION__;
@@ -52,7 +52,7 @@ class Tests_Actions extends WP_UnitTestCase {
/**
* @covers ::has_action
*/
function test_has_action() {
public function test_has_action() {
$tag = __FUNCTION__;
$func = __FUNCTION__ . '_func';
@@ -71,7 +71,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::do_action
*/
function test_multiple_actions() {
public function test_multiple_actions() {
$a1 = new MockAction();
$a2 = new MockAction();
$tag = __FUNCTION__;
@@ -92,7 +92,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::do_action
*/
function test_action_args_1() {
public function test_action_args_1() {
$a = new MockAction();
$tag = __FUNCTION__;
$val = __FUNCTION__ . '_val';
@@ -112,7 +112,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::do_action
*/
function test_action_args_2() {
public function test_action_args_2() {
$a1 = new MockAction();
$a2 = new MockAction();
$tag = __FUNCTION__;
@@ -146,7 +146,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::do_action
*/
function test_action_args_3() {
public function test_action_args_3() {
$a1 = new MockAction();
$a2 = new MockAction();
$a3 = new MockAction();
@@ -185,7 +185,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::do_action
*/
function test_action_args_with_php4_syntax() {
public function test_action_args_with_php4_syntax() {
$a = new MockAction();
$tag = __FUNCTION__;
$val = new stdClass();
@@ -199,7 +199,7 @@ class Tests_Actions extends WP_UnitTestCase {
$this->assertSame( array( $val ), array_pop( $argsvar ) );
}
function test_action_priority() {
public function test_action_priority() {
$a = new MockAction();
$tag = __FUNCTION__;
@@ -231,7 +231,7 @@ class Tests_Actions extends WP_UnitTestCase {
/**
* @covers ::did_action
*/
function test_did_action() {
public function test_did_action() {
$tag1 = 'action1';
$tag2 = 'action2';
@@ -255,7 +255,7 @@ class Tests_Actions extends WP_UnitTestCase {
/**
* @covers ::do_action
*/
function test_all_action() {
public function test_all_action() {
$a = new MockAction();
$tag1 = __FUNCTION__ . '_1';
$tag2 = __FUNCTION__ . '_2';
@@ -282,7 +282,7 @@ class Tests_Actions extends WP_UnitTestCase {
/**
* @covers ::remove_action
*/
function test_remove_all_action() {
public function test_remove_all_action() {
$a = new MockAction();
$tag = __FUNCTION__;
@@ -305,7 +305,7 @@ class Tests_Actions extends WP_UnitTestCase {
/**
* @covers ::do_action_ref_array
*/
function test_action_ref_array() {
public function test_action_ref_array() {
$obj = new stdClass();
$a = new MockAction();
$tag = __FUNCTION__;
@@ -326,7 +326,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::do_action
*/
function test_action_keyed_array() {
public function test_action_keyed_array() {
$a = new MockAction();
$tag = __FUNCTION__;
@@ -353,13 +353,13 @@ class Tests_Actions extends WP_UnitTestCase {
/**
* @covers ::remove_action
*/
function test_action_self_removal() {
public function test_action_self_removal() {
add_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) );
do_action( 'test_action_self_removal' );
$this->assertSame( 1, did_action( 'test_action_self_removal' ) );
}
function action_self_removal() {
public function action_self_removal() {
remove_action( 'test_action_self_removal', array( $this, 'action_self_removal' ) );
}
@@ -368,7 +368,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::do_action
*/
function test_action_recursion() {
public function test_action_recursion() {
$tag = __FUNCTION__;
$a = new MockAction();
$b = new MockAction();
@@ -385,7 +385,7 @@ class Tests_Actions extends WP_UnitTestCase {
/**
* @covers ::do_action
*/
function action_that_causes_recursion( $tag ) {
public function action_that_causes_recursion( $tag ) {
static $recursing = false;
if ( ! $recursing ) {
$recursing = true;
@@ -401,7 +401,7 @@ class Tests_Actions extends WP_UnitTestCase {
* @covers ::remove_action
* @covers ::add_action
*/
function test_action_callback_manipulation_while_running() {
public function test_action_callback_manipulation_while_running() {
$tag = __FUNCTION__;
$a = new MockAction();
$b = new MockAction();
@@ -423,7 +423,7 @@ class Tests_Actions extends WP_UnitTestCase {
$this->assertSame( 1, $e->get_call_count(), 'callback added by later priority callback should not get called' );
}
function action_that_manipulates_a_running_hook( $tag, $mocks ) {
public function action_that_manipulates_a_running_hook( $tag, $mocks ) {
remove_action( $tag, array( $mocks[1], 'action' ), 12, 2 );
add_action( $tag, array( $mocks[2], 'action' ), 12, 2 );
add_action( $tag, array( $mocks[3], 'action' ), 13, 2 );
@@ -438,7 +438,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::remove_filter
*/
function test_remove_anonymous_callback() {
public function test_remove_anonymous_callback() {
$tag = __FUNCTION__;
$a = new MockAction();
add_action( $tag, array( $a, 'action' ), 12, 1 );
@@ -475,7 +475,7 @@ class Tests_Actions extends WP_UnitTestCase {
* @covers WP_Hook::offsetSet
* @covers WP_Hook::offsetUnset
*/
function test_array_access_of_wp_filter_global() {
public function test_array_access_of_wp_filter_global() {
global $wp_filter;
$tag = __FUNCTION__;
@@ -503,7 +503,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::current_action
*/
function test_current_action() {
public function test_current_action() {
global $wp_current_filter;
$wp_current_filter[] = 'first';
$wp_current_filter[] = 'second'; // Let's say a second action was invoked.
@@ -516,7 +516,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::doing_filter
*/
function test_doing_filter() {
public function test_doing_filter() {
global $wp_current_filter;
$wp_current_filter = array(); // Set to an empty array first.
@@ -537,7 +537,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::doing_filter
*/
function test_doing_action() {
public function test_doing_action() {
global $wp_current_filter;
$wp_current_filter = array(); // Set to an empty array first.
@@ -558,7 +558,7 @@ class Tests_Actions extends WP_UnitTestCase {
*
* @covers ::doing_filter
*/
function test_doing_filter_real() {
public function test_doing_filter_real() {
$this->assertFalse( doing_filter() ); // No filter is passed in, and no filter is being processed.
$this->assertFalse( doing_filter( 'testing' ) ); // Filter is passed in but not being processed.
@@ -575,7 +575,7 @@ class Tests_Actions extends WP_UnitTestCase {
$this->assertFalse( doing_filter( 'testing' ) ); // No longer doing this filter.
}
function apply_testing_filter() {
public function apply_testing_filter() {
$this->apply_testing_filter = true;
$this->assertTrue( doing_filter() );
@@ -596,7 +596,7 @@ class Tests_Actions extends WP_UnitTestCase {
$this->assertFalse( doing_filter( 'testing_nested' ) );
}
function apply_testing_nested_filter() {
public function apply_testing_nested_filter() {
$this->apply_testing_nested_filter = true;
$this->assertTrue( doing_filter() );
$this->assertTrue( doing_filter( 'testing' ) );