Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

git-svn-id: https://develop.svn.wordpress.org/trunk@47122 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-01-29 00:43:23 +00:00
parent bd2cd572aa
commit cfc3b57488
810 changed files with 9893 additions and 8384 deletions
+24 -24
View File
@@ -11,7 +11,7 @@ class Tests_Auth extends WP_UnitTestCase {
protected static $wp_hasher;
/**
* action hook
* Action hook.
*/
protected $nonce_failure_hook = 'wp_verify_nonce_failed';
@@ -57,11 +57,11 @@ class Tests_Auth extends WP_UnitTestCase {
}
function test_auth_cookie_scheme() {
// arbitrary scheme name
// Arbitrary scheme name.
$cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' );
$this->assertEquals( self::$user_id, wp_validate_auth_cookie( $cookie, 'foo' ) );
// wrong scheme name - should fail
// Wrong scheme name - should fail.
$cookie = wp_generate_auth_cookie( self::$user_id, time() + 3600, 'foo' );
$this->assertEquals( false, wp_validate_auth_cookie( $cookie, 'bar' ) );
}
@@ -157,7 +157,7 @@ class Tests_Auth extends WP_UnitTestCase {
public function test_check_admin_referer_with_no_action_triggers_doing_it_wrong() {
$this->setExpectedIncorrectUsage( 'check_admin_referer' );
// A valid nonce needs to be set so the check doesn't die()
// A valid nonce needs to be set so the check doesn't die().
$_REQUEST['_wpnonce'] = wp_create_nonce( -1 );
$result = check_admin_referer();
$this->assertSame( 1, $result );
@@ -166,7 +166,7 @@ class Tests_Auth extends WP_UnitTestCase {
}
public function test_check_admin_referer_with_default_action_as_string_not_doing_it_wrong() {
// A valid nonce needs to be set so the check doesn't die()
// A valid nonce needs to be set so the check doesn't die().
$_REQUEST['_wpnonce'] = wp_create_nonce( '-1' );
$result = check_admin_referer( '-1' );
$this->assertSame( 1, $result );
@@ -180,7 +180,7 @@ class Tests_Auth extends WP_UnitTestCase {
public function test_check_ajax_referer_with_no_action_triggers_doing_it_wrong() {
$this->setExpectedIncorrectUsage( 'check_ajax_referer' );
// A valid nonce needs to be set so the check doesn't die()
// A valid nonce needs to be set so the check doesn't die().
$_REQUEST['_wpnonce'] = wp_create_nonce( -1 );
$result = check_ajax_referer();
$this->assertSame( 1, $result );
@@ -192,20 +192,20 @@ class Tests_Auth extends WP_UnitTestCase {
$limit = str_repeat( 'a', 4096 );
wp_set_password( $limit, self::$user_id );
// phpass hashed password
// phpass hashed password.
$this->assertStringStartsWith( '$P$', $this->user->data->user_pass );
$user = wp_authenticate( $this->user->user_login, 'aaaaaaaa' );
// Wrong Password
// Wrong password.
$this->assertInstanceOf( 'WP_Error', $user );
$user = wp_authenticate( $this->user->user_login, $limit );
$this->assertInstanceOf( 'WP_User', $user );
$this->assertEquals( self::$user_id, $user->ID );
// one char too many
// One char too many.
$user = wp_authenticate( $this->user->user_login, $limit . 'a' );
// Wrong Password
// Wrong password.
$this->assertInstanceOf( 'WP_Error', $user );
wp_set_password( $limit . 'a', self::$user_id );
@@ -223,11 +223,11 @@ class Tests_Auth extends WP_UnitTestCase {
$this->assertInstanceOf( 'WP_Error', $user );
$user = wp_authenticate( $this->user->user_login, 'aaaaaaaa' );
// Wrong Password
// Wrong password.
$this->assertInstanceOf( 'WP_Error', $user );
$user = wp_authenticate( $this->user->user_login, $limit );
// Wrong Password
// Wrong password.
$this->assertInstanceOf( 'WP_Error', $user );
$user = wp_authenticate( $this->user->user_login, $limit . 'a' );
@@ -242,7 +242,7 @@ class Tests_Auth extends WP_UnitTestCase {
$user = get_userdata( $this->user->ID );
$key = get_password_reset_key( $user );
// A correctly saved key should be accepted
// A correctly saved key should be accepted.
$check = check_password_reset_key( $key, $this->user->user_login );
$this->assertNotWPError( $check );
$this->assertInstanceOf( 'WP_User', $check );
@@ -267,21 +267,21 @@ class Tests_Auth extends WP_UnitTestCase {
);
clean_user_cache( $this->user );
// A valid key should be accepted
// A valid key should be accepted.
$check = check_password_reset_key( $key, $this->user->user_login );
$this->assertNotWPError( $check );
$this->assertInstanceOf( 'WP_User', $check );
$this->assertSame( $this->user->ID, $check->ID );
// An invalid key should be rejected
// An invalid key should be rejected.
$check = check_password_reset_key( 'key', $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
// An empty key should be rejected
// An empty key should be rejected.
$check = check_password_reset_key( '', $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
// A truncated key should be rejected
// A truncated key should be rejected.
$partial = substr( $key, 0, 10 );
$check = check_password_reset_key( $partial, $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
@@ -305,7 +305,7 @@ class Tests_Auth extends WP_UnitTestCase {
);
clean_user_cache( $this->user );
// An expired but otherwise valid key should be rejected
// An expired but otherwise valid key should be rejected.
$check = check_password_reset_key( $key, $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
}
@@ -314,11 +314,11 @@ class Tests_Auth extends WP_UnitTestCase {
* @ticket 32429
*/
function test_empty_user_activation_key_fails_key_check() {
// An empty user_activation_key should not allow any key to be accepted
// 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 );
// An empty user_activation_key should not allow an empty key to be accepted
// An empty user_activation_key should not allow an empty key to be accepted.
$check = check_password_reset_key( '', $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
}
@@ -343,11 +343,11 @@ class Tests_Auth extends WP_UnitTestCase {
);
clean_user_cache( $this->user );
// A legacy user_activation_key should not be accepted
// A legacy user_activation_key should not be accepted.
$check = check_password_reset_key( $key, $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
// An empty key with a legacy user_activation_key should be rejected
// An empty key with a legacy user_activation_key should be rejected.
$check = check_password_reset_key( '', $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
}
@@ -373,11 +373,11 @@ class Tests_Auth extends WP_UnitTestCase {
);
clean_user_cache( $this->user );
// A plaintext user_activation_key should not allow an otherwise valid key to be accepted
// A plaintext user_activation_key should not allow an otherwise valid key to be accepted.
$check = check_password_reset_key( $key, $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
// A plaintext user_activation_key should not allow an empty key to be accepted
// A plaintext user_activation_key should not allow an empty key to be accepted.
$check = check_password_reset_key( '', $this->user->user_login );
$this->assertInstanceOf( 'WP_Error', $check );
}