Docs: Update various DocBlocks and inline comments per the documentation standards.

Includes minor formatting edits for consistency.

Follow-up to [53/tests], [12179], [12946], [35288], [37884], [38810], [38928], [46596], [48131], [52955], [53548], [53813], [53873], [54118], [54316], [54420], [54421], [54803].

See #56792.

git-svn-id: https://develop.svn.wordpress.org/trunk@54855 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2022-11-17 18:13:47 +00:00
parent a71d7373ad
commit acbbee8a11
20 changed files with 99 additions and 92 deletions

View File

@@ -459,12 +459,12 @@ function gen_tests_array( $name, $array ) {
}
/**
* Use to create objects by yourself
* Use to create objects by yourself.
*/
class MockClass extends stdClass {}
/**
* Drops all tables from the WordPress database
* Drops all tables from the WordPress database.
*/
function drop_tables() {
global $wpdb;

View File

@@ -14,58 +14,58 @@ class Tests_Functions_SizeFormat extends WP_UnitTestCase {
public function _data_size_format() {
return array(
// Invalid values
// Invalid values.
array( array(), 0, false ),
array( 'baba', 0, false ),
array( '', 0, false ),
array( '-1', 0, false ),
array( -1, 0, false ),
// Bytes
// Bytes.
array( 0, 0, '0 B' ),
array( 1, 0, '1 B' ),
array( 1023, 0, '1,023 B' ),
// Kilobytes
// Kilobytes.
array( KB_IN_BYTES, 0, '1 KB' ),
array( KB_IN_BYTES, 2, '1.00 KB' ),
array( 2.5 * KB_IN_BYTES, 0, '3 KB' ),
array( 2.5 * KB_IN_BYTES, 2, '2.50 KB' ),
array( 10 * KB_IN_BYTES, 0, '10 KB' ),
// Megabytes
// Megabytes.
array( (string) 1024 * KB_IN_BYTES, 2, '1.00 MB' ),
array( MB_IN_BYTES, 0, '1 MB' ),
array( 2.5 * MB_IN_BYTES, 0, '3 MB' ),
array( 2.5 * MB_IN_BYTES, 2, '2.50 MB' ),
// Gigabytes
// Gigabytes.
array( (string) 1024 * MB_IN_BYTES, 2, '1.00 GB' ),
array( GB_IN_BYTES, 0, '1 GB' ),
array( 2.5 * GB_IN_BYTES, 0, '3 GB' ),
array( 2.5 * GB_IN_BYTES, 2, '2.50 GB' ),
// Terabytes
// Terabytes.
array( (string) 1024 * GB_IN_BYTES, 2, '1.00 TB' ),
array( TB_IN_BYTES, 0, '1 TB' ),
array( 2.5 * TB_IN_BYTES, 0, '3 TB' ),
array( 2.5 * TB_IN_BYTES, 2, '2.50 TB' ),
// Petabytes
// Petabytes.
array( (string) 1024 * TB_IN_BYTES, 2, '1.00 PB' ),
array( PB_IN_BYTES, 0, '1 PB' ),
array( 2.5 * PB_IN_BYTES, 0, '3 PB' ),
array( 2.5 * PB_IN_BYTES, 2, '2.50 PB' ),
// Exabytes
// Exabytes.
array( (string) 1024 * PB_IN_BYTES, 2, '1.00 EB' ),
array( EB_IN_BYTES, 0, '1 EB' ),
array( 2.5 * EB_IN_BYTES, 0, '3 EB' ),
array( 2.5 * EB_IN_BYTES, 2, '2.50 EB' ),
// Zettabytes
// Zettabytes.
array( (string) 1024 * EB_IN_BYTES, 2, '1.00 ZB' ),
array( ZB_IN_BYTES, 0, '1 ZB' ),
array( 2.5 * ZB_IN_BYTES, 0, '3 ZB' ),
array( 2.5 * ZB_IN_BYTES, 2, '2.50 ZB' ),
// Yottabytes
// Yottabytes.
array( (string) 1024 * ZB_IN_BYTES, 2, '1.00 YB' ),
array( YB_IN_BYTES, 0, '1 YB' ),
array( 2.5 * YB_IN_BYTES, 0, '3 YB' ),
array( 2.5 * YB_IN_BYTES, 2, '2.50 YB' ),
// Edge values
// Edge values.
array( TB_IN_BYTES + ( TB_IN_BYTES / 2 ) + MB_IN_BYTES, 1, '1.5 TB' ),
array( TB_IN_BYTES - MB_IN_BYTES - KB_IN_BYTES, 3, '1,023.999 GB' ),
);

View File

@@ -12,7 +12,7 @@ class Tests_Functions_wpListSort extends WP_UnitTestCase {
* @dataProvider data_test_wp_list_sort
*
* @param string|array $orderby Either the field name to order by or an array
* of multiple orderby fields as $orderby => $order.
* of multiple orderby fields as `$orderby => $order`.
* @param string $order Either 'ASC' or 'DESC'.
*/
public function test_wp_list_sort( $list, $orderby, $order, $expected ) {
@@ -337,7 +337,7 @@ class Tests_Functions_wpListSort extends WP_UnitTestCase {
* @dataProvider data_test_wp_list_sort_preserve_keys
*
* @param string|array $orderby Either the field name to order by or an array
* of multiple orderby fields as $orderby => $order.
* of multiple orderby fields as `$orderby => $order`.
* @param string $order Either 'ASC' or 'DESC'.
*/
public function test_wp_list_sort_preserve_keys( $list, $orderby, $order, $expected ) {

View File

@@ -64,7 +64,8 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
* @param array $target_array The array to create the list from.
* @param string $target_key The key to pluck.
* @param array $expected The expected array.
* @param string $index_key Optional. Field from the element to use as keys for the new array. Default null.
* @param string $index_key Optional. Field from the element to use as keys for the new array.
* Default null.
*/
public function test_wp_list_util_pluck( $target_array, $target_key, $expected, $index_key = null ) {
$util = new WP_List_Util( $target_array );
@@ -156,9 +157,11 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
*
* @param array $expected The expected array.
* @param array $target_array The array to create a list from.
* @param array $orderby Optional. Either the field name to order by or an array of multiple orderby fields as $orderby => $order.
* @param array $orderby Optional. Either the field name to order by or an array
* of multiple orderby fields as `$orderby => $order`.
* Default empty array.
* @param string $order Optional. Either 'ASC' or 'DESC'. Only used if $orderby is a string. Default 'ASC'.
* @param string $order Optional. Either 'ASC' or 'DESC'. Only used if `$orderby`
* is a string. Default 'ASC'.
* @param bool $preserve_keys Optional. Whether to preserve keys. Default false.
*/
public function test_wp_list_util_sort( $expected, $target_array, $orderby = array(), $order = 'ASC', $preserve_keys = false ) {
@@ -955,9 +958,11 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
*
* @param array $expected The expected array.
* @param array $target_array The array to create a list from.
* @param array $orderby Optional. Either the field name to order by or an array of multiple orderby fields as $orderby => $order.
* @param array $orderby Optional. Either the field name to order by or an array
* of multiple orderby fields as `$orderby => $order`.
* Default empty array.
* @param string $order Optional. Either 'ASC' or 'DESC'. Only used if $orderby is a string. Default 'ASC'.
* @param string $order Optional. Either 'ASC' or 'DESC'. Only used if `$orderby`
* is a string. Default 'ASC'.
* @param bool $preserve_keys Optional. Whether to preserve keys. Default false.
*/
public function test_wp_list_util_sort_php_7_or_greater( $expected, $target_array, $orderby = array(), $order = 'ASC', $preserve_keys = false ) {

View File

@@ -14,7 +14,6 @@ class Tests_Functions_wpNonceField extends WP_UnitTestCase {
* @ticket 55578
*/
public function test_wp_nonce_field() {
wp_nonce_field();
$this->expectOutputRegex( '#^<input type="hidden" id="_wpnonce" name="_wpnonce" value=".{10}" /><input type="hidden" name="_wp_http_referer" value="" />$#' );
}
@@ -24,14 +23,13 @@ class Tests_Functions_wpNonceField extends WP_UnitTestCase {
*
* @dataProvider data_wp_nonce_field
*
* @param int|string $action Action name.
* @param string $name Nonce name.
* @param bool $referer Whether to set the referer field fior validation.
* @param string $expected_reg_exp The expected regular expression.
* @param int|string $action Action name.
* @param string $name Nonce name.
* @param bool $referer Whether to set the referer field for validation.
* @param string $expected_regexp The expected regular expression.
*/
public function test_wp_nonce_field_return( $action, $name, $referer, $expected_reg_exp ) {
$this->assertMatchesRegularExpression( $expected_reg_exp, wp_nonce_field( $action, $name, $referer, false ) );
public function test_wp_nonce_field_return( $action, $name, $referer, $expected_regexp ) {
$this->assertMatchesRegularExpression( $expected_regexp, wp_nonce_field( $action, $name, $referer, false ) );
}
/**
@@ -40,37 +38,36 @@ class Tests_Functions_wpNonceField extends WP_UnitTestCase {
* @return array
*/
public function data_wp_nonce_field() {
return array(
'default' => array(
'action' => - 1,
'name' => '_wpnonce',
'referer' => true,
'expected_reg_exp' => '#^<input type="hidden" id="_wpnonce" name="_wpnonce" value=".{10}" /><input type="hidden" name="_wp_http_referer" value="" />$#',
'action' => -1,
'name' => '_wpnonce',
'referer' => true,
'expected_regexp' => '#^<input type="hidden" id="_wpnonce" name="_wpnonce" value=".{10}" /><input type="hidden" name="_wp_http_referer" value="" />$#',
),
'nonce_name' => array(
'action' => - 1,
'name' => 'nonce_name',
'referer' => true,
'expected_reg_exp' => '#^<input type="hidden" id="nonce_name" name="nonce_name" value=".{10}" /><input type="hidden" name="_wp_http_referer" value="" />$#',
'action' => -1,
'name' => 'nonce_name',
'referer' => true,
'expected_regexp' => '#^<input type="hidden" id="nonce_name" name="nonce_name" value=".{10}" /><input type="hidden" name="_wp_http_referer" value="" />$#',
),
'action_name' => array(
'action' => 'action_name',
'name' => '_wpnonce',
'referer' => true,
'expected_reg_exp' => '#^<input type="hidden" id="_wpnonce" name="_wpnonce" value="' . wp_create_nonce( 'action_name' ) . '" /><input type="hidden" name="_wp_http_referer" value="" />$#',
'action' => 'action_name',
'name' => '_wpnonce',
'referer' => true,
'expected_regexp' => '#^<input type="hidden" id="_wpnonce" name="_wpnonce" value="' . wp_create_nonce( 'action_name' ) . '" /><input type="hidden" name="_wp_http_referer" value="" />$#',
),
'no_referer' => array(
'action' => - 1,
'name' => '_wpnonce',
'referer' => false,
'expected_reg_exp' => '#^<input type="hidden" id="_wpnonce" name="_wpnonce" value=".{10}" />$#',
'action' => -1,
'name' => '_wpnonce',
'referer' => false,
'expected_regexp' => '#^<input type="hidden" id="_wpnonce" name="_wpnonce" value=".{10}" />$#',
),
'& in name' => array(
'action' => - 1,
'name' => 'a&b',
'referer' => false,
'expected_reg_exp' => '#^<input type="hidden" id="a\&amp;b" name="a\&amp;b" value=".{10}" />$#',
'action' => -1,
'name' => 'a&b',
'referer' => false,
'expected_regexp' => '#^<input type="hidden" id="a\&amp;b" name="a\&amp;b" value=".{10}" />$#',
),
);
}

View File

@@ -14,8 +14,8 @@ class Tests_Functions_wpRefererField extends WP_UnitTestCase {
* @ticket 55578
*/
public function test_wp_referer_field() {
$_SERVER['REQUEST_URI'] = '/test/';
wp_referer_field();
$this->expectOutputString( '<input type="hidden" name="_wp_http_referer" value="/test/" />' );
}
@@ -24,7 +24,6 @@ class Tests_Functions_wpRefererField extends WP_UnitTestCase {
* @ticket 55578
*/
public function test_wp_referer_field_return() {
$_SERVER['REQUEST_URI'] = '/test/';
$this->assertSame( '<input type="hidden" name="_wp_http_referer" value="/test/" />', wp_referer_field( false ) );

View File

@@ -1529,6 +1529,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
/**
* @ticket 55592
*
* @covers WP_REST_Posts_Controller::get_items
* @covers ::update_post_thumbnail_cache
*/
@@ -1566,6 +1567,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
/**
* @ticket 55593
*
* @covers WP_REST_Posts_Controller::get_items
* @covers ::update_post_parent_caches
*/

View File

@@ -3026,7 +3026,7 @@ class Tests_Theme_wpThemeJson extends WP_UnitTestCase {
}
/**
* Testing that dynamic properties in theme.json return the value they refrence,
* Testing that dynamic properties in theme.json return the value they reference,
* e.g. array( 'ref' => 'styles.color.background' ) => "#ffffff".
*
* @ticket 56467