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

View File

@@ -32,7 +32,7 @@ class Tests_Auth extends WP_UnitTestCase {
self::$wp_hasher = new PasswordHash( 8, true );
}
function set_up() {
public function set_up() {
parent::set_up();
$this->user = clone self::$_user;
@@ -49,12 +49,12 @@ class Tests_Auth extends WP_UnitTestCase {
parent::tear_down();
}
function test_auth_cookie_valid() {
public function test_auth_cookie_valid() {
$cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'auth' );
$this->assertSame( self::$user_id, wp_validate_auth_cookie( $cookie, 'auth' ) );
}
function test_auth_cookie_invalid() {
public function test_auth_cookie_invalid() {
// 3600 or less and +3600 may occur in wp_validate_auth_cookie(),
// as an ajax test may have defined DOING_AJAX, failing the test.
@@ -70,7 +70,7 @@ class Tests_Auth extends WP_UnitTestCase {
$this->assertFalse( wp_validate_auth_cookie( self::$user_id, 'auth' ), 'altered cookie' );
}
function test_auth_cookie_scheme() {
public function test_auth_cookie_scheme() {
// Arbitrary scheme name.
$cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' );
$this->assertSame( self::$user_id, wp_validate_auth_cookie( $cookie, 'foo' ) );
@@ -83,7 +83,7 @@ class Tests_Auth extends WP_UnitTestCase {
/**
* @ticket 23494
*/
function test_password_trimming() {
public function test_password_trimming() {
$passwords_to_test = array(
'a password with no trailing or leading spaces',
'a password with trailing spaces ',
@@ -108,7 +108,7 @@ class Tests_Auth extends WP_UnitTestCase {
*
* @ticket 24973
*/
function test_wp_hash_password_trimming() {
public function test_wp_hash_password_trimming() {
$password = ' pass with leading whitespace';
$this->assertTrue( wp_check_password( 'pass with leading whitespace', wp_hash_password( $password ) ) );
@@ -129,7 +129,7 @@ class Tests_Auth extends WP_UnitTestCase {
/**
* @ticket 29217
*/
function test_wp_verify_nonce_with_empty_arg() {
public function test_wp_verify_nonce_with_empty_arg() {
$this->assertFalse( wp_verify_nonce( '' ) );
$this->assertFalse( wp_verify_nonce( null ) );
}
@@ -137,14 +137,14 @@ class Tests_Auth extends WP_UnitTestCase {
/**
* @ticket 29542
*/
function test_wp_verify_nonce_with_integer_arg() {
public function test_wp_verify_nonce_with_integer_arg() {
$this->assertFalse( wp_verify_nonce( 1 ) );
}
/**
* @ticket 24030
*/
function test_wp_nonce_verify_failed() {
public function test_wp_nonce_verify_failed() {
$nonce = substr( md5( uniqid() ), 0, 10 );
$count = did_action( $this->nonce_failure_hook );
@@ -156,7 +156,7 @@ class Tests_Auth extends WP_UnitTestCase {
/**
* @ticket 24030
*/
function test_wp_nonce_verify_success() {
public function test_wp_nonce_verify_success() {
$nonce = wp_create_nonce( 'nonce_test_action' );
$count = did_action( $this->nonce_failure_hook );
@@ -202,7 +202,7 @@ class Tests_Auth extends WP_UnitTestCase {
unset( $_REQUEST['_wpnonce'] );
}
function test_password_length_limit() {
public function test_password_length_limit() {
$limit = str_repeat( 'a', 4096 );
wp_set_password( $limit, self::$user_id );
@@ -252,7 +252,7 @@ class Tests_Auth extends WP_UnitTestCase {
/**
* @ticket 45746
*/
function test_user_activation_key_is_saved() {
public function test_user_activation_key_is_saved() {
$user = get_userdata( $this->user->ID );
$key = get_password_reset_key( $user );
@@ -266,7 +266,7 @@ class Tests_Auth extends WP_UnitTestCase {
/**
* @ticket 32429
*/
function test_user_activation_key_is_checked() {
public function test_user_activation_key_is_checked() {
global $wpdb;
$key = wp_generate_password( 20, false );
@@ -304,7 +304,7 @@ class Tests_Auth extends WP_UnitTestCase {
/**
* @ticket 32429
*/
function test_expired_user_activation_key_is_rejected() {
public function test_expired_user_activation_key_is_rejected() {
global $wpdb;
$key = wp_generate_password( 20, false );
@@ -327,7 +327,7 @@ class Tests_Auth extends WP_UnitTestCase {
/**
* @ticket 32429
*/
function test_empty_user_activation_key_fails_key_check() {
public function test_empty_user_activation_key_fails_key_check() {
// An empty user_activation_key should not allow any key to be accepted.
$check = check_password_reset_key( 'key', $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
@@ -340,7 +340,7 @@ class Tests_Auth extends WP_UnitTestCase {
/**
* @ticket 32429
*/
function test_legacy_user_activation_key_is_rejected() {
public function test_legacy_user_activation_key_is_rejected() {
global $wpdb;
// A legacy user_activation_key is one without the `time()` prefix introduced in WordPress 4.3.
@@ -370,7 +370,7 @@ class Tests_Auth extends WP_UnitTestCase {
* @ticket 32429
* @ticket 24783
*/
function test_plaintext_user_activation_key_is_rejected() {
public function test_plaintext_user_activation_key_is_rejected() {
global $wpdb;
// A plaintext user_activation_key is one stored before hashing was introduced in WordPress 3.7.