Tests: Add missing @covers tags for files in phpunit/tests/functions/.

Props pbearne, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@49006 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-09-19 15:52:03 +00:00
parent 898eb5fc51
commit 835e9c48a4
27 changed files with 102 additions and 29 deletions

View File

@ -3,6 +3,7 @@
/** /**
* @group formatting * @group formatting
* @group functions.php * @group functions.php
* @covers ::add_magic_quotes
*/ */
class Tests_Functions_AddMagicQuotes extends WP_UnitTestCase { class Tests_Functions_AddMagicQuotes extends WP_UnitTestCase {

View File

@ -3,6 +3,7 @@
/** /**
* @group formatting * @group formatting
* @group functions.php * @group functions.php
* @covers ::wp_allowed_protocols
*/ */
class Tests_Functions_AllowedProtocols extends WP_UnitTestCase { class Tests_Functions_AllowedProtocols extends WP_UnitTestCase {

View File

@ -10,12 +10,14 @@
/** /**
* Class Tests_Functions_Anonymization. * Class Tests_Functions_Anonymization.
* *
* @since 4.9.6
*
* @group functions.php * @group functions.php
* @group privacy * @group privacy
* * @covers ::wp_privacy_anonymize_data
* @since 4.9.6
*/ */
class Tests_Functions_Anonymization extends WP_UnitTestCase { class Tests_Functions_Anonymization extends WP_UnitTestCase {
/** /**
* Test that wp_privacy_anonymize_ip() properly anonymizes all possible IP address formats. * Test that wp_privacy_anonymize_ip() properly anonymizes all possible IP address formats.
* *

View File

@ -1,11 +1,13 @@
<?php <?php
/* /**
* Validate that badly named charsets always return the correct format for UTF-8 and ISO-8859-1. * Validate that badly named charsets always return the correct format for UTF-8 and ISO-8859-1.
* *
* @since 4.8.0 * @since 4.8.0
*
* @group functions.php
* @covers ::_canonical_charset
*/ */
class Tests_Functions_CanonicalCharset extends WP_UnitTestCase { class Tests_Functions_CanonicalCharset extends WP_UnitTestCase {
public function test_utf_8_lower() { public function test_utf_8_lower() {
@ -50,6 +52,8 @@ class Tests_Functions_CanonicalCharset extends WP_UnitTestCase {
/** /**
* @ticket 23688 * @ticket 23688
*
* @covers ::get_option
*/ */
function test_update_option_blog_charset() { function test_update_option_blog_charset() {
$orig_blog_charset = get_option( 'blog_charset' ); $orig_blog_charset = get_option( 'blog_charset' );

View File

@ -1,16 +1,18 @@
<?php <?php
/* /**
* Test _cleanup_header_comment(). * Test _cleanup_header_comment().
* *
* @group functions.php
* @ticket 8497 * @ticket 8497
* @ticket 38101 * @ticket 38101
*
* @group functions.php
* @covers ::_cleanup_header_comment
*/ */
class Tests_Functions_CleanupHeaderComment extends WP_UnitTestCase { class Tests_Functions_CleanupHeaderComment extends WP_UnitTestCase {
/** /**
* Test cleanup header of header comment. * Test cleanup header of header comment.
* *
* @covers ::_cleanup_header_comment
* @dataProvider data_cleanup_header_comment * @dataProvider data_cleanup_header_comment
* *
* @param string $test_string * @param string $test_string

View File

@ -3,10 +3,13 @@
/** /**
* Test cases for deprecated functions, arguments, and files * Test cases for deprecated functions, arguments, and files
* *
* @package WordPress * @package WordPress
* @subpackage Unit Tests * @subpackage Unit Tests
* @since 3.5.0 *
* @group deprecated * @since 3.5.0
*
* @group functions.php
* @group deprecated
*/ */
class Tests_Functions_Deprecated extends WP_UnitTestCase { class Tests_Functions_Deprecated extends WP_UnitTestCase {
@ -140,6 +143,8 @@ class Tests_Functions_Deprecated extends WP_UnitTestCase {
* *
* @ticket 6821 * @ticket 6821
* @expectedDeprecated wp_save_image_file * @expectedDeprecated wp_save_image_file
*
* @covers ::wp_save_image_file
*/ */
public function test_wp_save_image_file_deprecated_with_gd_resource() { public function test_wp_save_image_file_deprecated_with_gd_resource() {
if ( ! function_exists( 'imagejpeg' ) ) { if ( ! function_exists( 'imagejpeg' ) ) {
@ -163,6 +168,8 @@ class Tests_Functions_Deprecated extends WP_UnitTestCase {
* Tests that wp_save_image_file() doesn't have a deprecated argument when passed a WP_Image_Editor. * Tests that wp_save_image_file() doesn't have a deprecated argument when passed a WP_Image_Editor.
* *
* @ticket 6821 * @ticket 6821
*
* @covers ::wp_save_image_file
*/ */
public function test_wp_save_image_file_not_deprecated_with_wp_image_editor() { public function test_wp_save_image_file_not_deprecated_with_wp_image_editor() {
if ( ! function_exists( 'imagejpeg' ) ) { if ( ! function_exists( 'imagejpeg' ) ) {

View File

@ -10,11 +10,11 @@
/** /**
* Tests_Functions_DoEnclose class. * Tests_Functions_DoEnclose class.
* *
* @since 5.3.0
*
* @group functions.php * @group functions.php
* @group post * @group post
* @covers ::do_enclose * @covers ::do_enclose
*
* @since 5.3.0
*/ */
class Tests_Functions_DoEnclose extends WP_UnitTestCase { class Tests_Functions_DoEnclose extends WP_UnitTestCase {
@ -253,7 +253,7 @@ class Tests_Functions_DoEnclose extends WP_UnitTestCase {
* @since 5.3.0 * @since 5.3.0
* *
* @param int $post_id Post ID. * @param int $post_id Post ID.
* @return string All enclosure data for the given post. * @return string All enclosure data for the given post.
*/ */
protected function get_enclosed_by_post_id( $post_id ) { protected function get_enclosed_by_post_id( $post_id ) {
return implode( '', (array) get_post_meta( $post_id, 'enclosure', false ) ); return implode( '', (array) get_post_meta( $post_id, 'enclosure', false ) );

View File

@ -6,6 +6,7 @@
* @since 5.3.0 * @since 5.3.0
* *
* @group functions.php * @group functions.php
* @covers ::get_status_header_desc
*/ */
class Tests_Functions_GetStatusHeaderDesc extends WP_UnitTestCase { class Tests_Functions_GetStatusHeaderDesc extends WP_UnitTestCase {

View File

@ -2,6 +2,7 @@
/** /**
* @group functions.php * @group functions.php
* @covers ::get_weekstartend
*/ */
class Tests_Functions_GetWeekstartend extends WP_UnitTestCase { class Tests_Functions_GetWeekstartend extends WP_UnitTestCase {

View File

@ -5,6 +5,7 @@
* @since 5.2.0 * @since 5.2.0
* *
* @group functions.php * @group functions.php
* @covers ::is_new_day
*/ */
class Tests_Functions_IsNewDate extends WP_UnitTestCase { class Tests_Functions_IsNewDate extends WP_UnitTestCase {

View File

@ -3,8 +3,10 @@
/** /**
* Tests for `is_serialized_string()`. * Tests for `is_serialized_string()`.
* *
* @group functions.php
* @ticket 42870 * @ticket 42870
*
* @group functions.php
* @covers ::is_serialized_string
*/ */
class Tests_Functions_IsSerializedString extends WP_UnitTestCase { class Tests_Functions_IsSerializedString extends WP_UnitTestCase {

View File

@ -4,8 +4,10 @@
* Test list_files(). * Test list_files().
* *
* @group functions.php * @group functions.php
* @covers ::list_files
*/ */
class Tests_Functions_ListFiles extends WP_UnitTestCase { class Tests_Functions_ListFiles extends WP_UnitTestCase {
public function test_list_files_returns_a_list_of_files() { public function test_list_files_returns_a_list_of_files() {
$admin_files = list_files( ABSPATH . 'wp-admin/' ); $admin_files = list_files( ABSPATH . 'wp-admin/' );
$this->assertInternalType( 'array', $admin_files ); $this->assertInternalType( 'array', $admin_files );

View File

@ -5,8 +5,10 @@
* *
* @group functions.php * @group functions.php
* @group i18n * @group i18n
* @covers ::number_format_i18n
*/ */
class Tests_Functions_NumberFormatI18n extends WP_UnitTestCase { class Tests_Functions_NumberFormatI18n extends WP_UnitTestCase {
public function test_should_fall_back_to_number_format_when_wp_locale_is_not_set() { public function test_should_fall_back_to_number_format_when_wp_locale_is_not_set() {
$locale = clone $GLOBALS['wp_locale']; $locale = clone $GLOBALS['wp_locale'];
$GLOBALS['wp_locale'] = null; $GLOBALS['wp_locale'] = null;

View File

@ -5,6 +5,7 @@
* *
* @group functions.php * @group functions.php
* @group plugins * @group plugins
* @covers ::plugin_basename
*/ */
class Tests_Functions_PluginBasename extends WP_UnitTestCase { class Tests_Functions_PluginBasename extends WP_UnitTestCase {

View File

@ -4,8 +4,11 @@
* Test wp_get_referer(). * Test wp_get_referer().
* *
* @group functions.php * @group functions.php
* @covers ::wp_get_referer
* @covers ::wp_get_raw_referer
*/ */
class Tests_Functions_Referer extends WP_UnitTestCase { class Tests_Functions_Referer extends WP_UnitTestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();

View File

@ -2,8 +2,10 @@
/** /**
* @group functions.php * @group functions.php
* @covers ::remove_query_arg
*/ */
class Tests_Functions_RemoveQueryArg extends WP_UnitTestCase { class Tests_Functions_RemoveQueryArg extends WP_UnitTestCase {
/** /**
* @dataProvider remove_query_arg_provider * @dataProvider remove_query_arg_provider
*/ */

View File

@ -3,10 +3,13 @@
/** /**
* Tests for size_format() * Tests for size_format()
* *
* @group functions.php
* @ticket 36635 * @ticket 36635
*
* @group functions.php
* @covers ::size_format
*/ */
class Tests_Functions_SizeFormat extends WP_UnitTestCase { class Tests_Functions_SizeFormat extends WP_UnitTestCase {
public function _data_size_format() { public function _data_size_format() {
return array( return array(
array( array(), 0, false ), array( array(), 0, false ),

View File

@ -8,26 +8,44 @@
*/ */
class Tests_Functions_UnderscoreReturn extends WP_UnitTestCase { class Tests_Functions_UnderscoreReturn extends WP_UnitTestCase {
/**
* @covers ::__return_true
*/
public function test__return_true() { public function test__return_true() {
$this->assertTrue( __return_true() ); $this->assertTrue( __return_true() );
} }
/**
* @covers ::__return_false
*/
public function test__return_false() { public function test__return_false() {
$this->assertFalse( __return_false() ); $this->assertFalse( __return_false() );
} }
/**
* @covers ::__return_zero
*/
public function test__return_zero() { public function test__return_zero() {
$this->assertSame( 0, __return_zero() ); $this->assertSame( 0, __return_zero() );
} }
/**
* @covers ::__return_empty_array
*/
public function test__return_empty_array() { public function test__return_empty_array() {
$this->assertSame( array(), __return_empty_array() ); $this->assertSame( array(), __return_empty_array() );
} }
/**
* @covers ::__return_null
*/
public function test__return_null() { public function test__return_null() {
$this->assertNull( __return_null() ); $this->assertNull( __return_null() );
} }
/**
* @covers ::__return_empty_string
*/
public function test__return_empty_string() { public function test__return_empty_string() {
$this->assertSame( '', __return_empty_string() ); $this->assertSame( '', __return_empty_string() );
} }

View File

@ -3,6 +3,7 @@
/** /**
* @group functions.php * @group functions.php
* @group query * @group query
* @covers ::wp
*/ */
class Tests_Functions_WP extends WP_UnitTestCase { class Tests_Functions_WP extends WP_UnitTestCase {

View File

@ -5,8 +5,8 @@
* *
* @since 5.3.0 * @since 5.3.0
* *
* @covers ::wp_array_slice_assoc
* @group functions.php * @group functions.php
* @covers ::wp_array_slice_assoc
*/ */
class Tests_Functions_wpArraySliceAssoc extends WP_UnitTestCase { class Tests_Functions_wpArraySliceAssoc extends WP_UnitTestCase {

View File

@ -4,6 +4,8 @@
* Tests for the behavior of `wp_auth_check()` * Tests for the behavior of `wp_auth_check()`
* *
* @group functions.php * @group functions.php
* @covers ::is_user_logged_in
* @covers ::wp_auth_check
*/ */
class Tests_Functions_wpAuthCheck extends WP_UnitTestCase { class Tests_Functions_wpAuthCheck extends WP_UnitTestCase {

View File

@ -1,12 +1,9 @@
<?php <?php
/*
$defaults = array( /**
'type' => 'monthly', 'limit' => '', * @group functions.php
'format' => 'html', 'before' => '', * @covers ::wp_get_archives
'after' => '', 'show_post_count' => false, */
'echo' => 1, 'order' => 'DESC',
);
*/
class Tests_Functions_wpGetArchives extends WP_UnitTestCase { class Tests_Functions_wpGetArchives extends WP_UnitTestCase {
protected static $post_ids; protected static $post_ids;
protected $month_url; protected $month_url;

View File

@ -4,6 +4,7 @@
* Test wp_get_mime_types(). * Test wp_get_mime_types().
* *
* @group functions.php * @group functions.php
* @covers ::wp_get_mime_types
*/ */
class Tests_Functions_wpGetMimeTypes extends WP_UnitTestCase { class Tests_Functions_wpGetMimeTypes extends WP_UnitTestCase {

View File

@ -4,6 +4,8 @@
* Test wp_filter_object_list(), wp_list_filter(), wp_list_pluck(). * Test wp_filter_object_list(), wp_list_filter(), wp_list_pluck().
* *
* @group functions.php * @group functions.php
* @covers ::wp_filter_object_list
* @covers ::wp_list_pluck
*/ */
class Tests_Functions_wpListFilter extends WP_UnitTestCase { class Tests_Functions_wpListFilter extends WP_UnitTestCase {
var $object_list = array(); var $object_list = array();
@ -317,7 +319,6 @@ class Tests_Functions_wpListFilter extends WP_UnitTestCase {
$this->assertArrayHasKey( 'baz', $list ); $this->assertArrayHasKey( 'baz', $list );
} }
function test_filter_object_list_nested_array_and_field() { function test_filter_object_list_nested_array_and_field() {
$list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'AND', 'name' ); $list = wp_filter_object_list( $this->object_list, array( 'field4' => array( 'blue' ) ), 'AND', 'name' );
$this->assertSame( array( 'baz' => 'baz' ), $list ); $this->assertSame( array( 'baz' => 'baz' ), $list );

View File

@ -155,6 +155,8 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
/** /**
* @dataProvider data_test_wp_list_pluck * @dataProvider data_test_wp_list_pluck
* *
* @covers ::wp_list_pluck
*
* @param array $list List of objects or arrays. * @param array $list List of objects or arrays.
* @param int|string $field Field from the object to place instead of the entire object * @param int|string $field Field from the object to place instead of the entire object
* @param int|string $index_key Field from the object to use as keys for the new array. * @param int|string $index_key Field from the object to use as keys for the new array.
@ -359,6 +361,8 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
/** /**
* @dataProvider data_test_wp_list_filter * @dataProvider data_test_wp_list_filter
* *
* @covers ::wp_list_filter
*
* @param array $list An array of objects to filter. * @param array $list An array of objects to filter.
* @param array $args An array of key => value arguments to match * @param array $args An array of key => value arguments to match
* against each object. * against each object.
@ -686,6 +690,8 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
/** /**
* @dataProvider data_test_wp_list_sort * @dataProvider data_test_wp_list_sort
* *
* @covers ::wp_list_sort
*
* @param string|array $orderby Either the field name to order by or an array * @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'. * @param string $order Either 'ASC' or 'DESC'.
@ -1011,6 +1017,8 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
/** /**
* @dataProvider data_test_wp_list_sort_preserve_keys * @dataProvider data_test_wp_list_sort_preserve_keys
* *
* @covers ::wp_list_sort
*
* @param string|array $orderby Either the field name to order by or an array * @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'. * @param string $order Either 'ASC' or 'DESC'.
@ -1019,6 +1027,9 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
$this->assertSame( $expected, wp_list_sort( $list, $orderby, $order, true ) ); $this->assertSame( $expected, wp_list_sort( $list, $orderby, $order, true ) );
} }
/**
* @covers WP_List_Util::get_input
*/
public function test_wp_list_util_get_input() { public function test_wp_list_util_get_input() {
$input = array( 'foo', 'bar' ); $input = array( 'foo', 'bar' );
$util = new WP_List_Util( $input ); $util = new WP_List_Util( $input );
@ -1026,6 +1037,9 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
$this->assertSameSets( $input, $util->get_input() ); $this->assertSameSets( $input, $util->get_input() );
} }
/**
* @covers WP_List_Util::get_output
*/
public function test_wp_list_util_get_output_immediately() { public function test_wp_list_util_get_output_immediately() {
$input = array( 'foo', 'bar' ); $input = array( 'foo', 'bar' );
$util = new WP_List_Util( $input ); $util = new WP_List_Util( $input );
@ -1033,6 +1047,9 @@ class Tests_Functions_wpListUtil extends WP_UnitTestCase {
$this->assertSameSets( $input, $util->get_output() ); $this->assertSameSets( $input, $util->get_output() );
} }
/**
* @covers WP_List_Util::get_output
*/
public function test_wp_list_util_get_output() { public function test_wp_list_util_get_output() {
$expected = array( $expected = array(
(object) array( (object) array(

View File

@ -3,6 +3,7 @@
* @group http * @group http
* @group external-http * @group external-http
* @group functions.php * @group functions.php
* @covers ::wp_remote_fopen
*/ */
class Tests_Functions_wpRemoteFopen extends WP_UnitTestCase { class Tests_Functions_wpRemoteFopen extends WP_UnitTestCase {

View File

@ -3,8 +3,8 @@
/** /**
* Tests the wp_validate_boolean function. * Tests the wp_validate_boolean function.
* *
* @covers ::wp_validate_boolean
* @group functions.php * @group functions.php
* @covers ::wp_validate_boolean
*/ */
class Tests_Functions_wpValidateBoolean extends WP_UnitTestCase { class Tests_Functions_wpValidateBoolean extends WP_UnitTestCase {
/** /**
@ -47,8 +47,8 @@ class Tests_Functions_wpValidateBoolean extends WP_UnitTestCase {
* *
* @dataProvider data_provider * @dataProvider data_provider
* *
* @param mixed $test_value. * @param mixed $test_value
* @param bool $expected. * @param bool $expected
* *
* @ticket 30238 * @ticket 30238
* @ticket 39868 * @ticket 39868