diff --git a/tests/phpunit/tests/abilities-api/wpAbilitiesRegistry.php b/tests/phpunit/tests/abilities-api/wpAbilitiesRegistry.php index 7d98cb2780454..72f868030dc4a 100644 --- a/tests/phpunit/tests/abilities-api/wpAbilitiesRegistry.php +++ b/tests/phpunit/tests/abilities-api/wpAbilitiesRegistry.php @@ -229,7 +229,7 @@ public function test_register_ability_nonexistent_category(): void { * * @ticket 65569 * - * @dataProvider data_invalid_category_types + * @dataProvider data_register_ability_rejects_invalid_category_type * * @covers WP_Abilities_Registry::register * @@ -255,7 +255,7 @@ public function test_register_ability_rejects_invalid_category_type( $category ) * * @return array> Test cases. */ - public static function data_invalid_category_types(): array { + public static function data_register_ability_rejects_invalid_category_type(): array { return array( 'null' => array( null ), 'boolean' => array( false ), diff --git a/tests/phpunit/tests/abilities-api/wpAbility.php b/tests/phpunit/tests/abilities-api/wpAbility.php index 181c68d54ae15..951e749ec6c8c 100644 --- a/tests/phpunit/tests/abilities-api/wpAbility.php +++ b/tests/phpunit/tests/abilities-api/wpAbility.php @@ -2354,23 +2354,11 @@ public function test_prepare_input( array $schema, $input, $expected ): void { $this->assertSame( $expected, $ability->prepare_input( $input ) ); } - /** - * Provides representative inputs for execution lifecycle integration. - * - * @return array - */ - public static function data_input_coercion(): array { - return array_intersect_key( - self::data_input_is_coerced(), - array_flip( array( 'integer number', 'stdClass object input', 'default', 'text-field format' ) ) - ); - } - /** * Tests coercion after validation and consistent input throughout execution. * * @ticket 66383 - * @dataProvider data_input_coercion + * @dataProvider data_execute_coerces_validated_input * * @param array $schema Input schema. * @param mixed $input Original input. @@ -2427,39 +2415,14 @@ static function ( $name, $value ) use ( &$seen ) { } /** - * Provides top-level and nested collisions introduced by sanitization. + * Provides representative inputs for execution lifecycle integration. * * @return array */ - public static function data_input_sanitization_errors(): array { - $unique = array( - 'type' => 'array', - 'items' => array( 'type' => 'integer' ), - 'uniqueItems' => true, - ); - $object = array( - 'type' => 'object', - 'properties' => array( - 'flag' => array( 'type' => 'boolean' ), - 'ids' => $unique, - ), - ); - $input = array( - 'flag' => 'false', - 'ids' => '1,01', - ); - - return array( - 'top-level array' => array( $unique, array( '1', '01' ), 'input' ), - 'nested object' => array( $object, $input, 'input[ids]' ), - 'object in list' => array( - array( - 'type' => 'array', - 'items' => $object, - ), - array( $input ), - 'input[0][ids]', - ), + public static function data_execute_coerces_validated_input(): array { + return array_intersect_key( + self::data_input_is_coerced(), + array_flip( array( 'integer number', 'stdClass object input', 'default', 'text-field format' ) ) ); } @@ -2496,6 +2459,43 @@ public function test_input_sanitization_errors( array $schema, $input, string $p $this->assertEquals( $error, $ability->execute( $input ), 'Execution should propagate the sanitization error.' ); } + /** + * Provides top-level and nested collisions introduced by sanitization. + * + * @return array + */ + public static function data_input_sanitization_errors(): array { + $unique = array( + 'type' => 'array', + 'items' => array( 'type' => 'integer' ), + 'uniqueItems' => true, + ); + $object = array( + 'type' => 'object', + 'properties' => array( + 'flag' => array( 'type' => 'boolean' ), + 'ids' => $unique, + ), + ); + $input = array( + 'flag' => 'false', + 'ids' => '1,01', + ); + + return array( + 'top-level array' => array( $unique, array( '1', '01' ), 'input' ), + 'nested object' => array( $object, $input, 'input[ids]' ), + 'object in list' => array( + array( + 'type' => 'array', + 'items' => $object, + ), + array( $input ), + 'input[0][ids]', + ), + ); + } + /** * Tests that sanitization cannot rescue invalid input or bypass validation filters. * @@ -2575,18 +2575,6 @@ private function create_custom_class_ability( array $args ): WP_Ability { return new class( self::$test_ability_name, $args ) extends WP_Ability {}; } - /** - * Data provider for required capabilities that default to an empty array. - * - * @return array}> - */ - public static function data_required_capabilities_default_to_empty_array(): array { - return array( - 'not set' => array( array() ), - 'null' => array( array( 'required_capabilities' => null ) ), - ); - } - /** * Tests that required capabilities default to an empty array. * @@ -2605,6 +2593,18 @@ public function test_required_capabilities_default_to_empty_array( array $overri $this->assertSame( array(), $ability->get_required_capabilities() ); } + /** + * Data provider for required capabilities that default to an empty array. + * + * @return array}> + */ + public static function data_required_capabilities_default_to_empty_array(): array { + return array( + 'not set' => array( array() ), + 'null' => array( array( 'required_capabilities' => null ) ), + ); + } + /** * Tests that an ability can declare required capabilities without a permission callback. * @@ -2653,25 +2653,6 @@ public function test_invalid_permission_callback_with_required_capabilities_thro new WP_Ability( self::$test_ability_name, $args ); } - /** - * Data provider for invalid required capabilities. - * - * @return array - */ - public static function data_invalid_required_capabilities(): array { - return array( - 'string' => array( 'manage_options' ), - 'empty string' => array( array( '' ) ), - 'whitespace only' => array( array( " \t" ) ), - 'non-string' => array( array( 'read', 1 ) ), - 'associative' => array( array( 'cap' => 'manage_options' ) ), - 'non-sequential' => array( array( 1 => 'manage_options' ) ), - 'nested array' => array( array( array( 'manage_options' ) ) ), - 'boolean' => array( true ), - 'null in the list' => array( array( null ) ), - ); - } - /** * Tests that invalid required capabilities throw an exception. * @@ -2679,7 +2660,7 @@ public static function data_invalid_required_capabilities(): array { * * @covers WP_Ability::prepare_properties * - * @dataProvider data_invalid_required_capabilities + * @dataProvider data_invalid_required_capabilities_throw_exception * * @param mixed $capabilities The invalid required capabilities. */ @@ -2694,15 +2675,21 @@ public function test_invalid_required_capabilities_throw_exception( $capabilitie } /** - * Data provider for permission checks based on required capabilities. + * Data provider for invalid required capabilities. * - * @return array + * @return array */ - public static function data_check_permissions_with_required_capabilities(): array { + public static function data_invalid_required_capabilities_throw_exception(): array { return array( - 'user has all capabilities' => array( 'administrator', true ), - 'user misses one capability' => array( 'editor', false ), - 'user misses all capabilities' => array( 'subscriber', false ), + 'string' => array( 'manage_options' ), + 'empty string' => array( array( '' ) ), + 'whitespace only' => array( array( " \t" ) ), + 'non-string' => array( array( 'read', 1 ) ), + 'associative' => array( array( 'cap' => 'manage_options' ) ), + 'non-sequential' => array( array( 1 => 'manage_options' ) ), + 'nested array' => array( array( array( 'manage_options' ) ) ), + 'boolean' => array( true ), + 'null in the list' => array( array( null ) ), ); } @@ -2729,6 +2716,19 @@ public function test_check_permissions_with_required_capabilities( string $role, $this->assertSame( $expected, $ability->check_permissions() ); } + /** + * Data provider for permission checks based on required capabilities. + * + * @return array + */ + public static function data_check_permissions_with_required_capabilities(): array { + return array( + 'user has all capabilities' => array( 'administrator', true ), + 'user misses one capability' => array( 'editor', false ), + 'user misses all capabilities' => array( 'subscriber', false ), + ); + } + /** * Tests that the permission callback doesn't run when a required capability is missing. * @@ -2807,6 +2807,27 @@ public function test_permission_result_filter_can_grant_missing_required_capabil $this->assertSame( 0, $result, 'The filter should be able to grant a missing required capability.' ); } + /** + * Tests that check_permissions() returns an error when a custom class has no valid + * permission callback, even if the user has all required capabilities. + * + * @ticket 66325 + * + * @covers WP_Ability::check_permissions + * + * @dataProvider data_check_permissions_custom_class_without_valid_permission_check + * + * @param array $overrides The properties to merge into the test ability properties. + */ + public function test_check_permissions_custom_class_without_valid_permission_check( array $overrides ) { + wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); + + $result = $this->create_custom_class_ability( array_merge( self::$test_ability_properties, $overrides ) )->check_permissions(); + + $this->assertWPError( $result ); + $this->assertSame( 'ability_invalid_permission_callback', $result->get_error_code() ); + } + /** * Data provider for custom class abilities without a valid permission check. * @@ -2829,27 +2850,6 @@ public static function data_check_permissions_custom_class_without_valid_permiss ); } - /** - * Tests that check_permissions() returns an error when a custom class has no valid - * permission callback, even if the user has all required capabilities. - * - * @ticket 66325 - * - * @covers WP_Ability::check_permissions - * - * @dataProvider data_check_permissions_custom_class_without_valid_permission_check - * - * @param array $overrides The properties to merge into the test ability properties. - */ - public function test_check_permissions_custom_class_without_valid_permission_check( array $overrides ) { - wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) ); - - $result = $this->create_custom_class_ability( array_merge( self::$test_ability_properties, $overrides ) )->check_permissions(); - - $this->assertWPError( $result ); - $this->assertSame( 'ability_invalid_permission_callback', $result->get_error_code() ); - } - /** * Tests that check_permissions() works for a custom class with only required capabilities. * diff --git a/tests/phpunit/tests/abilities-api/wpGetAbilities.php b/tests/phpunit/tests/abilities-api/wpGetAbilities.php index 3618a4070bc34..6548a5d1d930c 100644 --- a/tests/phpunit/tests/abilities-api/wpGetAbilities.php +++ b/tests/phpunit/tests/abilities-api/wpGetAbilities.php @@ -832,6 +832,27 @@ private function register_abilities_with_required_capabilities(): void { ); } + /** + * Tests that the has_required_capabilities filter leaves out abilities whose declared + * capabilities the current user lacks. Abilities without required capabilities stay. + * + * @ticket 66325 + * + * @dataProvider data_filter_by_has_required_capabilities + * + * @param string $role The role of the current user. Empty for a logged-out user. + * @param array $args The arguments passed to wp_get_abilities(). + * @param string[] $expected The expected ability names. + */ + public function test_filter_by_has_required_capabilities( string $role, array $args, array $expected ): void { + $this->register_abilities_with_required_capabilities(); + wp_set_current_user( '' === $role ? 0 : self::factory()->user->create( array( 'role' => $role ) ) ); + + $result = wp_get_abilities( array_merge( array( 'namespace' => 'test' ), $args ) ); + + $this->assertSameSets( $expected, array_keys( $result ) ); + } + /** * Data provider for filtering by the current user's required capabilities. * @@ -857,27 +878,6 @@ public static function data_filter_by_has_required_capabilities(): array { ); } - /** - * Tests that the has_required_capabilities filter leaves out abilities whose declared - * capabilities the current user lacks. Abilities without required capabilities stay. - * - * @ticket 66325 - * - * @dataProvider data_filter_by_has_required_capabilities - * - * @param string $role The role of the current user. Empty for a logged-out user. - * @param array $args The arguments passed to wp_get_abilities(). - * @param string[] $expected The expected ability names. - */ - public function test_filter_by_has_required_capabilities( string $role, array $args, array $expected ): void { - $this->register_abilities_with_required_capabilities(); - wp_set_current_user( '' === $role ? 0 : self::factory()->user->create( array( 'role' => $role ) ) ); - - $result = wp_get_abilities( array_merge( array( 'namespace' => 'test' ), $args ) ); - - $this->assertSameSets( $expected, array_keys( $result ) ); - } - /** * Tests that the has_required_capabilities filter doesn't call permission callbacks. * diff --git a/tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php b/tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php index 0f23eb7831177..1ab7533f496ed 100644 --- a/tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php +++ b/tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php @@ -533,7 +533,7 @@ public static function data_core_ability_field_lists(): array { * * @ticket 66493 * - * @dataProvider data_users_who_cannot_manage_options + * @dataProvider data_core_get_site_info_denies_users_who_cannot_manage_options * * @param string $role Role of the current user, or an empty string for a logged-out visitor. */ @@ -555,7 +555,7 @@ public function test_core_get_site_info_denies_users_who_cannot_manage_options( * * @return array[] */ - public static function data_users_who_cannot_manage_options(): array { + public static function data_core_get_site_info_denies_users_who_cannot_manage_options(): array { return array( 'subscriber' => array( 'subscriber' ), 'logged-out user' => array( '' ), diff --git a/tests/phpunit/tests/abilities-api/wpRegisterCoreContentAbility.php b/tests/phpunit/tests/abilities-api/wpRegisterCoreContentAbility.php index 0a6b9fd447093..9442b1550d36e 100644 --- a/tests/phpunit/tests/abilities-api/wpRegisterCoreContentAbility.php +++ b/tests/phpunit/tests/abilities-api/wpRegisterCoreContentAbility.php @@ -859,34 +859,12 @@ public function test_exposes_a_post_type_registered_by_another_plugin(): void { $this->assertContains( $post_id, $ids, 'The custom post type should be queryable through the content ability.' ); } - /** - * Returns `show_in_abilities` values other than `true`. - * - * @return array Non-boolean `show_in_abilities` test cases. - */ - public static function data_show_in_abilities_values_other_than_true(): array { - return array( - 'false' => array( - 'value' => false, - ), - 'array of operations' => array( - 'value' => array( 'create' ), - ), - 'string "false"' => array( - 'value' => 'false', - ), - 'integer 1' => array( - 'value' => 1, - ), - ); - } - /** * Only a `show_in_abilities` value of `true` exposes a post type, so other values, such as * arrays, can be given a meaning later. * * @ticket 66268 - * @dataProvider data_show_in_abilities_values_other_than_true + * @dataProvider data_does_not_expose_a_post_type_with_a_show_in_abilities_value_other_than_true * @since 7.2.0 * * @param mixed $value The `show_in_abilities` value to register the post type with. @@ -928,6 +906,28 @@ public function test_does_not_expose_a_post_type_with_a_show_in_abilities_value_ $this->assertSame( 'ability_invalid_input', $result->get_error_code(), 'A query of the post type should fail validation.' ); } + /** + * Returns `show_in_abilities` values other than `true`. + * + * @return array Non-boolean `show_in_abilities` test cases. + */ + public static function data_does_not_expose_a_post_type_with_a_show_in_abilities_value_other_than_true(): array { + return array( + 'false' => array( + 'value' => false, + ), + 'array of operations' => array( + 'value' => array( 'create' ), + ), + 'string "false"' => array( + 'value' => 'false', + ), + 'integer 1' => array( + 'value' => 1, + ), + ); + } + /** * A schema filter can expose a post type that is registered after the ability, by adding it * to the `type` enum of `where`. @@ -1138,13 +1138,32 @@ public function test_query_by_id_can_return_content_fields(): void { ); } + /** + * A query whose IDs or slugs match no post of the post type returns the empty result, + * rather than an error. + * + * @ticket 66268 + * @dataProvider data_ids_or_slugs_that_match_no_post_return_the_empty_result + * @since 7.2.0 + * + * @param array $where The `where` value to send. + */ + public function test_ids_or_slugs_that_match_no_post_return_the_empty_result( array $where ): void { + $this->login_as( 'administrator' ); + $this->register_ability(); + + $result = wp_get_ability( 'core/content-query' )->execute( array( 'where' => $where ) ); + + $this->assertSame( self::EMPTY_RESULT, $result, 'A query whose IDs or slugs match no post should return the empty result.' ); + } + /** * Returns `where` values whose IDs or slugs match no post of the post type: a missing ID * and a slug that no post has. * * @return array}> The `where` values. */ - public static function data_where_values_that_match_no_post(): array { + public static function data_ids_or_slugs_that_match_no_post_return_the_empty_result(): array { return array( 'missing ID' => array( 'where' => array( @@ -1161,25 +1180,6 @@ public static function data_where_values_that_match_no_post(): array { ); } - /** - * A query whose IDs or slugs match no post of the post type returns the empty result, - * rather than an error. - * - * @ticket 66268 - * @dataProvider data_where_values_that_match_no_post - * @since 7.2.0 - * - * @param array $where The `where` value to send. - */ - public function test_ids_or_slugs_that_match_no_post_return_the_empty_result( array $where ): void { - $this->login_as( 'administrator' ); - $this->register_ability(); - - $result = wp_get_ability( 'core/content-query' )->execute( array( 'where' => $where ) ); - - $this->assertSame( self::EMPTY_RESULT, $result, 'A query whose IDs or slugs match no post should return the empty result.' ); - } - /** * A post in a status that is public but not viewable is returned only to users who can edit * it. @@ -1232,40 +1232,12 @@ public function test_public_non_viewable_status_is_returned_only_with_edit_acces ); } - /** - * Returns `where` filters that name a post in the publicly viewable `public_archive` status. - * - * @return array}> Filter test cases. - */ - public static function data_filters_naming_a_post_in_a_viewable_custom_status(): array { - return array( - 'ids' => array( - 'where' => array( - 'type' => 'post', - 'ids' => array( self::IMPORTED_POST_ID ), - ), - ), - 'slugs' => array( - 'where' => array( - 'type' => 'post', - 'slugs' => array( 'public-archive-post' ), - ), - ), - 'status' => array( - 'where' => array( - 'type' => 'post', - 'status' => array( 'public_archive' ), - ), - ), - ); - } - /** * A post in a publicly viewable custom status is returned to a subscriber, who cannot edit * it, whether the query names it by ID, by slug or by status. * * @ticket 66268 - * @dataProvider data_filters_naming_a_post_in_a_viewable_custom_status + * @dataProvider data_viewable_custom_status_is_readable_by_subscribers * @since 7.2.0 * * @param array $where The `where` filters. @@ -1313,6 +1285,34 @@ public function test_viewable_custom_status_is_readable_by_subscribers( array $w ); } + /** + * Returns `where` filters that name a post in the publicly viewable `public_archive` status. + * + * @return array}> Filter test cases. + */ + public static function data_viewable_custom_status_is_readable_by_subscribers(): array { + return array( + 'ids' => array( + 'where' => array( + 'type' => 'post', + 'ids' => array( self::IMPORTED_POST_ID ), + ), + ), + 'slugs' => array( + 'where' => array( + 'type' => 'post', + 'slugs' => array( 'public-archive-post' ), + ), + ), + 'status' => array( + 'where' => array( + 'type' => 'post', + 'status' => array( 'public_archive' ), + ), + ), + ); + } + /** * Registers the exposed `inherit_cpt` post type, and adds the `inherit` status to the * ability's queries for it. @@ -1886,25 +1886,6 @@ public function test_ids_and_slugs_together_return_only_posts_in_both_lists(): v ); } - /** - * Returns a role that cannot read another user's draft and a role that can, with the posts - * that share a slug that each role gets, newest first. - * - * @return array}> Role test cases. - */ - public static function data_roles_with_and_without_access_to_others_drafts(): array { - return array( - 'subscriber' => array( - 'role' => 'subscriber', - 'expected' => array( 'published' ), - ), - 'editor' => array( - 'role' => 'editor', - 'expected' => array( 'draft', 'published' ), - ), - ); - } - /** * A newer draft that shares a published post's slug comes back next to the published post * for a role that can read the draft, and is withheld from a role that cannot. @@ -1913,7 +1894,7 @@ public static function data_roles_with_and_without_access_to_others_drafts(): ar * drafts, while an editor's do. * * @ticket 66268 - * @dataProvider data_roles_with_and_without_access_to_others_drafts + * @dataProvider data_slugs_return_a_newer_draft_sharing_the_slug_only_to_roles_that_can_read_it * @since 7.2.0 * * @param string $role The role to query the slug as. @@ -1967,6 +1948,25 @@ static function ( string $name ) use ( $posts ): int { $this->assertCount( $result['pagination']['total'], $expected, 'The total should count every post with the slug in the statuses the role may query.' ); } + /** + * Returns a role that cannot read another user's draft and a role that can, with the posts + * that share a slug that each role gets, newest first. + * + * @return array}> Role test cases. + */ + public static function data_slugs_return_a_newer_draft_sharing_the_slug_only_to_roles_that_can_read_it(): array { + return array( + 'subscriber' => array( + 'role' => 'subscriber', + 'expected' => array( 'published' ), + ), + 'editor' => array( + 'role' => 'editor', + 'expected' => array( 'draft', 'published' ), + ), + ); + } + /** * An unknown requested field path fails schema validation. * @@ -1994,12 +1994,42 @@ public function test_unknown_requested_field_fails_schema_validation(): void { $this->assertSame( 'ability_invalid_input', $result->get_error_code(), 'Unknown fields should use the invalid input error.' ); } + /** + * A sub-field path returns only that sub-field, inside its object. + * + * @ticket 66268 + * @dataProvider data_sub_field_path_returns_only_that_sub_field + * @since 7.2.0 + * + * @param string $field The field path to request, such as `title.rendered`. + */ + public function test_sub_field_path_returns_only_that_sub_field( string $field ): void { + $this->login_as( 'administrator' ); + $this->register_ability(); + + list( $object, $key ) = explode( '.', $field ); + + $result = wp_get_ability( 'core/content-query' )->execute( + array( + 'where' => array( + 'type' => 'post', + 'ids' => array( self::$post_ids['limited_role_content'] ), + ), + 'fields' => array( $field ), + ) + ); + + $this->assertIsArray( $result, 'The query should succeed.' ); + $this->assertSameSets( array( 'id', $object ), array_keys( $result['items'][0] ), 'Only the ID and the object that holds the sub-field should be returned.' ); + $this->assertSame( array( $key ), array_keys( $result['items'][0][ $object ] ), 'The object should hold only the requested sub-field.' ); + } + /** * Returns field paths that each name one sub-field. * * @return array Field path test cases. */ - public static function data_sub_field_paths(): array { + public static function data_sub_field_path_returns_only_that_sub_field(): array { return array( 'title.rendered' => array( 'field' => 'title.rendered', @@ -2029,20 +2059,19 @@ public static function data_sub_field_paths(): array { } /** - * A sub-field path returns only that sub-field, inside its object. + * A whole object returns every key it holds to a user who can edit the post. * * @ticket 66268 - * @dataProvider data_sub_field_paths + * @dataProvider data_whole_object_returns_every_key_to_a_user_who_can_edit_the_post * @since 7.2.0 * - * @param string $field The field path to request, such as `title.rendered`. + * @param string $field The object field to request. + * @param list $keys The keys the object should hold, in order. */ - public function test_sub_field_path_returns_only_that_sub_field( string $field ): void { + public function test_whole_object_returns_every_key_to_a_user_who_can_edit_the_post( string $field, array $keys ): void { $this->login_as( 'administrator' ); $this->register_ability(); - list( $object, $key ) = explode( '.', $field ); - $result = wp_get_ability( 'core/content-query' )->execute( array( 'where' => array( @@ -2054,8 +2083,8 @@ public function test_sub_field_path_returns_only_that_sub_field( string $field ) ); $this->assertIsArray( $result, 'The query should succeed.' ); - $this->assertSameSets( array( 'id', $object ), array_keys( $result['items'][0] ), 'Only the ID and the object that holds the sub-field should be returned.' ); - $this->assertSame( array( $key ), array_keys( $result['items'][0][ $object ] ), 'The object should hold only the requested sub-field.' ); + $this->assertSame( array( 'id', $field ), array_keys( $result['items'][0] ), 'Only the ID and the requested object should be returned.' ); + $this->assertSame( $keys, array_keys( $result['items'][0][ $field ] ), 'The object should hold every key, in order.' ); } /** @@ -2063,7 +2092,7 @@ public function test_sub_field_path_returns_only_that_sub_field( string $field ) * * @return array}> Object field test cases. */ - public static function data_object_fields(): array { + public static function data_whole_object_returns_every_key_to_a_user_who_can_edit_the_post(): array { return array( 'title' => array( 'field' => 'title', @@ -2092,35 +2121,6 @@ public static function data_object_fields(): array { ); } - /** - * A whole object returns every key it holds to a user who can edit the post. - * - * @ticket 66268 - * @dataProvider data_object_fields - * @since 7.2.0 - * - * @param string $field The object field to request. - * @param list $keys The keys the object should hold, in order. - */ - public function test_whole_object_returns_every_key_to_a_user_who_can_edit_the_post( string $field, array $keys ): void { - $this->login_as( 'administrator' ); - $this->register_ability(); - - $result = wp_get_ability( 'core/content-query' )->execute( - array( - 'where' => array( - 'type' => 'post', - 'ids' => array( self::$post_ids['limited_role_content'] ), - ), - 'fields' => array( $field ), - ) - ); - - $this->assertIsArray( $result, 'The query should succeed.' ); - $this->assertSame( array( 'id', $field ), array_keys( $result['items'][0] ), 'Only the ID and the requested object should be returned.' ); - $this->assertSame( $keys, array_keys( $result['items'][0][ $field ] ), 'The object should hold every key, in order.' ); - } - /** * Whole title, excerpt and content objects leave out the raw values for users who cannot * edit the post, rather than failing the request. @@ -2406,7 +2406,7 @@ public function test_author_object_describes_the_author(): void { * @ticket 66268 * @since 7.2.0 * - * @dataProvider data_author_visibility + * @dataProvider data_author_name_and_slug_are_returned_to_users_who_may_see_the_author * * @param string $role The role that reads the post, or `self` for the author. * @param string $post_status The status of the author's only post. @@ -2484,7 +2484,7 @@ public function test_author_name_and_slug_are_returned_to_users_who_may_see_the_ * * @return array */ - public static function data_author_visibility(): array { + public static function data_author_name_and_slug_are_returned_to_users_who_may_see_the_author(): array { return array( 'editor, pending post' => array( 'role' => 'editor', @@ -2912,34 +2912,13 @@ public function test_raw_field_requests_omit_raw_values_for_roles_without_edit_a } /** - * Returns statuses that are neither publicly viewable nor `private`: a draft, a public status - * that is not viewable, and a custom status flagged private, which WP_Query does not narrow - * to the current user's own posts as it does `private`. + * Subscribers cannot request posts in a status that requires edit access. * - * @return array Status test cases. - */ - public static function data_statuses_that_require_edit_access(): array { - return array( - 'draft' => array( - 'status' => 'draft', - ), - 'public status, not viewable' => array( - 'status' => 'public_hidden', - ), - 'custom status flagged private' => array( - 'status' => 'members_only', - ), - ); - } - - /** - * Subscribers cannot request posts in a status that requires edit access. - * - * @ticket 66268 - * @dataProvider data_statuses_that_require_edit_access - * @since 7.2.0 - * - * @param string $status The status to request. + * @ticket 66268 + * @dataProvider data_subscriber_cannot_request_statuses_that_require_edit_access + * @since 7.2.0 + * + * @param string $status The status to request. */ public function test_subscriber_cannot_request_statuses_that_require_edit_access( string $status ): void { register_post_status( @@ -2974,6 +2953,27 @@ public function test_subscriber_cannot_request_statuses_that_require_edit_access $this->assertSame( 'ability_invalid_permissions', $result->get_error_code(), 'A subscriber query for a status that requires edit access should return a permission error.' ); } + /** + * Returns statuses that are neither publicly viewable nor `private`: a draft, a public status + * that is not viewable, and a custom status flagged private, which WP_Query does not narrow + * to the current user's own posts as it does `private`. + * + * @return array Status test cases. + */ + public static function data_subscriber_cannot_request_statuses_that_require_edit_access(): array { + return array( + 'draft' => array( + 'status' => 'draft', + ), + 'public status, not viewable' => array( + 'status' => 'public_hidden', + ), + 'custom status flagged private' => array( + 'status' => 'members_only', + ), + ); + } + /** * Subscribers can query private posts, and get only their own. * @@ -3296,39 +3296,6 @@ public function test_query_totals_may_include_rows_withheld_by_row_level_permiss $this->assertSame( 1, $result['pagination']['total_pages'], 'Page counts should be based on the underlying query total, matching REST behavior.' ); } - /** - * Returns roles with the posts that a query by ID without a status returns to them, and the - * total they get. - * - * The posts are named by status and by owner: the `own_` posts belong to the `author` role, - * and the published post and the `other_` posts to another author. - * - * The total counts the posts that the query covers, including withheld ones. Another user's - * private post is only covered with `read_private_posts`, so the subscriber's and the - * author's totals leave it out while the editor's counts it. - * - * @return array, total: int}> Role test cases. - */ - public static function data_default_statuses_with_ids_by_role(): array { - return array( - 'subscriber' => array( - 'role' => 'subscriber', - 'expected' => array( 'publish' ), - 'total' => 1, - ), - 'author' => array( - 'role' => 'author', - 'expected' => array( 'publish', 'own_draft', 'own_pending', 'own_future', 'own_private' ), - 'total' => 8, - ), - 'editor' => array( - 'role' => 'editor', - 'expected' => array( 'publish', 'own_draft', 'own_pending', 'own_future', 'own_private', 'other_draft', 'other_pending', 'other_future', 'other_private' ), - 'total' => 9, - ), - ); - } - /** * A query by ID without a status covers every status that the current user may query, and * returns the posts in them that the user may read. @@ -3340,7 +3307,7 @@ public static function data_default_statuses_with_ids_by_role(): array { * posts in every status. * * @ticket 66268 - * @dataProvider data_default_statuses_with_ids_by_role + * @dataProvider data_ids_without_a_status_cover_the_statuses_each_role_may_query * @since 7.2.0 * * @param string $role The role to query as. @@ -3399,6 +3366,39 @@ public function test_ids_without_a_status_cover_the_statuses_each_role_may_query $this->assertSame( $total, $result['pagination']['total'], 'The total should count every post the query covers, including withheld ones.' ); } + /** + * Returns roles with the posts that a query by ID without a status returns to them, and the + * total they get. + * + * The posts are named by status and by owner: the `own_` posts belong to the `author` role, + * and the published post and the `other_` posts to another author. + * + * The total counts the posts that the query covers, including withheld ones. Another user's + * private post is only covered with `read_private_posts`, so the subscriber's and the + * author's totals leave it out while the editor's counts it. + * + * @return array, total: int}> Role test cases. + */ + public static function data_ids_without_a_status_cover_the_statuses_each_role_may_query(): array { + return array( + 'subscriber' => array( + 'role' => 'subscriber', + 'expected' => array( 'publish' ), + 'total' => 1, + ), + 'author' => array( + 'role' => 'author', + 'expected' => array( 'publish', 'own_draft', 'own_pending', 'own_future', 'own_private' ), + 'total' => 8, + ), + 'editor' => array( + 'role' => 'editor', + 'expected' => array( 'publish', 'own_draft', 'own_pending', 'own_future', 'own_private', 'other_draft', 'other_pending', 'other_future', 'other_private' ), + 'total' => 9, + ), + ); + } + /** * An author gets their own draft from a query by ID or by slug that gives no status, but * not from a query without IDs or slugs, whose default status stays `publish`, nor from a @@ -4471,29 +4471,12 @@ public function test_rendered_fields_without_a_global_post_keep_an_earlier_the_p $this->assertSame( $the_post_count + 1, did_action( 'the_post' ), 'The ability should keep the `the_post` count of a loop that had already started.' ); } - /** - * Returns the posts whose `the_post` callbacks throw: the requested post, as it is set - * up, and the surrounding post, as it is set up again afterwards. - * - * @return array Throwing post test cases. - */ - public static function data_posts_whose_the_post_callbacks_throw(): array { - return array( - 'requested post' => array( - 'throwing_post' => 'limited_role_content', - ), - 'surrounding post' => array( - 'throwing_post' => 'published', - ), - ); - } - /** * A `the_post` callback that throws fails the query without leaving the requested post * in the loop globals. * * @ticket 66268 - * @dataProvider data_posts_whose_the_post_callbacks_throw + * @dataProvider data_post_context_is_restored_when_a_the_post_callback_throws * @since 7.2.0 * * @param string $throwing_post The fixture name of the post whose `the_post` callback throws. @@ -4541,6 +4524,23 @@ static function ( WP_Post $post ) use ( $throwing_post_id ): void { $this->assertSame( $surrounding_globals, $this->get_loop_globals(), 'The surrounding loop globals should be restored as they were.' ); } + /** + * Returns the posts whose `the_post` callbacks throw: the requested post, as it is set + * up, and the surrounding post, as it is set up again afterwards. + * + * @return array Throwing post test cases. + */ + public static function data_post_context_is_restored_when_a_the_post_callback_throws(): array { + return array( + 'requested post' => array( + 'throwing_post' => 'limited_role_content', + ), + 'surrounding post' => array( + 'throwing_post' => 'published', + ), + ); + } + /** * Returns the loop globals that are set, keyed by name. * @@ -4681,21 +4681,6 @@ public function test_query_out_of_range_page_is_rejected_rather_than_reported_as $this->assertSame( 404, $result->get_error_data()['status'], 'An out-of-range page should be reported as not found.' ); } - /** - * Returns whole numbers that the integer schema accepts but that are not PHP integers, - * as a page, a page size, and a page past the last one. - * - * @return array The values to send. - */ - public static function data_whole_numbers_that_are_not_integers(): array { - return array( - 'floats' => array( 2.0, 2.0, 99.0 ), - 'decimal strings' => array( '2.0', '2.0', '99.0' ), - 'signed strings' => array( '+2', '+2', '+99' ), - 'strings with a space' => array( ' 2', ' 2', ' 99' ), - ); - } - /** * A `pagination.page` and `pagination.per_page` that the integer schema accepts are honored * even when they are not PHP integers, as when the MCP adapter passes the 2.0 a JSON encoder @@ -4706,7 +4691,7 @@ public static function data_whole_numbers_that_are_not_integers(): array { * a page past the last one. * * @ticket 66268 - * @dataProvider data_whole_numbers_that_are_not_integers + * @dataProvider data_query_honors_a_page_and_per_page_that_are_not_integers * @since 7.2.0 * * @param float|string $page The page to request. @@ -4738,6 +4723,21 @@ public function test_query_honors_a_page_and_per_page_that_are_not_integers( $pa $this->assertSame( 'content_invalid_page_number', $result->get_error_code(), 'A page past the last one should report the out-of-range error.' ); } + /** + * Returns whole numbers that the integer schema accepts but that are not PHP integers, + * as a page, a page size, and a page past the last one. + * + * @return array The values to send. + */ + public static function data_query_honors_a_page_and_per_page_that_are_not_integers(): array { + return array( + 'floats' => array( 2.0, 2.0, 99.0 ), + 'decimal strings' => array( '2.0', '2.0', '99.0' ), + 'signed strings' => array( '+2', '+2', '+99' ), + 'strings with a space' => array( ' 2', ' 2', ' 99' ), + ); + } + /** * Returns {@see self::IMPORTED_POST_ID} in forms that the integer schema accepts but that * are not PHP integers. @@ -4875,26 +4875,6 @@ public function test_query_empty_result_beyond_first_page_reports_zero_totals(): $this->assertSame( 0, $result['pagination']['total_pages'], 'An empty result set reports zero pages.' ); } - /** - * Returns page sizes that a query filter can set, with the pages they make of five posts. - * - * @return array Page size test cases. - */ - public static function data_page_sizes_set_by_a_query_filter(): array { - return array( - 'smaller page size' => array( - 'posts_per_page' => 2, - 'total_pages' => 3, - 'last_page_count' => 1, - ), - 'no paging' => array( - 'posts_per_page' => -1, - 'total_pages' => 1, - 'last_page_count' => 5, - ), - ); - } - /** * A query counts the pages with the page size it ran with. * @@ -4904,7 +4884,7 @@ public static function data_page_sizes_set_by_a_query_filter(): array { * hold posts or serve the same posts again. * * @ticket 66268 - * @dataProvider data_page_sizes_set_by_a_query_filter + * @dataProvider data_query_counts_pages_with_the_page_size_the_query_ran_with * @since 7.2.0 * * @param int $posts_per_page The page size the query filter sets. @@ -4952,6 +4932,26 @@ static function ( WP_Query $query ) use ( $posts_per_page ): void { $this->assertSame( 'content_invalid_page_number', $past_last_page->get_error_code(), 'Paging past the last page should report the page number error.' ); } + /** + * Returns page sizes that a query filter can set, with the pages they make of five posts. + * + * @return array Page size test cases. + */ + public static function data_query_counts_pages_with_the_page_size_the_query_ran_with(): array { + return array( + 'smaller page size' => array( + 'posts_per_page' => 2, + 'total_pages' => 3, + 'last_page_count' => 1, + ), + 'no paging' => array( + 'posts_per_page' => -1, + 'total_pages' => 1, + 'last_page_count' => 5, + ), + ); + } + /** * IDs return every requested post when `pagination.per_page` is omitted. * @@ -4987,29 +4987,6 @@ public function test_query_ids_return_every_requested_post_without_per_page(): v $this->assertSame( 1, $result['pagination']['total_pages'], 'The requested posts should fit on a single page by default.' ); } - /** - * Returns the field paths that request a rendered excerpt or content, either directly or - * through the whole object. - * - * @return array Post meta priming test cases. - */ - public static function data_fields_that_prime_post_meta(): array { - return array( - 'content.rendered' => array( - 'field' => 'content.rendered', - ), - 'excerpt.rendered' => array( - 'field' => 'excerpt.rendered', - ), - 'whole content' => array( - 'field' => 'content', - ), - 'whole excerpt' => array( - 'field' => 'excerpt', - ), - ); - } - /** * Requesting rendered fields primes the post meta cache for the whole page. * @@ -5018,7 +4995,7 @@ public static function data_fields_that_prime_post_meta(): array { * its rendered value. * * @ticket 66268 - * @dataProvider data_fields_that_prime_post_meta + * @dataProvider data_query_rendered_fields_prime_the_post_meta_cache * @since 7.2.0 * * @param string $field The field path to request. @@ -5054,6 +5031,29 @@ static function () use ( $ids, $field ) { $this->assertSame( 1, $postmeta_queries, 'Rendered field requests should prime post meta with a single batched query, not one per returned post.' ); } + /** + * Returns the field paths that request a rendered excerpt or content, either directly or + * through the whole object. + * + * @return array Post meta priming test cases. + */ + public static function data_query_rendered_fields_prime_the_post_meta_cache(): array { + return array( + 'content.rendered' => array( + 'field' => 'content.rendered', + ), + 'excerpt.rendered' => array( + 'field' => 'excerpt.rendered', + ), + 'whole content' => array( + 'field' => 'content', + ), + 'whole excerpt' => array( + 'field' => 'excerpt', + ), + ); + } + /** * A query primes the authors of the whole page. * @@ -5545,21 +5545,60 @@ public function test_gmt_date_is_null_when_no_usable_date_exists( string $field, } /** - * Data provider for date field paths. + * A malformed stored date reports null instead of failing output validation. * + * A zero month still parses, but formats with a negative year, which the `date-time` + * format of the output schema rejects. + * + * @ticket 66268 * @since 7.2.0 * - * @return array + * @dataProvider data_malformed_date_is_null + * + * @param string $field The field path to request, such as `date.site`. + * @param string $column The cached post column to corrupt. */ - public static function data_date_fields(): array { - return array( - 'date.site' => array( - 'field' => 'date.site', - 'column' => 'post_date', - ), - 'date.gmt' => array( - 'field' => 'date.gmt', - 'column' => 'post_date_gmt', + public function test_malformed_date_is_null( string $field, string $column ): void { + $this->login_as( 'administrator' ); + $this->register_ability(); + + $post_id = self::factory()->post->create( array( 'post_status' => 'publish' ) ); + + $this->replace_cached_post_date_columns( $post_id, array( $column => '0000-00-01 00:00:00' ) ); + + list( $object, $key ) = explode( '.', $field ); + + $result = wp_get_ability( 'core/content-query' )->execute( + array( + 'where' => array( + 'type' => 'post', + 'ids' => array( $post_id ), + ), + 'fields' => array( 'id', $field ), + ) + ); + + $this->assertIsArray( $result, 'A malformed date should pass output validation.' ); + $this->assertArrayHasKey( $key, $result['items'][0][ $object ], 'A malformed date should still be returned.' ); + $this->assertNull( $result['items'][0][ $object ][ $key ], 'A malformed date should be null.' ); + } + + /** + * Data provider for date field paths. + * + * @since 7.2.0 + * + * @return array + */ + public static function data_malformed_date_is_null(): array { + return array( + 'date.site' => array( + 'field' => 'date.site', + 'column' => 'post_date', + ), + 'date.gmt' => array( + 'field' => 'date.gmt', + 'column' => 'post_date_gmt', ), 'modified.site' => array( 'field' => 'modified.site', @@ -5573,42 +5612,36 @@ public static function data_date_fields(): array { } /** - * A malformed stored date reports null instead of failing output validation. - * - * A zero month still parses, but formats with a negative year, which the `date-time` - * format of the output schema rejects. + * Called directly, an author filter that is not an object holding an ID or a slug is + * rejected rather than dropped, which would widen the query to every author's posts. * * @ticket 66268 + * @dataProvider data_execute_callback_rejects_an_author_filter_without_an_id_or_a_slug * @since 7.2.0 * - * @dataProvider data_date_fields - * - * @param string $field The field path to request, such as `date.site`. - * @param string $column The cached post column to corrupt. + * @param mixed $author The `where.author` value to send. */ - public function test_malformed_date_is_null( string $field, string $column ): void { + public function test_execute_callback_rejects_an_author_filter_without_an_id_or_a_slug( $author ): void { $this->login_as( 'administrator' ); - $this->register_ability(); - - $post_id = self::factory()->post->create( array( 'post_status' => 'publish' ) ); - - $this->replace_cached_post_date_columns( $post_id, array( $column => '0000-00-01 00:00:00' ) ); - - list( $object, $key ) = explode( '.', $field ); + $execute = $this->get_ability_callbacks()['execute_callback']; - $result = wp_get_ability( 'core/content-query' )->execute( + $result = $execute( array( - 'where' => array( - 'type' => 'post', - 'ids' => array( $post_id ), + 'where' => array( + 'type' => 'post', + 'author' => $author, ), - 'fields' => array( 'id', $field ), ) ); - $this->assertIsArray( $result, 'A malformed date should pass output validation.' ); - $this->assertArrayHasKey( $key, $result['items'][0][ $object ], 'A malformed date should still be returned.' ); - $this->assertNull( $result['items'][0][ $object ][ $key ], 'A malformed date should be null.' ); + $this->assertWPError( $result, 'An author filter without an ID or a slug must not silently widen the query to all authors.' ); + $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'An author filter without an ID or a slug should fail as an invalid filter.' ); + $this->assertSame( + array( 'where[author]' => $result->get_error_message() ), + $result->get_error_data()['params'], + 'The error data should map the malformed author filter to the error message.' + ); + $this->assertSame( 400, $result->get_error_data()['status'], 'The malformed author filter should be reported as a bad request.' ); } /** @@ -5619,7 +5652,7 @@ public function test_malformed_date_is_null( string $field, string $column ): vo * * @return array The `where.author` values. */ - public static function data_author_filters_without_an_id_or_a_slug(): array { + public static function data_execute_callback_rejects_an_author_filter_without_an_id_or_a_slug(): array { return array( 'string' => array( 'author' => 'author-slug', @@ -5658,16 +5691,16 @@ public static function data_author_filters_without_an_id_or_a_slug(): array { } /** - * Called directly, an author filter that is not an object holding an ID or a slug is - * rejected rather than dropped, which would widen the query to every author's posts. + * Called directly, an author ID that is not a positive integer is rejected rather than + * coerced, which could match another user's posts or every author's posts. * * @ticket 66268 - * @dataProvider data_author_filters_without_an_id_or_a_slug + * @dataProvider data_execute_callback_rejects_an_author_id_that_is_not_a_positive_integer * @since 7.2.0 * - * @param mixed $author The `where.author` value to send. + * @param mixed $id The `where.author.id` value to send. */ - public function test_execute_callback_rejects_an_author_filter_without_an_id_or_a_slug( $author ): void { + public function test_execute_callback_rejects_an_author_id_that_is_not_a_positive_integer( $id ): void { $this->login_as( 'administrator' ); $execute = $this->get_ability_callbacks()['execute_callback']; @@ -5675,19 +5708,19 @@ public function test_execute_callback_rejects_an_author_filter_without_an_id_or_ array( 'where' => array( 'type' => 'post', - 'author' => $author, + 'author' => array( 'id' => $id ), ), ) ); - $this->assertWPError( $result, 'An author filter without an ID or a slug must not silently widen the query to all authors.' ); - $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'An author filter without an ID or a slug should fail as an invalid filter.' ); + $this->assertWPError( $result, 'An author ID that is not a positive integer must not be coerced into a query.' ); + $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'An author ID that is not a positive integer should fail as an invalid filter.' ); $this->assertSame( - array( 'where[author]' => $result->get_error_message() ), + array( 'where[author][id]' => $result->get_error_message() ), $result->get_error_data()['params'], - 'The error data should map the malformed author filter to the error message.' + 'The error data should map the malformed author ID to the error message.' ); - $this->assertSame( 400, $result->get_error_data()['status'], 'The malformed author filter should be reported as a bad request.' ); + $this->assertSame( 400, $result->get_error_data()['status'], 'The malformed author ID should be reported as a bad request.' ); } /** @@ -5697,7 +5730,7 @@ public function test_execute_callback_rejects_an_author_filter_without_an_id_or_ * * @return array The `where.author.id` values. */ - public static function data_author_ids_that_are_not_positive_integers(): array { + public static function data_execute_callback_rejects_an_author_id_that_is_not_a_positive_integer(): array { return array( 'zero' => array( 'id' => 0, @@ -5724,36 +5757,47 @@ public static function data_author_ids_that_are_not_positive_integers(): array { } /** - * Called directly, an author ID that is not a positive integer is rejected rather than - * coerced, which could match another user's posts or every author's posts. + * Called directly, an author ID given as a string of digits or a whole float is accepted + * like a `parent` ID, and names the user with that ID. * * @ticket 66268 - * @dataProvider data_author_ids_that_are_not_positive_integers + * @dataProvider data_execute_callback_accepts_an_author_id_given_as_a_whole_number * @since 7.2.0 * - * @param mixed $id The `where.author.id` value to send. + * @param string $type The type to give the ID as. */ - public function test_execute_callback_rejects_an_author_id_that_is_not_a_positive_integer( $id ): void { + public function test_execute_callback_accepts_an_author_id_given_as_a_whole_number( string $type ): void { + $mine_id = self::factory()->post->create( + array( + 'post_author' => self::$user_ids['author'], + 'post_status' => 'publish', + ) + ); + self::factory()->post->create( + array( + 'post_author' => self::$user_ids['author_secondary'], + 'post_status' => 'publish', + ) + ); + + $author_id = self::$user_ids['author']; + settype( $author_id, $type ); + $this->login_as( 'administrator' ); $execute = $this->get_ability_callbacks()['execute_callback']; $result = $execute( array( - 'where' => array( + 'where' => array( 'type' => 'post', - 'author' => array( 'id' => $id ), + 'author' => array( 'id' => $author_id ), ), + 'fields' => array( 'id' ), ) ); - $this->assertWPError( $result, 'An author ID that is not a positive integer must not be coerced into a query.' ); - $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'An author ID that is not a positive integer should fail as an invalid filter.' ); - $this->assertSame( - array( 'where[author][id]' => $result->get_error_message() ), - $result->get_error_data()['params'], - 'The error data should map the malformed author ID to the error message.' - ); - $this->assertSame( 400, $result->get_error_data()['status'], 'The malformed author ID should be reported as a bad request.' ); + $this->assertIsArray( $result, "An author ID given as a {$type} should be accepted." ); + $this->assertSame( array( $mine_id ), wp_list_pluck( $result['items'], 'id' ), "An author ID given as a {$type} should return only that author's posts." ); } /** @@ -5761,7 +5805,7 @@ public function test_execute_callback_rejects_an_author_id_that_is_not_a_positiv * * @return array The type names, as `settype()` takes them. */ - public static function data_author_id_whole_number_types(): array { + public static function data_execute_callback_accepts_an_author_id_given_as_a_whole_number(): array { return array( 'string of digits' => array( 'type' => 'string', @@ -5773,47 +5817,36 @@ public static function data_author_id_whole_number_types(): array { } /** - * Called directly, an author ID given as a string of digits or a whole float is accepted - * like a `parent` ID, and names the user with that ID. + * Called directly, an author filter with several problems reports the first one found: + * the object's shape, then the ID, then the slug. * * @ticket 66268 - * @dataProvider data_author_id_whole_number_types + * @dataProvider data_execute_callback_reports_the_first_problem_of_an_author_filter * @since 7.2.0 * - * @param string $type The type to give the ID as. + * @param array $author The `where.author` value to send. + * @param string $param The parameter the error should name. */ - public function test_execute_callback_accepts_an_author_id_given_as_a_whole_number( string $type ): void { - $mine_id = self::factory()->post->create( - array( - 'post_author' => self::$user_ids['author'], - 'post_status' => 'publish', - ) - ); - self::factory()->post->create( - array( - 'post_author' => self::$user_ids['author_secondary'], - 'post_status' => 'publish', - ) - ); - - $author_id = self::$user_ids['author']; - settype( $author_id, $type ); - + public function test_execute_callback_reports_the_first_problem_of_an_author_filter( array $author, string $param ): void { $this->login_as( 'administrator' ); $execute = $this->get_ability_callbacks()['execute_callback']; $result = $execute( array( - 'where' => array( + 'where' => array( 'type' => 'post', - 'author' => array( 'id' => $author_id ), + 'author' => $author, ), - 'fields' => array( 'id' ), ) ); - $this->assertIsArray( $result, "An author ID given as a {$type} should be accepted." ); - $this->assertSame( array( $mine_id ), wp_list_pluck( $result['items'], 'id' ), "An author ID given as a {$type} should return only that author's posts." ); + $this->assertWPError( $result, 'An author filter with several problems should be rejected.' ); + $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'An author filter with several problems should fail as an invalid filter.' ); + $this->assertSame( + array( $param => $result->get_error_message() ), + $result->get_error_data()['params'], + 'The error data should name the first problem found in the author filter.' + ); } /** @@ -5822,7 +5855,7 @@ public function test_execute_callback_accepts_an_author_id_given_as_a_whole_numb * * @return array, param: string}> The filters and parameters. */ - public static function data_author_filters_with_several_problems(): array { + public static function data_execute_callback_reports_the_first_problem_of_an_author_filter(): array { return array( 'unknown property next to a bad id' => array( 'author' => array( @@ -5856,17 +5889,16 @@ public static function data_author_filters_with_several_problems(): array { } /** - * Called directly, an author filter with several problems reports the first one found: - * the object's shape, then the ID, then the slug. + * Called directly, an author slug that is not a string, or is empty, is rejected rather + * than silently dropped, which would widen the query to every author's posts. * * @ticket 66268 - * @dataProvider data_author_filters_with_several_problems + * @dataProvider data_execute_callback_rejects_an_author_slug_that_is_not_a_non_empty_string * @since 7.2.0 * - * @param array $author The `where.author` value to send. - * @param string $param The parameter the error should name. + * @param mixed $slug The `where.author.slug` value to send. */ - public function test_execute_callback_reports_the_first_problem_of_an_author_filter( array $author, string $param ): void { + public function test_execute_callback_rejects_an_author_slug_that_is_not_a_non_empty_string( $slug ): void { $this->login_as( 'administrator' ); $execute = $this->get_ability_callbacks()['execute_callback']; @@ -5874,18 +5906,19 @@ public function test_execute_callback_reports_the_first_problem_of_an_author_fil array( 'where' => array( 'type' => 'post', - 'author' => $author, + 'author' => array( 'slug' => $slug ), ), ) ); - $this->assertWPError( $result, 'An author filter with several problems should be rejected.' ); - $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'An author filter with several problems should fail as an invalid filter.' ); + $this->assertWPError( $result, 'An author slug that is not a non-empty string must not silently widen the query to all authors.' ); + $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'An author slug that is not a non-empty string should fail as an invalid filter.' ); $this->assertSame( - array( $param => $result->get_error_message() ), + array( 'where[author][slug]' => $result->get_error_message() ), $result->get_error_data()['params'], - 'The error data should name the first problem found in the author filter.' + 'The error data should map the malformed author slug to the error message.' ); + $this->assertSame( 400, $result->get_error_data()['status'], 'The malformed author slug should be reported as a bad request.' ); } /** @@ -5895,7 +5928,7 @@ public function test_execute_callback_reports_the_first_problem_of_an_author_fil * * @return array The `where.author.slug` values. */ - public static function data_author_slugs_that_are_not_non_empty_strings(): array { + public static function data_execute_callback_rejects_an_author_slug_that_is_not_a_non_empty_string(): array { return array( 'integer' => array( 'slug' => 5, @@ -5918,39 +5951,6 @@ public static function data_author_slugs_that_are_not_non_empty_strings(): array ); } - /** - * Called directly, an author slug that is not a string, or is empty, is rejected rather - * than silently dropped, which would widen the query to every author's posts. - * - * @ticket 66268 - * @dataProvider data_author_slugs_that_are_not_non_empty_strings - * @since 7.2.0 - * - * @param mixed $slug The `where.author.slug` value to send. - */ - public function test_execute_callback_rejects_an_author_slug_that_is_not_a_non_empty_string( $slug ): void { - $this->login_as( 'administrator' ); - $execute = $this->get_ability_callbacks()['execute_callback']; - - $result = $execute( - array( - 'where' => array( - 'type' => 'post', - 'author' => array( 'slug' => $slug ), - ), - ) - ); - - $this->assertWPError( $result, 'An author slug that is not a non-empty string must not silently widen the query to all authors.' ); - $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'An author slug that is not a non-empty string should fail as an invalid filter.' ); - $this->assertSame( - array( 'where[author][slug]' => $result->get_error_message() ), - $result->get_error_data()['params'], - 'The error data should map the malformed author slug to the error message.' - ); - $this->assertSame( 400, $result->get_error_data()['status'], 'The malformed author slug should be reported as a bad request.' ); - } - /** * An author slug that names no user matches no post, rather than being dropped, which * would widen the query to every author's posts. @@ -6104,32 +6104,6 @@ public function test_execute_callback_rejects_non_integer_parent_filter(): void ); } - /** - * Returns `where.ids` values that hold no valid ID: no item is a whole number of at least - * 1 within the integer range. - * - * @return array The `where.ids` values. - */ - public static function data_ids_with_no_valid_ids(): array { - return array( - 'zero' => array( - 'ids' => array( 0 ), - ), - 'fraction' => array( - 'ids' => array( 2.5 ), - ), - 'negative number' => array( - 'ids' => array( -5 ), - ), - 'non-numeric string' => array( - 'ids' => 'abc', - ), - 'beyond the integer range' => array( - 'ids' => array( 2 ** 64 + self::ALIASED_POST_ID ), - ), - ); - } - /** * An ids filter that parses to no valid IDs is rejected rather than returning an * unrestricted result set. @@ -6140,7 +6114,7 @@ public static function data_ids_with_no_valid_ids(): array { * published post whose ID it aliases. * * @ticket 66268 - * @dataProvider data_ids_with_no_valid_ids + * @dataProvider data_execute_callback_rejects_ids_with_no_valid_ids * @since 7.2.0 * * @param mixed $ids The `where.ids` value to send. @@ -6174,6 +6148,32 @@ public function test_execute_callback_rejects_ids_with_no_valid_ids( $ids ): voi ); } + /** + * Returns `where.ids` values that hold no valid ID: no item is a whole number of at least + * 1 within the integer range. + * + * @return array The `where.ids` values. + */ + public static function data_execute_callback_rejects_ids_with_no_valid_ids(): array { + return array( + 'zero' => array( + 'ids' => array( 0 ), + ), + 'fraction' => array( + 'ids' => array( 2.5 ), + ), + 'negative number' => array( + 'ids' => array( -5 ), + ), + 'non-numeric string' => array( + 'ids' => 'abc', + ), + 'beyond the integer range' => array( + 'ids' => array( 2 ** 64 + self::ALIASED_POST_ID ), + ), + ); + } + /** * Called directly, an item of `where.ids` that is not a valid ID is dropped, while the * other IDs still apply. @@ -6223,6 +6223,40 @@ public function test_execute_callback_drops_an_invalid_id_next_to_a_valid_one(): ); } + /** + * Called directly, a slugs filter with no slug left after normalization is rejected rather + * than widened to every post. + * + * @ticket 66268 + * @dataProvider data_execute_callback_rejects_slugs_with_no_slug_left + * @since 7.2.0 + * + * @param mixed $slugs The `where.slugs` value to send. + */ + public function test_execute_callback_rejects_slugs_with_no_slug_left( $slugs ): void { + $this->login_as( 'administrator' ); + + self::factory()->post->create( array( 'post_status' => 'publish' ) ); + $execute = $this->get_ability_callbacks()['execute_callback']; + + $result = $execute( + array( + 'where' => array( + 'type' => 'post', + 'slugs' => $slugs, + ), + ) + ); + + $this->assertWPError( $result, 'A slugs filter with no slug left must not fall through to an unrestricted query.' ); + $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'A slugs filter with no slug left should fail closed as an invalid filter.' ); + $this->assertSame( + array( 'where[slugs]' => $result->get_error_message() ), + $result->get_error_data()['params'], + 'The error data should map the slugs filter to the error message.' + ); + } + /** * Returns `where.slugs` values in which no slug is left after normalization. * @@ -6231,7 +6265,7 @@ public function test_execute_callback_drops_an_invalid_id_next_to_a_valid_one(): * * @return array The `where.slugs` values. */ - public static function data_slugs_with_no_slug_left(): array { + public static function data_execute_callback_rejects_slugs_with_no_slug_left(): array { return array( 'empty slug' => array( 'slugs' => array( '' ), @@ -6246,36 +6280,32 @@ public static function data_slugs_with_no_slug_left(): array { } /** - * Called directly, a slugs filter with no slug left after normalization is rejected rather - * than widened to every post. + * Called directly, a status filter with a status that is not registered, or is internal, or + * with no status left in it, is rejected rather than queried. + * + * WP_Query ignores a status that is not registered, and with no status left it covers every + * status, including `trash`. A list that is given but empty would fall through to the default + * statuses instead, which with `ids` or `slugs` cover every status the user may query. * * @ticket 66268 - * @dataProvider data_slugs_with_no_slug_left + * @dataProvider data_execute_callback_rejects_statuses_that_cannot_be_queried * @since 7.2.0 * - * @param mixed $slugs The `where.slugs` value to send. + * @param array $where The `where` filters to send. */ - public function test_execute_callback_rejects_slugs_with_no_slug_left( $slugs ): void { + public function test_execute_callback_rejects_statuses_that_cannot_be_queried( array $where ): void { $this->login_as( 'administrator' ); - self::factory()->post->create( array( 'post_status' => 'publish' ) ); $execute = $this->get_ability_callbacks()['execute_callback']; - $result = $execute( - array( - 'where' => array( - 'type' => 'post', - 'slugs' => $slugs, - ), - ) - ); + $result = $execute( array( 'where' => $where ) ); - $this->assertWPError( $result, 'A slugs filter with no slug left must not fall through to an unrestricted query.' ); - $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'A slugs filter with no slug left should fail closed as an invalid filter.' ); + $this->assertWPError( $result, 'A status filter with a status that cannot be queried must not run the query.' ); + $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'A status that cannot be queried should fail as an invalid filter.' ); $this->assertSame( - array( 'where[slugs]' => $result->get_error_message() ), + array( 'where[status]' => $result->get_error_message() ), $result->get_error_data()['params'], - 'The error data should map the slugs filter to the error message.' + 'The error data should map the status filter to the error message.' ); } @@ -6286,7 +6316,7 @@ public function test_execute_callback_rejects_slugs_with_no_slug_left( $slugs ): * * @return array}> The `where` filters. */ - public static function data_where_filters_with_statuses_that_cannot_be_queried(): array { + public static function data_execute_callback_rejects_statuses_that_cannot_be_queried(): array { return array( 'empty status list' => array( 'where' => array( @@ -6334,36 +6364,6 @@ public static function data_where_filters_with_statuses_that_cannot_be_queried() ); } - /** - * Called directly, a status filter with a status that is not registered, or is internal, or - * with no status left in it, is rejected rather than queried. - * - * WP_Query ignores a status that is not registered, and with no status left it covers every - * status, including `trash`. A list that is given but empty would fall through to the default - * statuses instead, which with `ids` or `slugs` cover every status the user may query. - * - * @ticket 66268 - * @dataProvider data_where_filters_with_statuses_that_cannot_be_queried - * @since 7.2.0 - * - * @param array $where The `where` filters to send. - */ - public function test_execute_callback_rejects_statuses_that_cannot_be_queried( array $where ): void { - $this->login_as( 'administrator' ); - - $execute = $this->get_ability_callbacks()['execute_callback']; - - $result = $execute( array( 'where' => $where ) ); - - $this->assertWPError( $result, 'A status filter with a status that cannot be queried must not run the query.' ); - $this->assertSame( 'content_invalid_filter', $result->get_error_code(), 'A status that cannot be queried should fail as an invalid filter.' ); - $this->assertSame( - array( 'where[status]' => $result->get_error_message() ), - $result->get_error_data()['params'], - 'The error data should map the status filter to the error message.' - ); - } - /** * A status that the input schema still lists, but that is no longer registered when the * query runs, is rejected rather than queried. diff --git a/tests/phpunit/tests/abilities-api/wpRegisterCoreSettingsGetAbility.php b/tests/phpunit/tests/abilities-api/wpRegisterCoreSettingsGetAbility.php index cfdc6677fff8f..ad0ea9e361d6e 100644 --- a/tests/phpunit/tests/abilities-api/wpRegisterCoreSettingsGetAbility.php +++ b/tests/phpunit/tests/abilities-api/wpRegisterCoreSettingsGetAbility.php @@ -514,7 +514,7 @@ public function test_core_settings_get_drops_values_that_fail_their_schema(): vo * * @ticket 64605 * - * @dataProvider data_stored_values + * @dataProvider data_core_settings_get_reads_stored_values * * @param string $type The setting type. * @param mixed $stored The stored option value. @@ -553,7 +553,7 @@ public function test_core_settings_get_reads_stored_values( string $type, $store * * @return array}> Stored values, and the JSON they are read as. */ - public static function data_stored_values(): array { + public static function data_core_settings_get_reads_stored_values(): array { return array( '"false" for a boolean' => array( 'boolean', 'false', 'false' ), 'an empty string for a boolean' => array( 'boolean', '', 'false' ), @@ -586,7 +586,7 @@ public static function data_stored_values(): array { * * @ticket 64605 * - * @dataProvider data_never_saved_settings + * @dataProvider data_core_settings_get_reads_a_setting_that_was_never_saved * * @param array $args The setting registration arguments. * @param string|null $expected The value as JSON, or null when it is left out. @@ -614,7 +614,7 @@ public function test_core_settings_get_reads_a_setting_that_was_never_saved( arr * * @return array, 1: string|null}> Registration arguments, and the JSON the setting is read as. */ - public static function data_never_saved_settings(): array { + public static function data_core_settings_get_reads_a_setting_that_was_never_saved(): array { return array( 'a boolean without a default' => array( array( 'type' => 'boolean' ), null ), 'an array without a default' => array( array( 'type' => 'array' ), null ), diff --git a/tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.php b/tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.php index 671db3381ec3b..2070661854b69 100644 --- a/tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.php +++ b/tests/phpunit/tests/abilities-api/wpRegisterCoreUsersAbility.php @@ -777,7 +777,7 @@ public function test_caller_who_can_assign_authors_gets_no_wider_access(): void * * @ticket 64657 * - * @dataProvider data_roles_for_username_filter_permissions + * @dataProvider data_roles_have_expected_username_filter_permissions * * @param string $role Current user's role. * @param bool $can_list_users Whether the role can list users, and so filter by username. @@ -808,7 +808,7 @@ public function test_roles_have_expected_username_filter_permissions( string $ro * * @return array */ - public static function data_roles_for_username_filter_permissions(): array { + public static function data_roles_have_expected_username_filter_permissions(): array { return array( 'administrator' => array( 'administrator', true ), 'editor' => array( 'editor', false ), @@ -823,7 +823,7 @@ public static function data_roles_for_username_filter_permissions(): array { * * @ticket 64657 * - * @dataProvider data_roles_without_list_users + * @dataProvider data_empty_collection_mode_restricts_users_without_list_users_to_public_authors * * @param string $role Current user's role. */ @@ -850,7 +850,7 @@ public function test_empty_collection_mode_restricts_users_without_list_users_to * * @return array */ - public static function data_roles_without_list_users(): array { + public static function data_empty_collection_mode_restricts_users_without_list_users_to_public_authors(): array { return array( 'editor' => array( 'editor' ), 'author' => array( 'author' ), @@ -1576,7 +1576,7 @@ public function test_where_with_two_identifier_filters_naming_one_user_returns_t * * @ticket 64657 * - * @dataProvider data_unsupported_where_keys + * @dataProvider data_unsupported_where_key_fails_schema_validation * * @param string $key The `where` key. * @param mixed $value The value given for the key. @@ -1596,7 +1596,7 @@ public function test_unsupported_where_key_fails_schema_validation( string $key, * * @return array */ - public static function data_unsupported_where_keys(): array { + public static function data_unsupported_where_key_fails_schema_validation(): array { return array( 'id' => array( 'id', 1 ), 'email' => array( 'email', 'core-users-ability-admin@example.com' ), @@ -1767,7 +1767,7 @@ public function test_admin_can_query_by_role_and_receive_roles(): void { * * @ticket 64657 * - * @dataProvider data_roles_for_another_public_author_field_visibility + * @dataProvider data_roles_have_expected_field_visibility_for_another_public_author * * @param string $role Current user's role. * @param bool $can_view_sensitive Whether the role can view another user's sensitive fields. @@ -1805,7 +1805,7 @@ public function test_roles_have_expected_field_visibility_for_another_public_aut * * @return array */ - public static function data_roles_for_another_public_author_field_visibility(): array { + public static function data_roles_have_expected_field_visibility_for_another_public_author(): array { return array( 'administrator' => array( 'administrator', true, true ), 'editor' => array( 'editor', false, false ), @@ -2188,7 +2188,7 @@ public function test_float_id_resolves_the_user(): void { * * @ticket 64657 * - * @dataProvider data_unknown_requested_fields + * @dataProvider data_unknown_requested_field_fails_schema_validation * * @param string $field The unknown field name or path to request. */ @@ -2212,7 +2212,7 @@ public function test_unknown_requested_field_fails_schema_validation( string $fi * * @return array */ - public static function data_unknown_requested_fields(): array { + public static function data_unknown_requested_field_fails_schema_validation(): array { return array( 'unknown field' => array( 'bogus_field' ), 'unknown registered sub-field' => array( 'registered.local' ), @@ -2439,7 +2439,7 @@ public function test_zero_registered_date_is_reported_as_null(): void { * * @ticket 64657 * - * @dataProvider data_registered_sub_field_paths + * @dataProvider data_zero_registered_date_sub_field_is_reported_as_null * * @param string $field The sub-field path to request. * @param string $key The key the path selects inside `registered`. @@ -2471,7 +2471,7 @@ public function test_zero_registered_date_sub_field_is_reported_as_null( string * * @return array */ - public static function data_registered_sub_field_paths(): array { + public static function data_zero_registered_date_sub_field_is_reported_as_null(): array { return array( 'registered.site' => array( 'registered.site', 'site' ), 'registered.gmt' => array( 'registered.gmt', 'gmt' ), @@ -2486,7 +2486,7 @@ public static function data_registered_sub_field_paths(): array { * * @ticket 64657 * - * @dataProvider data_registered_field_selections + * @dataProvider data_registered_field_selection_returns_the_selected_dates * * @param string[] $fields The fields to request. * @param array $expected The expected registered object. @@ -2514,7 +2514,7 @@ public function test_registered_field_selection_returns_the_selected_dates( arra * * @return array}> */ - public static function data_registered_field_selections(): array { + public static function data_registered_field_selection_returns_the_selected_dates(): array { return array( 'whole registered field' => array( array( 'registered' ), @@ -2550,7 +2550,7 @@ public static function data_registered_field_selections(): array { * * @ticket 64657 * - * @dataProvider data_registered_dates_in_site_timezones + * @dataProvider data_registered_dates_use_the_site_timezone_and_gmt * * @param string $timezone_string The timezone_string option. * @param float $gmt_offset The gmt_offset option. @@ -2597,7 +2597,7 @@ public function test_registered_dates_use_the_site_timezone_and_gmt( string $tim * * @return array */ - public static function data_registered_dates_in_site_timezones(): array { + public static function data_registered_dates_use_the_site_timezone_and_gmt(): array { return array( 'timezone string, standard time, previous day' => array( 'America/New_York', @@ -2664,7 +2664,7 @@ public static function data_registered_dates_in_site_timezones(): array { * * @ticket 64657 * - * @dataProvider data_registered_visibility + * @dataProvider data_registered_is_only_returned_to_self_and_editors * * @param string $role The fixture whose user runs the query. * @param string $field The registered field or sub-field path to request. @@ -2694,7 +2694,7 @@ public function test_registered_is_only_returned_to_self_and_editors( string $ro * * @return array */ - public static function data_registered_visibility(): array { + public static function data_registered_is_only_returned_to_self_and_editors(): array { return array( 'self, registered.site' => array( 'public_author', 'registered.site', true ), 'self, registered.gmt' => array( 'public_author', 'registered.gmt', true ), diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/closedPostboxes.php b/tests/phpunit/tests/admin/includes/ajax-actions/closedPostboxes.php index 8f39b5a5d9b25..9aadecc1ed076 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/closedPostboxes.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/closedPostboxes.php @@ -54,7 +54,7 @@ public function test_closed_postboxes_saves_closed_and_hidden_boxes(): void { /** * @ticket 65252 * - * @dataProvider data_always_shown_postboxes + * @dataProvider data_closed_postboxes_never_hides_always_shown_boxes * * @param string $postbox Postbox ID that can never be hidden. */ @@ -76,7 +76,7 @@ public function test_closed_postboxes_never_hides_always_shown_boxes( string $po * * @return array */ - public static function data_always_shown_postboxes(): array { + public static function data_closed_postboxes_never_hides_always_shown_boxes(): array { return array( 'submitdiv' => array( 'submitdiv' ), 'linksubmitdiv' => array( 'linksubmitdiv' ), diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/dashboardWidgets.php b/tests/phpunit/tests/admin/includes/ajax-actions/dashboardWidgets.php index b926b6ba9dbe9..415934a38137a 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/dashboardWidgets.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/dashboardWidgets.php @@ -124,7 +124,7 @@ public function test_dashboard_widgets_outputs_nothing_for_unknown_widget(): voi /** * @ticket 65252 * - * @dataProvider data_dashboard_screens + * @dataProvider data_dashboard_widgets_sets_dashboard_screen * * @param string $pagenow Dashboard screen ID. */ @@ -144,7 +144,7 @@ public function test_dashboard_widgets_sets_dashboard_screen( string $pagenow ): * * @return array */ - public static function data_dashboard_screens(): array { + public static function data_dashboard_widgets_sets_dashboard_screen(): array { return array( 'dashboard' => array( 'dashboard' ), 'dashboard-user' => array( 'dashboard-user' ), diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/findPosts.php b/tests/phpunit/tests/admin/includes/ajax-actions/findPosts.php index 1f1144e83eafc..58af6a8e97235 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/findPosts.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/findPosts.php @@ -112,7 +112,7 @@ public function test_find_posts_excludes_attachments_and_non_public_post_types() /** * @ticket 65252 * - * @dataProvider data_status_labels + * @dataProvider data_find_posts_labels_post_status * * @param string $status Post status. * @param string $label Expected status label. @@ -139,7 +139,7 @@ public function test_find_posts_labels_post_status( string $status, string $labe * * @return array */ - public static function data_status_labels(): array { + public static function data_find_posts_labels_post_status(): array { return array( 'publish' => array( 'publish', 'Published' ), 'private' => array( 'private', 'Published' ), diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/getCommunityEvents.php b/tests/phpunit/tests/admin/includes/ajax-actions/getCommunityEvents.php index 58c8fad4e3582..812b7ed99230c 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/getCommunityEvents.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/getCommunityEvents.php @@ -206,7 +206,7 @@ public function test_get_community_events_searches_location(): void { * * @ticket 65252 * - * @dataProvider data_saved_location_without_search + * @dataProvider data_get_community_events_updates_saved_location_when_ip_changes * * @param array|null $saved_location Location saved before the request, or null for none. * @param bool $response_ip Whether the API response includes an IP. @@ -244,7 +244,7 @@ public function test_get_community_events_updates_saved_location_when_ip_changes * * @return array */ - public static function data_saved_location_without_search(): array { + public static function data_get_community_events_updates_saved_location_when_ip_changes(): array { $saved_location = array( 'description' => 'Lyon', 'latitude' => '45.764', diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php b/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php index 86b91d8608699..b85efc1408687 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/saveAttachmentOrder.php @@ -150,7 +150,7 @@ public function test_save_attachment_order_insufficient_permissions(): void { * * @ticket 65252 * - * @dataProvider data_missing_parameters + * @dataProvider data_save_attachment_order_missing_parameters * * @param array $post_data POST data. */ @@ -174,7 +174,7 @@ public function test_save_attachment_order_missing_parameters( array $post_data * * @return array */ - public static function data_missing_parameters(): array { + public static function data_save_attachment_order_missing_parameters(): array { return array( 'missing post_id' => array( array( diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/saveUserColorScheme.php b/tests/phpunit/tests/admin/includes/ajax-actions/saveUserColorScheme.php index cf867f1808d63..f8fff5d7c9798 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/saveUserColorScheme.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/saveUserColorScheme.php @@ -45,7 +45,7 @@ public function set_up(): void { /** * @ticket 65252 * - * @dataProvider data_color_schemes + * @dataProvider data_save_user_color_scheme_saves_scheme * * @param string $color_scheme Posted color scheme. * @param string $expected Expected saved color scheme. @@ -76,7 +76,7 @@ public function test_save_user_color_scheme_saves_scheme( string $color_scheme, * * @return array */ - public static function data_color_schemes(): array { + public static function data_save_user_color_scheme_saves_scheme(): array { return array( 'light' => array( 'light', 'light' ), 'coffee' => array( 'coffee', 'coffee' ), diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/saveWidget.php b/tests/phpunit/tests/admin/includes/ajax-actions/saveWidget.php index 6c495e86f19f0..b48c4bba453a2 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/saveWidget.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/saveWidget.php @@ -246,7 +246,7 @@ public function test_save_widget_rejects_invalid_nonce(): void { /** * @ticket 65252 * - * @dataProvider data_roles_without_edit_theme_options + * @dataProvider data_save_widget_rejects_user_without_edit_theme_options * * @param string $role User role. */ @@ -264,7 +264,7 @@ public function test_save_widget_rejects_user_without_edit_theme_options( string * * @return array */ - public static function data_roles_without_edit_theme_options(): array { + public static function data_save_widget_rejects_user_without_edit_theme_options(): array { return array( 'editor' => array( 'editor' ), 'subscriber' => array( 'subscriber' ), diff --git a/tests/phpunit/tests/admin/includes/ajax-actions/wpAjaxTimeFormat.php b/tests/phpunit/tests/admin/includes/ajax-actions/wpAjaxTimeFormat.php index 856eecdbb710c..cbef47e01b56f 100644 --- a/tests/phpunit/tests/admin/includes/ajax-actions/wpAjaxTimeFormat.php +++ b/tests/phpunit/tests/admin/includes/ajax-actions/wpAjaxTimeFormat.php @@ -71,6 +71,35 @@ public function test_time_format( array $payload ): void { $this->assertSame( $expected, $this->_last_response ); } + /** + * Data provider for test_time_format. + * + * @return array + */ + public static function data_time_format(): array { + return array( + 'standard_time' => array( + 'payload' => array( + 'date' => 'H:i', + ), + ), + 'custom_time' => array( + 'payload' => array( + 'date' => 'g:i a', + ), + ), + 'empty_time' => array( + 'payload' => array( + 'date' => '', + ), + ), + ); + } + /** * Tests time format validation (sanitize_option). * @@ -130,33 +159,4 @@ public function test_unprivileged_user(): void { $this->assertSame( date_i18n( 'H:i' ), $this->_last_response ); } - - /** - * Data provider for test_time_format. - * - * @return array - */ - public static function data_time_format(): array { - return array( - 'standard_time' => array( - 'payload' => array( - 'date' => 'H:i', - ), - ), - 'custom_time' => array( - 'payload' => array( - 'date' => 'g:i a', - ), - ), - 'empty_time' => array( - 'payload' => array( - 'date' => '', - ), - ), - ); - } } diff --git a/tests/phpunit/tests/admin/includes/misc/setScreenOptions.php b/tests/phpunit/tests/admin/includes/misc/setScreenOptions.php index b2441edd6639f..994c2de4ad48e 100644 --- a/tests/phpunit/tests/admin/includes/misc/setScreenOptions.php +++ b/tests/phpunit/tests/admin/includes/misc/setScreenOptions.php @@ -65,17 +65,6 @@ public function test_set_screen_options( $option, $value, $expected ) { $this->assertEquals( $expected, $meta ); } - public function intercept_redirect( $location ) { - throw new Exception( 'Redirected' ); - } - - public function filter_set_screen_option_custom( $status, $option, $value ) { - if ( 'my_custom_page' === $option || 'layout_columns' === $option ) { - return $value; - } - return $status; - } - /** * Data provider for test_set_screen_options. * @@ -115,6 +104,17 @@ public static function data_set_screen_options(): array { ); } + public function intercept_redirect( $location ) { + throw new Exception( 'Redirected' ); + } + + public function filter_set_screen_option_custom( $status, $option, $value ) { + if ( 'my_custom_page' === $option || 'layout_columns' === $option ) { + return $value; + } + return $status; + } + /** * @ticket 65183 * diff --git a/tests/phpunit/tests/admin/includes/plugin-install/InstallPluginInstallStatus_Test.php b/tests/phpunit/tests/admin/includes/plugin-install/InstallPluginInstallStatus_Test.php index 9b3eab2a12b10..7b2f209abb7ef 100644 --- a/tests/phpunit/tests/admin/includes/plugin-install/InstallPluginInstallStatus_Test.php +++ b/tests/phpunit/tests/admin/includes/plugin-install/InstallPluginInstallStatus_Test.php @@ -232,7 +232,7 @@ public function test_should_ignore_updates_for_other_plugins() { * * @ticket 65819 * - * @dataProvider data_users_and_install_urls + * @dataProvider data_should_return_install_when_plugin_directory_has_no_plugin * * @param string $user The user to test with, 'admin' or 'subscriber'. * @param bool $expects_url Whether an install URL is expected. @@ -258,7 +258,7 @@ public function test_should_return_install_when_plugin_directory_has_no_plugin( * * @return array[] */ - public static function data_users_and_install_urls() { + public static function data_should_return_install_when_plugin_directory_has_no_plugin() { return array( 'user who can install plugins' => array( 'admin', true ), 'user who cannot install plugins' => array( 'subscriber', false ), @@ -270,7 +270,7 @@ public static function data_users_and_install_urls() { * * @ticket 65819 * - * @dataProvider data_installed_versions + * @dataProvider data_should_compare_installed_version_with_api_version * * @param string $api_version The version reported by the API. * @param string $expected_status The expected status. @@ -297,7 +297,7 @@ public function test_should_compare_installed_version_with_api_version( $api_ver * * @return array[] */ - public static function data_installed_versions() { + public static function data_should_compare_installed_version_with_api_version() { return array( 'same version' => array( '2.0.0', 'latest_installed', '' ), 'installed version is newer' => array( '1.5.0', 'newer_installed', '2.0.0' ), @@ -372,7 +372,7 @@ public function test_should_refresh_update_check_when_api_version_is_newer() { * * @ticket 65819 * - * @dataProvider data_from_query_arg + * @dataProvider data_should_append_from_query_arg_to_url * * @param string $from The "from" query argument, slashed as in a request. * @param string $expected The expected suffix of the URL. @@ -392,7 +392,7 @@ public function test_should_append_from_query_arg_to_url( $from, $expected ) { * * @return array[] */ - public static function data_from_query_arg() { + public static function data_should_append_from_query_arg_to_url() { return array( 'value to encode' => array( 'a b&c=d', '&from=a+b%26c%3Dd' ), 'slashed value' => array( "it\\'s", '&from=it%27s' ), diff --git a/tests/phpunit/tests/admin/includes/plugin/allowedOptions.php b/tests/phpunit/tests/admin/includes/plugin/allowedOptions.php index c156a6680532b..8043263c5fe7e 100644 --- a/tests/phpunit/tests/admin/includes/plugin/allowedOptions.php +++ b/tests/phpunit/tests/admin/includes/plugin/allowedOptions.php @@ -325,7 +325,7 @@ public function test_option_update_filter_adds_new_allowed_options() { * * @covers ::option_update_filter * - * @dataProvider data_new_allowed_options_without_additions + * @dataProvider data_option_update_filter_returns_options_unchanged_without_new_allowed_options * * @param mixed $new_allowed_options Value of the $new_allowed_options global. */ @@ -342,7 +342,7 @@ public function test_option_update_filter_returns_options_unchanged_without_new_ * * @return array[] */ - public static function data_new_allowed_options_without_additions() { + public static function data_option_update_filter_returns_options_unchanged_without_new_allowed_options() { return array( 'null' => array( null ), 'string' => array( 'my_option' ), diff --git a/tests/phpunit/tests/admin/includes/plugin/deletePlugins.php b/tests/phpunit/tests/admin/includes/plugin/deletePlugins.php index 577c822420e0b..6d62c067dd1f9 100644 --- a/tests/phpunit/tests/admin/includes/plugin/deletePlugins.php +++ b/tests/phpunit/tests/admin/includes/plugin/deletePlugins.php @@ -90,7 +90,7 @@ public function tear_down() { * * @ticket 65819 * - * @dataProvider data_no_plugins + * @dataProvider data_should_return_false_without_plugins * * @param mixed $plugins The plugins to delete. */ @@ -103,7 +103,7 @@ public function test_should_return_false_without_plugins( $plugins ) { * * @return array[] */ - public static function data_no_plugins() { + public static function data_should_return_false_without_plugins() { return array( 'empty array' => array( array() ), 'null' => array( null ), diff --git a/tests/phpunit/tests/admin/includes/plugin/getAdminPageParent.php b/tests/phpunit/tests/admin/includes/plugin/getAdminPageParent.php index 2e42de394a2ec..3d5b148e32eec 100644 --- a/tests/phpunit/tests/admin/includes/plugin/getAdminPageParent.php +++ b/tests/phpunit/tests/admin/includes/plugin/getAdminPageParent.php @@ -86,7 +86,7 @@ public function tear_down() { * * @covers ::get_admin_page_parent * - * @dataProvider data_explicit_parent_pages + * @dataProvider data_get_admin_page_parent_returns_explicit_parent_page * * @param string $parent_page Parent page passed to the function. * @param string $expected Expected parent. @@ -104,7 +104,7 @@ public function test_get_admin_page_parent_returns_explicit_parent_page( $parent * * @return array[] */ - public static function data_explicit_parent_pages() { + public static function data_get_admin_page_parent_returns_explicit_parent_page() { return array( 'core parent page' => array( 'options-general.php', 'options-general.php' ), 'parent page that is unknown' => array( 'does-not-exist', 'does-not-exist' ), @@ -119,7 +119,7 @@ public static function data_explicit_parent_pages() { * * @covers ::get_admin_page_parent * - * @dataProvider data_detected_parent_pages + * @dataProvider data_get_admin_page_parent_detects_parent_of_current_page * * @param array $globals Globals describing the current request, keyed by name. * @param string $parent_page Parent page passed to the function. @@ -140,7 +140,7 @@ public function test_get_admin_page_parent_detects_parent_of_current_page( $glob * * @return array[] */ - public static function data_detected_parent_pages() { + public static function data_get_admin_page_parent_detects_parent_of_current_page() { return array( 'top-level plugin page' => array( array( @@ -234,7 +234,7 @@ public static function data_detected_parent_pages() { * * @covers ::get_admin_page_parent * - * @dataProvider data_pages_without_parent + * @dataProvider data_get_admin_page_parent_returns_empty_string_without_parent * * @param array $globals Globals describing the current request, keyed by name. */ @@ -252,7 +252,7 @@ public function test_get_admin_page_parent_returns_empty_string_without_parent( * * @return array[] */ - public static function data_pages_without_parent() { + public static function data_get_admin_page_parent_returns_empty_string_without_parent() { return array( 'page that is not in a submenu' => array( array( 'pagenow' => 'profile.php' ) ), 'unknown plugin page' => array( @@ -284,7 +284,7 @@ public static function data_pages_without_parent() { * * @covers ::get_admin_page_parent * - * @dataProvider data_pages_without_parent_with_parent_file + * @dataProvider data_get_admin_page_parent_preserves_existing_parent_file * * @param string $pagenow Current admin page. */ @@ -301,7 +301,7 @@ public function test_get_admin_page_parent_preserves_existing_parent_file( $page * * @return array[] */ - public static function data_pages_without_parent_with_parent_file() { + public static function data_get_admin_page_parent_preserves_existing_parent_file() { return array( 'page that is not in a submenu' => array( 'profile.php' ), 'submenu page when the parent file has a query' => array( 'edit.php' ), diff --git a/tests/phpunit/tests/admin/includes/plugin/getPluginDataMarkupTranslate.php b/tests/phpunit/tests/admin/includes/plugin/getPluginDataMarkupTranslate.php index 040663e258107..94b6eb1183392 100644 --- a/tests/phpunit/tests/admin/includes/plugin/getPluginDataMarkupTranslate.php +++ b/tests/phpunit/tests/admin/includes/plugin/getPluginDataMarkupTranslate.php @@ -119,7 +119,7 @@ public function test_should_add_markup() { * * @ticket 65819 * - * @dataProvider data_empty_markup_fields + * @dataProvider data_should_skip_markup_for_empty_fields * * @param array $fields The plugin data fields. * @param array $expected The expected Title, Author and Description. @@ -142,7 +142,7 @@ public function test_should_skip_markup_for_empty_fields( $fields, $expected ) { * * @return array[] */ - public static function data_empty_markup_fields() { + public static function data_should_skip_markup_for_empty_fields() { return array( 'no plugin URI' => array( array( @@ -266,7 +266,7 @@ public function test_should_not_translate_when_disabled() { * * @ticket 65819 * - * @dataProvider data_plugins_without_text_domain + * @dataProvider data_should_handle_plugin_without_text_domain * * @param string $plugin_file The plugin file, relative to the plugins directory. * @param array $expected The expected translate() calls. @@ -289,7 +289,7 @@ public function test_should_handle_plugin_without_text_domain( $plugin_file, $ex * * @return array[] */ - public static function data_plugins_without_text_domain() { + public static function data_should_handle_plugin_without_text_domain() { return array( 'Hello Dolly uses the default text domain' => array( 'hello.php', @@ -311,7 +311,7 @@ public static function data_plugins_without_text_domain() { * * @ticket 65819 * - * @dataProvider data_text_domain_paths + * @dataProvider data_should_load_text_domain_from_plugin_directory * * @param string $domain_path The Domain Path header. * @param string $expected_path The expected path, relative to the plugins directory. @@ -342,7 +342,7 @@ public function test_should_load_text_domain_from_plugin_directory( $domain_path * * @return array[] */ - public static function data_text_domain_paths() { + public static function data_should_load_text_domain_from_plugin_directory() { return array( 'no domain path' => array( '', 'my-plugin' ), 'domain path' => array( '/languages', 'my-plugin/languages' ), diff --git a/tests/phpunit/tests/admin/includes/plugin/removeMenuPage.php b/tests/phpunit/tests/admin/includes/plugin/removeMenuPage.php index 68a3c65be7f2d..72067366b937b 100644 --- a/tests/phpunit/tests/admin/includes/plugin/removeMenuPage.php +++ b/tests/phpunit/tests/admin/includes/plugin/removeMenuPage.php @@ -126,7 +126,7 @@ public function test_remove_menu_page_only_removes_first_matching_menu_item() { * * @covers ::remove_menu_page * - * @dataProvider data_menu_slugs_without_match + * @dataProvider data_remove_menu_page_returns_false_without_match * * @param mixed $menu_slug Menu slug. */ @@ -142,7 +142,7 @@ public function test_remove_menu_page_returns_false_without_match( $menu_slug ) * * @return array[] */ - public static function data_menu_slugs_without_match() { + public static function data_remove_menu_page_returns_false_without_match() { return array( 'unknown slug' => array( 'does-not-exist' ), 'partial slug' => array( 'edit' ), @@ -218,7 +218,7 @@ public function test_remove_submenu_page_keeps_menu_items() { * * @covers ::remove_submenu_page * - * @dataProvider data_submenu_slugs_without_match + * @dataProvider data_remove_submenu_page_returns_false_without_match * * @param mixed $menu_slug Parent menu slug. * @param mixed $submenu_slug Submenu slug. @@ -235,7 +235,7 @@ public function test_remove_submenu_page_returns_false_without_match( $menu_slug * * @return array[] */ - public static function data_submenu_slugs_without_match() { + public static function data_remove_submenu_page_returns_false_without_match() { return array( 'unknown parent slug' => array( 'does-not-exist', 'post-new.php' ), 'unknown submenu slug' => array( 'edit.php', 'does-not-exist' ), diff --git a/tests/phpunit/tests/admin/includes/plugin/settingsFields.php b/tests/phpunit/tests/admin/includes/plugin/settingsFields.php index acbd02c59709c..57895292154ee 100644 --- a/tests/phpunit/tests/admin/includes/plugin/settingsFields.php +++ b/tests/phpunit/tests/admin/includes/plugin/settingsFields.php @@ -19,7 +19,7 @@ public function set_up() { /** * @ticket 65819 * - * @dataProvider data_option_groups + * @dataProvider data_outputs_option_page_and_action_fields * * @param string $option_group Settings group name. */ @@ -45,7 +45,7 @@ public function test_outputs_option_page_and_action_fields( $option_group ) { * * @return array[] */ - public static function data_option_groups() { + public static function data_outputs_option_page_and_action_fields() { return array( 'general' => array( 'general' ), 'custom group' => array( 'my_plugin_settings' ), @@ -77,7 +77,7 @@ public function test_escapes_option_group_in_option_page_value() { /** * @ticket 65819 * - * @dataProvider data_nonce_option_groups + * @dataProvider data_outputs_valid_nonce_for_option_group * * @param string $option_group Settings group name. */ @@ -112,7 +112,7 @@ public function test_outputs_valid_nonce_for_option_group( $option_group ) { * * @return array[] */ - public static function data_nonce_option_groups() { + public static function data_outputs_valid_nonce_for_option_group() { return array( 'general' => array( 'general' ), 'reading' => array( 'reading' ), diff --git a/tests/phpunit/tests/admin/includes/plugin/uninstallPlugin.php b/tests/phpunit/tests/admin/includes/plugin/uninstallPlugin.php index ad0acc53a416d..9fd8199efaf1e 100644 --- a/tests/phpunit/tests/admin/includes/plugin/uninstallPlugin.php +++ b/tests/phpunit/tests/admin/includes/plugin/uninstallPlugin.php @@ -154,7 +154,7 @@ public function test_uninstall_plugin_does_nothing_without_uninstall_routine() { * * @covers ::uninstall_plugin * - * @dataProvider data_plugins_for_pre_uninstall_action + * @dataProvider data_uninstall_plugin_fires_pre_uninstall_action * * @param string $plugin Plugin passed to uninstall_plugin(). */ @@ -176,7 +176,7 @@ public function test_uninstall_plugin_fires_pre_uninstall_action( $plugin ) { * * @return array[] */ - public static function data_plugins_for_pre_uninstall_action() { + public static function data_uninstall_plugin_fires_pre_uninstall_action() { return array( 'plugin with an uninstall callback' => array( 'hello.php' ), 'plugin without an uninstall routine' => array( 'other-plugin/other.php' ), diff --git a/tests/phpunit/tests/admin/includes/plugin/validateActivePlugins.php b/tests/phpunit/tests/admin/includes/plugin/validateActivePlugins.php index e49dfef026ff8..7a97ec359376f 100644 --- a/tests/phpunit/tests/admin/includes/plugin/validateActivePlugins.php +++ b/tests/phpunit/tests/admin/includes/plugin/validateActivePlugins.php @@ -76,7 +76,7 @@ public function tear_down() { * * @ticket 65819 * - * @dataProvider data_invalid_options + * @dataProvider data_should_reset_option_that_is_not_an_array * * @param mixed $value The option value. */ @@ -92,7 +92,7 @@ public function test_should_reset_option_that_is_not_an_array( $value ) { * * @return array[] */ - public static function data_invalid_options() { + public static function data_should_reset_option_that_is_not_an_array() { return array( 'string' => array( 'hello.php' ), 'integer' => array( 1 ), diff --git a/tests/phpunit/tests/admin/includes/plugin/validatePlugin.php b/tests/phpunit/tests/admin/includes/plugin/validatePlugin.php index eac2ccfdbd015..3449d8b3c355b 100644 --- a/tests/phpunit/tests/admin/includes/plugin/validatePlugin.php +++ b/tests/phpunit/tests/admin/includes/plugin/validatePlugin.php @@ -112,7 +112,7 @@ public function test_validate_plugin_success_single_file() { * * @ticket 65819 * - * @dataProvider data_invalid_plugin_paths + * @dataProvider data_validate_plugin_returns_error_for_invalid_path * * @param string $invalid_path Invalid plugin file path. */ @@ -128,7 +128,7 @@ public function test_validate_plugin_returns_error_for_invalid_path( $invalid_pa * * @return array[] */ - public static function data_invalid_plugin_paths() { + public static function data_validate_plugin_returns_error_for_invalid_path() { return array( 'directory traversal at start' => array( '../outside/plugin.php' ), 'nested directory traversal' => array( 'dir/../../file.php' ), diff --git a/tests/phpunit/tests/admin/includes/template/getMediaStates.php b/tests/phpunit/tests/admin/includes/template/getMediaStates.php index 7f92b2269d084..021c190182eda 100644 --- a/tests/phpunit/tests/admin/includes/template/getMediaStates.php +++ b/tests/phpunit/tests/admin/includes/template/getMediaStates.php @@ -154,7 +154,7 @@ public function test_header_image_state_with_random_header_images() { * * @ticket 65819 * - * @dataProvider data_header_video_states + * @dataProvider data_header_video_state * * @param bool $supports_video Whether the custom header supports video. * @param bool $is_video Whether the attachment is the header video. @@ -176,7 +176,7 @@ public function test_header_video_state( $supports_video, $is_video, $expected ) * * @return array[] */ - public static function data_header_video_states() { + public static function data_header_video_state() { return array( 'current header video' => array( true, true, array( 'Current Header Video' ) ), 'other video' => array( true, false, array() ), diff --git a/tests/phpunit/tests/admin/includes/theme/themePausedState.php b/tests/phpunit/tests/admin/includes/theme/themePausedState.php index ca1c7927427e8..9451a019c4ee5 100644 --- a/tests/phpunit/tests/admin/includes/theme/themePausedState.php +++ b/tests/phpunit/tests/admin/includes/theme/themePausedState.php @@ -354,7 +354,7 @@ public function test_resume_theme_does_not_redirect_for_inactive_theme() { * * @covers ::resume_theme * - * @dataProvider data_resume_theme_redirects + * @dataProvider data_resume_theme_redirects_and_loads_functions_file * * @runInSeparateProcess * @preserveGlobalState disabled @@ -404,7 +404,7 @@ public function test_resume_theme_redirects_and_loads_functions_file( $styleshee * * @return array[] */ - public static function data_resume_theme_redirects() { + public static function data_resume_theme_redirects_and_loads_functions_file() { return array( 'theme is the active stylesheet' => array( '/themedir1/sandbox', '/themedir1/default' ), 'theme is the active template' => array( '/themedir1/default', '/themedir1/sandbox' ), diff --git a/tests/phpunit/tests/admin/includes/update/wpIsAutoUpdateEnabledForType.php b/tests/phpunit/tests/admin/includes/update/wpIsAutoUpdateEnabledForType.php index bbdf0ab714f01..67c1ceb485161 100644 --- a/tests/phpunit/tests/admin/includes/update/wpIsAutoUpdateEnabledForType.php +++ b/tests/phpunit/tests/admin/includes/update/wpIsAutoUpdateEnabledForType.php @@ -37,7 +37,7 @@ public function set_up() { * * @ticket 65819 * - * @dataProvider data_types_and_updater_states + * @dataProvider data_should_follow_automatic_updater * * @param string $type The update type. * @param bool $disabled Whether the automatic updater is disabled. @@ -53,7 +53,7 @@ public function test_should_follow_automatic_updater( $type, $disabled ) { * * @return array[] */ - public static function data_types_and_updater_states() { + public static function data_should_follow_automatic_updater() { return array( 'plugin, updater enabled' => array( 'plugin', false ), 'plugin, updater disabled' => array( 'plugin', true ), @@ -78,7 +78,7 @@ public function test_should_be_disabled_without_file_changes() { * * @ticket 65819 * - * @dataProvider data_type_filters + * @dataProvider data_should_apply_type_filter * * @param string $type The update type. * @param string $filter The filter for the type. @@ -99,7 +99,7 @@ public function test_should_apply_type_filter( $type, $filter ) { * * @return array[] */ - public static function data_type_filters() { + public static function data_should_apply_type_filter() { return array( 'plugin' => array( 'plugin', 'plugins_auto_update_enabled' ), 'theme' => array( 'theme', 'themes_auto_update_enabled' ), @@ -111,7 +111,7 @@ public static function data_type_filters() { * * @ticket 65819 * - * @dataProvider data_other_types + * @dataProvider data_should_return_false_for_other_types * * @param mixed $type The update type. */ @@ -128,7 +128,7 @@ public function test_should_return_false_for_other_types( $type ) { * * @return array[] */ - public static function data_other_types() { + public static function data_should_return_false_for_other_types() { return array( 'core' => array( 'core' ), 'plural type' => array( 'plugins' ), diff --git a/tests/phpunit/tests/admin/includes/update/wpPluginUpdateRow.php b/tests/phpunit/tests/admin/includes/update/wpPluginUpdateRow.php index 6eae6a3a02bd0..7e68645c9e6a9 100644 --- a/tests/phpunit/tests/admin/includes/update/wpPluginUpdateRow.php +++ b/tests/phpunit/tests/admin/includes/update/wpPluginUpdateRow.php @@ -241,7 +241,7 @@ public function test_should_sanitize_plugin_name() { * * @ticket 65819 * - * @dataProvider data_details_urls + * @dataProvider data_should_choose_details_url * * @param array $response The update response fields. * @param string $slug The expected plugin slug. @@ -267,7 +267,7 @@ public function test_should_choose_details_url( $response, $slug, $details_url ) * * @return array[] */ - public static function data_details_urls() { + public static function data_should_choose_details_url() { return array( 'update URL' => array( array( @@ -347,7 +347,7 @@ public function test_update_rows_should_hook_row_for_each_update() { * * @ticket 65819 * - * @dataProvider data_no_update_rows + * @dataProvider data_update_rows_should_not_hook_rows * * @param string $user The user, 'admin' or 'subscriber'. * @param mixed $response The response of the update transient, or false for no transient. @@ -369,7 +369,7 @@ public function test_update_rows_should_not_hook_rows( $user, $response ) { * * @return array[] */ - public static function data_no_update_rows() { + public static function data_update_rows_should_not_hook_rows() { return array( 'user who cannot update plugins' => array( 'subscriber', array( self::FILE => (object) array( 'slug' => 'my-plugin' ) ) ), 'no update transient' => array( 'admin', false ), diff --git a/tests/phpunit/tests/admin/includesUpdate.php b/tests/phpunit/tests/admin/includesUpdate.php index 7dfd156eaa17a..b822e4e04e785 100644 --- a/tests/phpunit/tests/admin/includesUpdate.php +++ b/tests/phpunit/tests/admin/includesUpdate.php @@ -76,7 +76,7 @@ public function test_wp_get_translation_update_data_reads_plugin_updates_indepen /** * @ticket 42281 - * @dataProvider data_non_plugin_translation_updates + * @dataProvider data_wp_get_translation_update_data_does_not_load_plugin_names_without_plugin_translations * * @param string|null $type Translation type, or null for no updates. */ @@ -120,7 +120,7 @@ static function ( $value ) use ( &$reads ) { /** * @return array[] */ - public static function data_non_plugin_translation_updates() { + public static function data_wp_get_translation_update_data_does_not_load_plugin_names_without_plugin_translations() { return array( 'no updates' => array( null ), 'core only' => array( 'core' ), @@ -449,7 +449,7 @@ public function test_wp_get_deferred_translation_updates_filters_to_available_up /** * @ticket 42281 - * @dataProvider data_translation_update_selections + * @dataProvider data_wp_process_translation_update_selection * * @param string[] $form Updates included in the form. * @param string[] $checked Selected updates. @@ -520,7 +520,7 @@ static function ( $key ) use ( $updates ) { * * @return array[] */ - public static function data_translation_update_selections() { + public static function data_wp_process_translation_update_selection() { return array( 'select all form updates' => array( array( 'core', 'plugin', 'theme' ), diff --git a/tests/phpunit/tests/admin/languagePackUpgrader.php b/tests/phpunit/tests/admin/languagePackUpgrader.php index 16cd98c5d2e76..bd89963f93862 100644 --- a/tests/phpunit/tests/admin/languagePackUpgrader.php +++ b/tests/phpunit/tests/admin/languagePackUpgrader.php @@ -78,7 +78,7 @@ static function () use ( &$bulk_upgrade_started ) { * Tests that only successfully installed translations lose their deferrals. * * @ticket 42281 - * @dataProvider data_bulk_upgrade_results + * @dataProvider data_bulk_upgrade_should_clear_only_successful_deferrals * @covers Language_Pack_Upgrader::bulk_upgrade * * @param string[] $outcomes Results returned by successive package attempts. @@ -105,7 +105,7 @@ public function test_bulk_upgrade_should_clear_only_successful_deferrals( $outco * * @return array[] */ - public static function data_bulk_upgrade_results() { + public static function data_bulk_upgrade_should_clear_only_successful_deferrals() { return array( 'all package types succeed' => array( array( 'success', 'success', 'success' ), diff --git a/tests/phpunit/tests/admin/plugin-dependencies/displayAdminNotices.php b/tests/phpunit/tests/admin/plugin-dependencies/displayAdminNotices.php index c84afb6edd6cc..e6aa4192e8d02 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/displayAdminNotices.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/displayAdminNotices.php @@ -110,7 +110,7 @@ public static function data_screens() { * * @group ms-required * - * @dataProvider data_network_users + * @dataProvider data_unmet_notice_on_multisite * * @param bool $super_admin Whether the user is a super admin. * @param string $suffix The expected text after the message. @@ -137,7 +137,7 @@ public function test_unmet_notice_on_multisite( $super_admin, $suffix ) { * * @return array[] */ - public static function data_network_users() { + public static function data_unmet_notice_on_multisite() { return array( 'super admin' => array( true, 'Manage plugins.' ), 'site administrator' => array( false, 'Please contact your network administrator.' ), diff --git a/tests/phpunit/tests/admin/plugin-dependencies/getCircularDependencies.php b/tests/phpunit/tests/admin/plugin-dependencies/getCircularDependencies.php index 9ef5a0d531056..48d4bb222e5ca 100644 --- a/tests/phpunit/tests/admin/plugin-dependencies/getCircularDependencies.php +++ b/tests/phpunit/tests/admin/plugin-dependencies/getCircularDependencies.php @@ -42,7 +42,7 @@ public function test_should_return_empty_array_without_dependencies() { * * @ticket 65819 * - * @dataProvider data_dependencies + * @dataProvider data_should_find_circular_dependencies * * @param array $dependencies The dependency slugs of each plugin, keyed by plugin slug. * @param array $pairs The expected pairs. @@ -60,7 +60,7 @@ public function test_should_find_circular_dependencies( $dependencies, $pairs, $ * * @return array[] */ - public static function data_dependencies() { + public static function data_should_find_circular_dependencies() { return array( 'no circular dependency' => array( array( diff --git a/tests/phpunit/tests/admin/pluginInstallerSkinDoOverwrite.php b/tests/phpunit/tests/admin/pluginInstallerSkinDoOverwrite.php index dac1aa65bf44a..bbc275eb6c5b2 100644 --- a/tests/phpunit/tests/admin/pluginInstallerSkinDoOverwrite.php +++ b/tests/phpunit/tests/admin/pluginInstallerSkinDoOverwrite.php @@ -57,7 +57,7 @@ public function tear_down() { * * @ticket 65819 * - * @dataProvider data_not_an_overwrite + * @dataProvider data_should_return_false_when_not_overwriting * * @param string $type The skin type. * @param string $error_code The result error code, or an empty string for a successful result. @@ -76,7 +76,7 @@ public function test_should_return_false_when_not_overwriting( $type, $error_cod * * @return array[] */ - public static function data_not_an_overwrite() { + public static function data_should_return_false_when_not_overwriting() { return array( 'web install' => array( 'web', 'folder_exists' ), 'successful upload' => array( 'upload', '' ), diff --git a/tests/phpunit/tests/admin/pluginInstallerSkinHideProcessFailed.php b/tests/phpunit/tests/admin/pluginInstallerSkinHideProcessFailed.php index da82fc75715d1..61f6577ba7488 100644 --- a/tests/phpunit/tests/admin/pluginInstallerSkinHideProcessFailed.php +++ b/tests/phpunit/tests/admin/pluginInstallerSkinHideProcessFailed.php @@ -25,7 +25,7 @@ public static function set_up_before_class() { * * @ticket 65819 * - * @dataProvider data_errors + * @dataProvider data_should_hide_folder_exists_error_for_first_upload * * @param string $type The skin type. * @param string $overwrite The overwrite argument. @@ -48,7 +48,7 @@ public function test_should_hide_folder_exists_error_for_first_upload( $type, $o * * @return array[] */ - public static function data_errors() { + public static function data_should_hide_folder_exists_error_for_first_upload() { return array( 'upload, existing folder' => array( 'upload', '', 'folder_exists', true ), 'upload, other error' => array( 'upload', '', 'incompatible_archive', false ), diff --git a/tests/phpunit/tests/admin/pluginUpgraderCheckPackage.php b/tests/phpunit/tests/admin/pluginUpgraderCheckPackage.php index d33f436d6d340..66c1ff235defc 100644 --- a/tests/phpunit/tests/admin/pluginUpgraderCheckPackage.php +++ b/tests/phpunit/tests/admin/pluginUpgraderCheckPackage.php @@ -111,7 +111,7 @@ public function test_should_return_source_when_directory_does_not_exist() { * * @ticket 65819 * - * @dataProvider data_packages_without_plugin + * @dataProvider data_should_reject_package_without_plugin * * @param array $files The package files, keyed by file name. */ @@ -132,7 +132,7 @@ public function test_should_reject_package_without_plugin( $files ) { * * @return array[] */ - public static function data_packages_without_plugin() { + public static function data_should_reject_package_without_plugin() { return array( 'empty package' => array( array() ), 'no PHP files' => array( array( 'readme.txt' => "Plugin Name: Not A PHP File\n" ) ), diff --git a/tests/phpunit/tests/admin/pluginUpgraderPluginInfo.php b/tests/phpunit/tests/admin/pluginUpgraderPluginInfo.php index 41d57a820819d..0ee341e84edf2 100644 --- a/tests/phpunit/tests/admin/pluginUpgraderPluginInfo.php +++ b/tests/phpunit/tests/admin/pluginUpgraderPluginInfo.php @@ -34,7 +34,7 @@ public function tear_down() { * * @ticket 65819 * - * @dataProvider data_unusable_results + * @dataProvider data_should_return_false_without_destination * * @param mixed $result The upgrade result. */ @@ -55,7 +55,7 @@ public function test_should_return_false_without_destination( $result ) { * * @return array[] */ - public static function data_unusable_results() { + public static function data_should_return_false_without_destination() { return array( 'no result' => array( null ), 'false' => array( false ), diff --git a/tests/phpunit/tests/admin/pluginUpgraderUpgradeHooks.php b/tests/phpunit/tests/admin/pluginUpgraderUpgradeHooks.php index 71d37219f0f54..a8ed72598035c 100644 --- a/tests/phpunit/tests/admin/pluginUpgraderUpgradeHooks.php +++ b/tests/phpunit/tests/admin/pluginUpgraderUpgradeHooks.php @@ -214,7 +214,7 @@ public function test_deactivate_should_not_deactivate_plugin_in_cron() { * * @ticket 65819 * - * @dataProvider data_missing_plugins + * @dataProvider data_should_return_bad_request_without_plugin * * @param string $callback The callback name. * @param array $args The hook extra arguments. @@ -236,7 +236,7 @@ public function test_should_return_bad_request_without_plugin( $callback, $args * * @return array[] */ - public static function data_missing_plugins() { + public static function data_should_return_bad_request_without_plugin() { return array( 'deactivate, no plugin key' => array( 'deactivate_plugin_before_upgrade', array() ), 'deactivate, empty plugin' => array( 'deactivate_plugin_before_upgrade', array( 'plugin' => '' ) ), @@ -250,7 +250,7 @@ public static function data_missing_plugins() { * * @ticket 65819 * - * @dataProvider data_empty_plugin_args + * @dataProvider data_active_before_and_after_should_not_toggle_maintenance_mode_without_plugin * * @param array $args The hook arguments. */ @@ -269,7 +269,7 @@ public function test_active_before_and_after_should_not_toggle_maintenance_mode_ * * @return array[] */ - public static function data_empty_plugin_args() { + public static function data_active_before_and_after_should_not_toggle_maintenance_mode_without_plugin() { return array( 'no plugin key' => array( array() ), 'empty plugin' => array( array( 'plugin' => '' ) ), @@ -396,7 +396,7 @@ static function ( $file ) use ( &$maintenance_file_exists ) { * * @ticket 65819 * - * @dataProvider data_no_maintenance_mode + * @dataProvider data_active_before_and_after_should_not_toggle_maintenance_mode * * @param bool $cron Whether the upgrade runs in cron. * @param bool $active Whether the plugin is active. @@ -420,7 +420,7 @@ public function test_active_before_and_after_should_not_toggle_maintenance_mode( * * @return array[] */ - public static function data_no_maintenance_mode() { + public static function data_active_before_and_after_should_not_toggle_maintenance_mode() { return array( 'manual upgrade' => array( false, true, false ), 'inactive plugin' => array( true, false, false ), @@ -433,7 +433,7 @@ public static function data_no_maintenance_mode() { * * @ticket 65819 * - * @dataProvider data_old_plugin_files + * @dataProvider data_delete_old_plugin_should_delete_plugin_files * * @param string $plugin The plugin file. * @param string $path The expected deleted path. @@ -454,7 +454,7 @@ public function test_delete_old_plugin_should_delete_plugin_files( $plugin, $pat * * @return array[] */ - public static function data_old_plugin_files() { + public static function data_delete_old_plugin_should_delete_plugin_files() { return array( 'plugin in a directory' => array( self::FILE, self::PLUGINS_DIR . 'my-plugin/', true ), 'single-file plugin' => array( 'my-plugin.php', self::PLUGINS_DIR . 'my-plugin.php', false ), diff --git a/tests/phpunit/tests/admin/walkerCategoryChecklist.php b/tests/phpunit/tests/admin/walkerCategoryChecklist.php index bb398abd5a5ff..9689c63fb6c80 100644 --- a/tests/phpunit/tests/admin/walkerCategoryChecklist.php +++ b/tests/phpunit/tests/admin/walkerCategoryChecklist.php @@ -103,7 +103,7 @@ public static function data_depths() { * * @covers ::start_el * - * @dataProvider data_list_only_items + * @dataProvider data_start_el_in_list_only_mode * * @param array $args Arguments passed to the walker. * @param string $expected Expected list item, without the leading newline. @@ -124,7 +124,7 @@ public function test_start_el_in_list_only_mode( $args, $expected ) { * * @return array[] */ - public static function data_list_only_items() { + public static function data_start_el_in_list_only_mode() { $unselected = ''; $selected = ''; @@ -153,7 +153,7 @@ public static function data_list_only_items() { * * @covers ::start_el * - * @dataProvider data_checkbox_items + * @dataProvider data_start_el_generates_checkbox * * @param array $args Arguments passed to the walker. * @param string $name Expected name of the checkbox. @@ -188,7 +188,7 @@ public function test_start_el_generates_checkbox( $args, $name, $id_prefix, $is_ * * @return array[] */ - public static function data_checkbox_items() { + public static function data_start_el_generates_checkbox() { return array( 'default arguments' => array( array(), 'post_category[]', 'in-category-5-', false, false, null ), 'empty taxonomy' => array( array( 'taxonomy' => '' ), 'post_category[]', 'in-category-5-', false, false, null ), @@ -225,7 +225,7 @@ public static function data_checkbox_items() { * * @covers ::start_el * - * @dataProvider data_list_only_modes + * @dataProvider data_start_el_filters_and_escapes_category_name * * @param bool $list_only Whether to generate the list-only markup. */ @@ -256,7 +256,7 @@ static function () { * * @return array[] */ - public static function data_list_only_modes() { + public static function data_start_el_filters_and_escapes_category_name() { return array( 'checkbox markup' => array( false ), 'list-only markup' => array( true ), diff --git a/tests/phpunit/tests/admin/wpAutomaticUpdaterAfterPluginThemeUpdate.php b/tests/phpunit/tests/admin/wpAutomaticUpdaterAfterPluginThemeUpdate.php index 2e2061da38f8c..a53a0ba457aca 100644 --- a/tests/phpunit/tests/admin/wpAutomaticUpdaterAfterPluginThemeUpdate.php +++ b/tests/phpunit/tests/admin/wpAutomaticUpdaterAfterPluginThemeUpdate.php @@ -25,7 +25,7 @@ public static function set_up_before_class() { * * @ticket 65819 * - * @dataProvider data_no_plugin_or_theme_results + * @dataProvider data_should_not_send_email_without_plugin_or_theme_results * * @param array $update_results The update results. */ @@ -47,7 +47,7 @@ public function test_should_not_send_email_without_plugin_or_theme_results( $upd * * @return array[] */ - public static function data_no_plugin_or_theme_results() { + public static function data_should_not_send_email_without_plugin_or_theme_results() { return array( 'no results' => array( array() ), 'empty plugin and theme results' => array( @@ -70,7 +70,7 @@ public static function data_no_plugin_or_theme_results() { * * @ticket 65819 * - * @dataProvider data_email_types + * @dataProvider data_should_send_email_for_results * * @param array $results The plugin and theme results, as result values keyed by type. * @param string $type The expected email type. @@ -101,7 +101,7 @@ public function test_should_send_email_for_results( $results, $type, $successful * * @return array[] */ - public static function data_email_types() { + public static function data_should_send_email_for_results() { return array( 'plugin succeeded' => array( array( 'plugin' => array( true ) ), @@ -186,7 +186,7 @@ public static function data_email_types() { * * @ticket 65819 * - * @dataProvider data_disabled_notifications + * @dataProvider data_should_leave_out_results_when_email_is_disabled_for_type * * @param string $disabled The type whose email filter returns false. * @param string $kept The type that is still emailed. @@ -222,7 +222,7 @@ public function test_should_leave_out_results_when_email_is_disabled_for_type( $ * * @return array[] */ - public static function data_disabled_notifications() { + public static function data_should_leave_out_results_when_email_is_disabled_for_type() { return array( 'plugin emails disabled' => array( 'plugin', 'theme' ), 'theme emails disabled' => array( 'theme', 'plugin' ), diff --git a/tests/phpunit/tests/admin/wpAutomaticUpdaterSendDebugEmail.php b/tests/phpunit/tests/admin/wpAutomaticUpdaterSendDebugEmail.php index bd4a8cb746517..3ad507d2e42e7 100644 --- a/tests/phpunit/tests/admin/wpAutomaticUpdaterSendDebugEmail.php +++ b/tests/phpunit/tests/admin/wpAutomaticUpdaterSendDebugEmail.php @@ -104,7 +104,7 @@ public function test_should_report_successful_updates() { * * @ticket 65819 * - * @dataProvider data_failed_core_results + * @dataProvider data_should_report_failed_updates * * @param false|WP_Error $core_result The failed core update result. */ @@ -151,7 +151,7 @@ public function test_should_report_failed_updates( $core_result ) { * * @return array[] */ - public static function data_failed_core_results() { + public static function data_should_report_failed_updates() { return array( 'false result' => array( false ), 'error result' => array( new WP_Error( 'core_update_failed', 'Core update failed.' ) ), diff --git a/tests/phpunit/tests/admin/wpAutomaticUpdaterShouldUpdate.php b/tests/phpunit/tests/admin/wpAutomaticUpdaterShouldUpdate.php index 1902f019e02a0..4dab21782ff5e 100644 --- a/tests/phpunit/tests/admin/wpAutomaticUpdaterShouldUpdate.php +++ b/tests/phpunit/tests/admin/wpAutomaticUpdaterShouldUpdate.php @@ -150,7 +150,7 @@ public function test_returns_false_for_vcs_checkout() { * * @ticket 65819 * - * @dataProvider data_core_updates_that_cannot_run + * @dataProvider data_sends_core_notification_when_core_cannot_be_updated * * @param bool $credentials_available Whether filesystem credentials are available. * @param bool $is_vcs_checkout Whether the site is a version-controlled checkout. @@ -170,7 +170,7 @@ public function test_sends_core_notification_when_core_cannot_be_updated( $crede * * @return array[] */ - public static function data_core_updates_that_cannot_run() { + public static function data_sends_core_notification_when_core_cannot_be_updated() { return array( 'no filesystem credentials' => array( false, false ), 'version-controlled site' => array( true, true ), @@ -182,7 +182,7 @@ public static function data_core_updates_that_cannot_run() { * * @ticket 65819 * - * @dataProvider data_relaxed_file_ownership + * @dataProvider data_allows_relaxed_file_ownership_only_for_core_without_new_files * * @param string $type Update type. * @param object $item Update offer. @@ -201,7 +201,7 @@ public function test_allows_relaxed_file_ownership_only_for_core_without_new_fil * * @return array[] */ - public static function data_relaxed_file_ownership() { + public static function data_allows_relaxed_file_ownership_only_for_core_without_new_files() { return array( 'core without new files' => array( 'core', self::core_offer( array( 'new_files' => false ) ), true ), 'core with new files' => array( 'core', self::core_offer( array( 'new_files' => true ) ), false ), @@ -305,7 +305,7 @@ public function test_disable_autoupdate_flag_overrides_choice_but_not_filter() { * * @ticket 65819 * - * @dataProvider data_filter_values + * @dataProvider data_auto_update_filter * * @param mixed $filtered Value returned by the filter. * @param bool $expected Whether the item should be updated. @@ -332,7 +332,7 @@ static function () use ( $filtered ) { * * @return array[] */ - public static function data_filter_values() { + public static function data_auto_update_filter() { return array( 'true' => array( true, true ), 'false' => array( false, false ), @@ -358,7 +358,7 @@ public function test_sends_core_notification_when_core_update_is_declined() { * * @ticket 65819 * - * @dataProvider data_core_update_policy + * @dataProvider data_core_update_follows_core_update_policy * * @param bool $allow_major Whether the core update policy allows major updates. * @param bool $expected Whether core should be updated. @@ -375,7 +375,7 @@ public function test_core_update_follows_core_update_policy( $allow_major, $expe * * @return array[] */ - public static function data_core_update_policy() { + public static function data_core_update_follows_core_update_policy() { return array( 'policy allows the update' => array( true, true ), 'policy denies the update' => array( false, false ), @@ -387,7 +387,7 @@ public static function data_core_update_policy() { * * @ticket 65819 * - * @dataProvider data_core_requirements + * @dataProvider data_core_update_requirements * * @param array $fields Fields of the update offer. * @param bool $expected Whether core should be updated. @@ -403,7 +403,7 @@ public function test_core_update_requirements( $fields, $expected ) { * * @return array[] */ - public static function data_core_requirements() { + public static function data_core_update_requirements() { return array( 'requirements met' => array( array(), true ), 'PHP version too old' => array( array( 'php_version' => '99.0' ), false ), diff --git a/tests/phpunit/tests/admin/wpColorSchemeMenuIconStyles.php b/tests/phpunit/tests/admin/wpColorSchemeMenuIconStyles.php index 85daae297deed..73d0006f0964c 100644 --- a/tests/phpunit/tests/admin/wpColorSchemeMenuIconStyles.php +++ b/tests/phpunit/tests/admin/wpColorSchemeMenuIconStyles.php @@ -79,7 +79,7 @@ public function test_adds_icon_colors_of_third_party_scheme(): void { /** * @ticket 65089 * - * @dataProvider data_schemes_without_icon_styles + * @dataProvider data_adds_nothing_for_other_schemes * * @param string $url URL of the stylesheet of the scheme. * @param array $icons Icon colors of the scheme. @@ -97,7 +97,7 @@ public function test_adds_nothing_for_other_schemes( $url, $icons ): void { * * @return array }> */ - public static function data_schemes_without_icon_styles(): array { + public static function data_adds_nothing_for_other_schemes(): array { $icons = array( 'base' => '#aaaaaa', 'focus' => '#bbbbbb', diff --git a/tests/phpunit/tests/admin/wpCommentsListTable.php b/tests/phpunit/tests/admin/wpCommentsListTable.php index b1bbce346328a..533403b9041b4 100644 --- a/tests/phpunit/tests/admin/wpCommentsListTable.php +++ b/tests/phpunit/tests/admin/wpCommentsListTable.php @@ -221,7 +221,7 @@ public function test_get_views_should_return_views_by_default() { * @ticket 64474 * @ticket 64638 * - * @dataProvider data_comment_type + * @dataProvider data_comments_list_table_does_not_show_internal_comment_types * * @param string $comment_type The comment_type parameter value to test. */ @@ -272,7 +272,7 @@ public function test_comments_list_table_does_not_show_internal_comment_types( s * * @return array */ - public static function data_comment_type(): array { + public static function data_comments_list_table_does_not_show_internal_comment_types(): array { return array( 'note type explicitly requested' => array( 'note' ), 'reaction type explicitly requested' => array( 'reaction' ), diff --git a/tests/phpunit/tests/admin/wpDebugDataPlugins.php b/tests/phpunit/tests/admin/wpDebugDataPlugins.php index d4a9e848473da..1a80fd3186629 100644 --- a/tests/phpunit/tests/admin/wpDebugDataPlugins.php +++ b/tests/phpunit/tests/admin/wpDebugDataPlugins.php @@ -261,7 +261,7 @@ public function test_plugins_should_ignore_auto_update_setting_when_disabled() { * * @ticket 65819 * - * @dataProvider data_update_items + * @dataProvider data_plugins_should_pass_update_item_to_auto_update_filter * * @param string $transient_list The transient list holding the plugin, or an empty string for none. * @param string $new_version The expected new version of the item. @@ -295,7 +295,7 @@ public function test_plugins_should_pass_update_item_to_auto_update_filter( $tra * * @return array[] */ - public static function data_update_items() { + public static function data_plugins_should_pass_update_item_to_auto_update_filter() { return array( 'available update' => array( 'response', '2.0', '' ), 'no update' => array( 'no_update', '2.0', '' ), diff --git a/tests/phpunit/tests/admin/wpEditThemePluginFilePlugin.php b/tests/phpunit/tests/admin/wpEditThemePluginFilePlugin.php index a97fa7e37a851..2a533dad007e4 100644 --- a/tests/phpunit/tests/admin/wpEditThemePluginFilePlugin.php +++ b/tests/phpunit/tests/admin/wpEditThemePluginFilePlugin.php @@ -154,7 +154,7 @@ public function tear_down() { * * @ticket 65819 * - * @dataProvider data_incomplete_requests + * @dataProvider data_should_reject_incomplete_request * * @param array $args The arguments, merged over a valid request. * @param string $code The expected error code. @@ -180,7 +180,7 @@ static function ( $value ) { * * @return array[] */ - public static function data_incomplete_requests() { + public static function data_should_reject_incomplete_request() { return array( 'no file' => array( array( 'file' => null ), 'missing_file' ), 'empty file' => array( array( 'file' => '' ), 'missing_file' ), @@ -329,7 +329,7 @@ static function ( $types ) { * * @ticket 65819 * - * @dataProvider data_files + * @dataProvider data_should_save_file_of_inactive_plugin * * @param string $file The file, relative to the plugin directory. */ @@ -344,7 +344,7 @@ public function test_should_save_file_of_inactive_plugin( $file ) { * * @return array[] */ - public static function data_files() { + public static function data_should_save_file_of_inactive_plugin() { return array( 'text file' => array( 'readme.txt' ), 'main plugin file' => array( self::SLUG . '.php' ), @@ -450,7 +450,7 @@ public function test_should_trigger_loopback_for_network_active_plugin() { * * @ticket 65819 * - * @dataProvider data_failed_loopbacks + * @dataProvider data_should_revert_php_file_of_active_plugin_when_loopback_fails * * @param array $scrape_results The scrape results of the loopback requests. * @param string $message The expected error message. @@ -478,7 +478,7 @@ public function test_should_revert_php_file_of_active_plugin_when_loopback_fails * * @return array[] */ - public static function data_failed_loopbacks() { + public static function data_should_revert_php_file_of_active_plugin_when_loopback_fails() { $loopback_failed = 'Unable to communicate back with site to check for fatal errors, so the PHP change was reverted. You will need to upload your PHP file change by some other means, such as by using SFTP.'; $editor_path = wp_parse_url( admin_url( 'plugin-editor.php' ), PHP_URL_PATH ); $home_path = wp_parse_url( home_url( '/' ), PHP_URL_PATH ); diff --git a/tests/phpunit/tests/admin/wpImporter.php b/tests/phpunit/tests/admin/wpImporter.php index 6eea810a971d3..fcd9c1737afa2 100644 --- a/tests/phpunit/tests/admin/wpImporter.php +++ b/tests/phpunit/tests/admin/wpImporter.php @@ -190,7 +190,7 @@ public function test_set_blog_returns_numeric_blog_id() { * * @group ms-required * - * @dataProvider data_set_blog_on_multisite + * @dataProvider data_set_blog_switches_to_blog_on_multisite * * @param string $blog Blog ID placeholder or URL passed to set_blog(). */ @@ -218,7 +218,7 @@ public function test_set_blog_switches_to_blog_on_multisite( $blog ) { * * @return array[] */ - public static function data_set_blog_on_multisite() { + public static function data_set_blog_switches_to_blog_on_multisite() { return array( 'numeric ID' => array( '%id%' ), 'URL with scheme' => array( 'https://importer.example.org/target/' ), @@ -282,7 +282,7 @@ public function test_cmpr_strlen_sorts_longest_first() { * @covers WP_Importer::get_page * @covers WP_Importer::bump_request_timeout * - * @dataProvider data_get_page_requests + * @dataProvider data_get_page_request * * @param string $username Username. * @param string $password Password. @@ -336,7 +336,7 @@ static function ( $response, $args, $url ) use ( &$requests ) { * * @return array[] */ - public static function data_get_page_requests() { + public static function data_get_page_request() { return array( 'GET without credentials' => array( '', '', false, 'GET', null ), 'HEAD request' => array( '', '', true, 'HEAD', null ), @@ -369,7 +369,7 @@ public function test_is_user_over_quota_on_single_site() { * * @group ms-required * - * @dataProvider data_quota_usage + * @dataProvider data_is_user_over_quota_on_multisite * * @param int $space_used Space used, in megabytes. * @param bool $expected Whether the user should be over quota. @@ -401,7 +401,7 @@ static function () use ( $space_used ) { * * @return array[] */ - public static function data_quota_usage() { + public static function data_is_user_over_quota_on_multisite() { return array( 'under quota' => array( 5, false, '' ), 'over quota' => array( 20, true, 'Sorry, you have used your space allocation of 10 MB. Please delete some files to upload more files.' ), diff --git a/tests/phpunit/tests/admin/wpMenuOutput.php b/tests/phpunit/tests/admin/wpMenuOutput.php index 09e2c2a8fd384..6cad31b3cad7e 100644 --- a/tests/phpunit/tests/admin/wpMenuOutput.php +++ b/tests/phpunit/tests/admin/wpMenuOutput.php @@ -55,7 +55,7 @@ public function set_up() { * * @covers ::_wp_menu_output * - * @dataProvider data_replaced_dashicons + * @dataProvider data_core_dashicon_is_rendered_as_svg_icon * * @param string $dashicon Dashicon class name. */ @@ -74,7 +74,7 @@ public function test_core_dashicon_is_rendered_as_svg_icon( $dashicon ): void { * * @return array */ - public static function data_replaced_dashicons(): array { + public static function data_core_dashicon_is_rendered_as_svg_icon(): array { return array( 'dashboard' => array( 'dashicons-dashboard' ), 'posts' => array( 'dashicons-admin-post' ), @@ -127,7 +127,7 @@ public function test_dashicon_with_unregistered_replacement_is_rendered_as_dashi * * @covers ::_wp_menu_output * - * @dataProvider data_unchanged_icons + * @dataProvider data_other_icon_is_rendered_as_before * * @param string $icon The icon of the menu item. * @param string $expected The expected HTML of the icon element. @@ -147,7 +147,7 @@ public function test_other_icon_is_rendered_as_before( $icon, $expected ): void * * @return array */ - public static function data_unchanged_icons(): array { + public static function data_other_icon_is_rendered_as_before(): array { return array( 'other Dashicon' => array( 'dashicons-heart', diff --git a/tests/phpunit/tests/admin/wpPluginInstallListTableGetDependenciesNotice.php b/tests/phpunit/tests/admin/wpPluginInstallListTableGetDependenciesNotice.php index 776e6f6e6cc25..c4a2e7dcb2825 100644 --- a/tests/phpunit/tests/admin/wpPluginInstallListTableGetDependenciesNotice.php +++ b/tests/phpunit/tests/admin/wpPluginInstallListTableGetDependenciesNotice.php @@ -92,7 +92,7 @@ public function tear_down() { * * @ticket 65819 * - * @dataProvider data_no_dependencies + * @dataProvider data_should_return_empty_string_without_dependencies * * @param array $plugin_data The plugin data. */ @@ -105,7 +105,7 @@ public function test_should_return_empty_string_without_dependencies( $plugin_da * * @return array[] */ - public static function data_no_dependencies() { + public static function data_should_return_empty_string_without_dependencies() { return array( 'no requires_plugins key' => array( array( 'slug' => 'my-plugin' ) ), 'empty array' => array( array( 'requires_plugins' => array() ) ), @@ -163,7 +163,7 @@ public function test_should_use_slug_from_dependency_data() { * * @ticket 65819 * - * @dataProvider data_incomplete_dependency_data + * @dataProvider data_should_fall_back_to_plugins_api_for_incomplete_dependency_data * * @param array|false $dependency_data The stored dependency data, or false for none. */ @@ -190,7 +190,7 @@ public function test_should_fall_back_to_plugins_api_for_incomplete_dependency_d * * @return array[] */ - public static function data_incomplete_dependency_data() { + public static function data_should_fall_back_to_plugins_api_for_incomplete_dependency_data() { $complete = array( 'name' => 'Dep One', 'slug' => 'dep-one', @@ -228,7 +228,7 @@ public function test_should_use_slug_from_plugins_api() { * * @ticket 65819 * - * @dataProvider data_unnamed_api_responses + * @dataProvider data_should_list_dependency_by_slug_without_name * * @param string $response The plugins API response type. */ @@ -251,7 +251,7 @@ public function test_should_list_dependency_by_slug_without_name( $response ) { * * @return array[] */ - public static function data_unnamed_api_responses() { + public static function data_should_list_dependency_by_slug_without_name() { return array( 'API error' => array( 'error' ), 'API data, no name' => array( 'no name' ), diff --git a/tests/phpunit/tests/admin/wpPluginInstallListTableNoItems.php b/tests/phpunit/tests/admin/wpPluginInstallListTableNoItems.php index 5ee2fbe7627fb..7e66774942340 100644 --- a/tests/phpunit/tests/admin/wpPluginInstallListTableNoItems.php +++ b/tests/phpunit/tests/admin/wpPluginInstallListTableNoItems.php @@ -70,7 +70,7 @@ public function test_no_items_should_suggest_a_different_search() { * * @covers WP_Plugin_Install_List_Table::display_tablenav * - * @dataProvider data_positions + * @dataProvider data_display_tablenav_should_output_nothing_on_featured_tab * * @param string $which The navigation position. */ @@ -85,7 +85,7 @@ public function test_display_tablenav_should_output_nothing_on_featured_tab( $wh * * @return array[] */ - public static function data_positions() { + public static function data_display_tablenav_should_output_nothing_on_featured_tab() { return array( 'top' => array( 'top' ), 'bottom' => array( 'bottom' ), diff --git a/tests/phpunit/tests/admin/wpPluginsListTableActionLinks.php b/tests/phpunit/tests/admin/wpPluginsListTableActionLinks.php index 644c321388cae..7245ab00a13ec 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTableActionLinks.php +++ b/tests/phpunit/tests/admin/wpPluginsListTableActionLinks.php @@ -309,7 +309,7 @@ public static function data_circular_dependencies() { * * @ticket 65819 * - * @dataProvider data_active_states + * @dataProvider data_should_not_add_links_for_user_without_capabilities * * @param bool $active Whether the plugin is active. */ @@ -329,7 +329,7 @@ public function test_should_not_add_links_for_user_without_capabilities( $active * * @return array[] */ - public static function data_active_states() { + public static function data_should_not_add_links_for_user_without_capabilities() { return array( 'active plugin' => array( true ), 'inactive plugin' => array( false ), diff --git a/tests/phpunit/tests/admin/wpPluginsListTableDependencyRow.php b/tests/phpunit/tests/admin/wpPluginsListTableDependencyRow.php index 56e546fe044f1..94d72079184c0 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTableDependencyRow.php +++ b/tests/phpunit/tests/admin/wpPluginsListTableDependencyRow.php @@ -123,7 +123,7 @@ public function test_should_list_dependencies_with_details_links() { * * @ticket 65819 * - * @dataProvider data_unlinked_dependencies + * @dataProvider data_should_not_link_dependency * * @param array $api_data The plugin directory data of the dependency. * @param string $expected The expected dependency markup. @@ -140,7 +140,7 @@ public function test_should_not_link_dependency( $api_data, $expected ) { * * @return array[] */ - public static function data_unlinked_dependencies() { + public static function data_should_not_link_dependency() { return array( 'no version' => array( array( diff --git a/tests/phpunit/tests/admin/wpPluginsListTableGetBulkActions.php b/tests/phpunit/tests/admin/wpPluginsListTableGetBulkActions.php index 0c3f51e68feb9..15c294c429add 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTableGetBulkActions.php +++ b/tests/phpunit/tests/admin/wpPluginsListTableGetBulkActions.php @@ -91,7 +91,7 @@ public function tear_down() { * * @group ms-excluded * - * @dataProvider data_statuses + * @dataProvider data_should_return_bulk_actions_for_status * * @param string $status The plugin status. * @param string[] $expected The expected bulk action names. @@ -107,7 +107,7 @@ public function test_should_return_bulk_actions_for_status( $status, $expected ) * * @return array[] */ - public static function data_statuses() { + public static function data_should_return_bulk_actions_for_status() { $all = array( 'activate-selected', 'deactivate-selected', diff --git a/tests/phpunit/tests/admin/wpPluginsListTableNetworkActionLinks.php b/tests/phpunit/tests/admin/wpPluginsListTableNetworkActionLinks.php index fa1f1bc62907a..b26fcba8e2fcd 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTableNetworkActionLinks.php +++ b/tests/phpunit/tests/admin/wpPluginsListTableNetworkActionLinks.php @@ -317,7 +317,7 @@ public static function data_circular_dependencies() { * * @ticket 65819 * - * @dataProvider data_network_active_states + * @dataProvider data_should_not_add_links_for_user_without_network_capabilities * * @param bool $network_active Whether the plugin is network active. */ @@ -336,7 +336,7 @@ public function test_should_not_add_links_for_user_without_network_capabilities( * * @return array[] */ - public static function data_network_active_states() { + public static function data_should_not_add_links_for_user_without_network_capabilities() { return array( 'network-active plugin' => array( true ), 'inactive plugin' => array( false ), diff --git a/tests/phpunit/tests/admin/wpPluginsListTablePrepareItems.php b/tests/phpunit/tests/admin/wpPluginsListTablePrepareItems.php index 14e4297ba6f1b..a10787f47b8d3 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTablePrepareItems.php +++ b/tests/phpunit/tests/admin/wpPluginsListTablePrepareItems.php @@ -285,7 +285,7 @@ public function test_should_respect_show_advanced_plugins_filter() { * * @group ms-required * - * @dataProvider data_show_network_active + * @dataProvider data_should_list_network_active_plugins_on_site_when_allowed * * @param bool $show Whether network-active plugins are shown. */ @@ -304,7 +304,7 @@ public function test_should_list_network_active_plugins_on_site_when_allowed( $s * * @return array[] */ - public static function data_show_network_active() { + public static function data_should_list_network_active_plugins_on_site_when_allowed() { return array( 'shown' => array( true ), 'hidden' => array( false ), diff --git a/tests/phpunit/tests/admin/wpPluginsListTableRequiredByRow.php b/tests/phpunit/tests/admin/wpPluginsListTableRequiredByRow.php index 04ff14293bdbb..7bbb4126719b4 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTableRequiredByRow.php +++ b/tests/phpunit/tests/admin/wpPluginsListTableRequiredByRow.php @@ -49,7 +49,7 @@ public function test_should_list_dependent() { * * @ticket 65819 * - * @dataProvider data_single_file_plugins + * @dataProvider data_should_match_single_file_dependency_by_slug * * @param string $plugin_file The plugin file. * @param string $slug The slug that dependents require. @@ -65,7 +65,7 @@ public function test_should_match_single_file_dependency_by_slug( $plugin_file, * * @return array[] */ - public static function data_single_file_plugins() { + public static function data_should_match_single_file_dependency_by_slug() { return array( 'single-file plugin' => array( 'my-plugin.php', 'my-plugin' ), 'Hello Dolly' => array( 'hello.php', 'hello-dolly' ), diff --git a/tests/phpunit/tests/admin/wpPluginsListTableRowCheckbox.php b/tests/phpunit/tests/admin/wpPluginsListTableRowCheckbox.php index c3181b222ecc4..b3ee5184aa568 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTableRowCheckbox.php +++ b/tests/phpunit/tests/admin/wpPluginsListTableRowCheckbox.php @@ -112,7 +112,7 @@ public function test_should_mark_active_row() { * * @ticket 65819 * - * @dataProvider data_dependency_states + * @dataProvider data_should_disable_checkbox_for_dependency_state * * @param string $state The dependency state, 'dependents' or 'unmet'. */ @@ -134,7 +134,7 @@ public function test_should_disable_checkbox_for_dependency_state( $state ) { * * @return array[] */ - public static function data_dependency_states() { + public static function data_should_disable_checkbox_for_dependency_state() { return array( 'plugin with dependents' => array( 'dependents' ), 'plugin with unmet dependencies' => array( 'unmet' ), @@ -176,7 +176,7 @@ public function test_should_keep_checkbox_for_incompatible_wordpress() { * * @ticket 65819 * - * @dataProvider data_update_states + * @dataProvider data_should_mark_plugin_with_update * * @param array $totals The status totals. * @param bool $update Whether the plugin data has an update. @@ -195,7 +195,7 @@ public function test_should_mark_plugin_with_update( $totals, $update, $expected * * @return array[] */ - public static function data_update_states() { + public static function data_should_mark_plugin_with_update() { return array( 'update and upgrade total' => array( array( 'upgrade' => 1 ), true, 'inactive update' ), 'update without upgrade total' => array( array(), true, 'inactive' ), @@ -248,7 +248,7 @@ public function test_should_hide_checkbox_for_must_use_plugins() { * * @group ms-required * - * @dataProvider data_network_restrictions + * @dataProvider data_should_hide_checkbox_for_network_restricted_plugin * * @param bool $network_active Whether the plugin is network active. * @param string $headers Additional plugin headers. @@ -266,7 +266,7 @@ public function test_should_hide_checkbox_for_network_restricted_plugin( $networ * * @return array[] */ - public static function data_network_restrictions() { + public static function data_should_hide_checkbox_for_network_restricted_plugin() { return array( 'network active' => array( true, '' ), 'network only' => array( false, " * Network: true\n" ), diff --git a/tests/phpunit/tests/admin/wpPluginsListTableSearchBox.php b/tests/phpunit/tests/admin/wpPluginsListTableSearchBox.php index 2982b9158d08d..3bb962cfe7e84 100644 --- a/tests/phpunit/tests/admin/wpPluginsListTableSearchBox.php +++ b/tests/phpunit/tests/admin/wpPluginsListTableSearchBox.php @@ -168,7 +168,7 @@ public function test_get_sortable_columns_should_return_no_columns() { * * @covers WP_Plugins_List_Table::_order_callback * - * @dataProvider data_orders + * @dataProvider data_order_callback_should_compare_by_field * * @param string $order The sort order. * @param string $a The first value. @@ -198,7 +198,7 @@ public function test_order_callback_should_compare_by_field( $order, $a, $b, $ex * * @return array[] */ - public static function data_orders() { + public static function data_order_callback_should_compare_by_field() { return array( 'equal values' => array( 'ASC', 'Alpha', 'Alpha', 0 ), 'ascending' => array( 'ASC', 'Alpha', 'beta', -1 ), diff --git a/tests/phpunit/tests/admin/wpPostsListTable.php b/tests/phpunit/tests/admin/wpPostsListTable.php index 50fd032c86265..1dadb4c5c2bd5 100644 --- a/tests/phpunit/tests/admin/wpPostsListTable.php +++ b/tests/phpunit/tests/admin/wpPostsListTable.php @@ -489,7 +489,7 @@ public function test_prepare_items_should_only_include_scheduled_posts_when_filt /** * @ticket 65772 - * @dataProvider data_scheduled_post_date_column_status + * @dataProvider data_column_date_should_show_scheduled_post_status * @covers WP_Posts_List_Table::column_date * * @param int $offset Seconds from now to the scheduled date. @@ -524,7 +524,7 @@ public function test_column_date_should_show_scheduled_post_status( $offset, $ex /** * @return array[] */ - public static function data_scheduled_post_date_column_status() { + public static function data_column_date_should_show_scheduled_post_status() { return array( 'future date' => array( DAY_IN_SECONDS, 'Scheduled' ), 'past due date' => array( -DAY_IN_SECONDS, 'Missed schedule' ), diff --git a/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php b/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php index 6b339add4d7f7..37908d5547dd2 100644 --- a/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php +++ b/tests/phpunit/tests/admin/wpPrivacyRequestsTable.php @@ -254,7 +254,7 @@ public function test_get_timestamp_as_date() { * * @ticket 65819 * - * @dataProvider data_request_tables + * @dataProvider data_request_email_is_escaped_in_columns * * @covers WP_Privacy_Requests_Table::column_email * @covers WP_Privacy_Requests_Table::column_cb @@ -296,7 +296,7 @@ public function test_request_email_is_escaped_in_columns( $table_class, $request * * @return array */ - public static function data_request_tables() { + public static function data_request_email_is_escaped_in_columns() { return array( 'base requests table' => array( '', 'export_personal_data' ), 'export requests list' => array( 'WP_Privacy_Data_Export_Requests_List_Table', 'export_personal_data' ), diff --git a/tests/phpunit/tests/admin/wpSiteHealthGetTestInsecureRegistration.php b/tests/phpunit/tests/admin/wpSiteHealthGetTestInsecureRegistration.php index 402dff0a4161f..725701eca1a89 100644 --- a/tests/phpunit/tests/admin/wpSiteHealthGetTestInsecureRegistration.php +++ b/tests/phpunit/tests/admin/wpSiteHealthGetTestInsecureRegistration.php @@ -24,7 +24,7 @@ public static function set_up_before_class() { * * @ticket 66359 * - * @dataProvider data_registration_settings + * @dataProvider data_status_depends_on_registration_and_default_role * * @param int $users_can_register Whether anyone can register. * @param string $default_role The default role for new users. @@ -45,7 +45,7 @@ public function test_status_depends_on_registration_and_default_role( $users_can * * @return array */ - public static function data_registration_settings() { + public static function data_status_depends_on_registration_and_default_role() { return array( 'registration closed, administrator' => array( 0, 'administrator', 'good' ), 'registration closed, editor' => array( 0, 'editor', 'good' ), diff --git a/tests/phpunit/tests/admin/wpSiteHealthGetTestPluginVersion.php b/tests/phpunit/tests/admin/wpSiteHealthGetTestPluginVersion.php index 3aad5118d1bf5..e160539bffedc 100644 --- a/tests/phpunit/tests/admin/wpSiteHealthGetTestPluginVersion.php +++ b/tests/phpunit/tests/admin/wpSiteHealthGetTestPluginVersion.php @@ -71,7 +71,7 @@ public function tear_down() { * * @ticket 65819 * - * @dataProvider data_active_plugins + * @dataProvider data_should_report_active_plugins_up_to_date * * @param int $count The number of installed, active plugins. * @param string $sentence The expected sentence. @@ -100,7 +100,7 @@ public function test_should_report_active_plugins_up_to_date( $count, $sentence * * @return array[] */ - public static function data_active_plugins() { + public static function data_should_report_active_plugins_up_to_date() { return array( 'one plugin' => array( 1, 'Your site has 1 active plugin, and it is up to date.' ), 'two plugins' => array( 2, 'Your site has 2 active plugins, and they are all up to date.' ), @@ -112,7 +112,7 @@ public static function data_active_plugins() { * * @ticket 65819 * - * @dataProvider data_outdated_plugins + * @dataProvider data_should_report_outdated_plugins * * @param int $outdated The number of plugins with an update. * @param string $sentence The expected sentence. @@ -138,7 +138,7 @@ public function test_should_report_outdated_plugins( $outdated, $sentence ) { * * @return array[] */ - public static function data_outdated_plugins() { + public static function data_should_report_outdated_plugins() { return array( 'one outdated plugin' => array( 1, 'Your site has 1 plugin waiting to be updated.' ), 'two outdated plugins' => array( 2, 'Your site has 2 plugins waiting to be updated.' ), @@ -170,7 +170,7 @@ public function test_should_ignore_updates_for_plugins_not_installed() { * * @group ms-excluded * - * @dataProvider data_inactive_plugins + * @dataProvider data_should_recommend_removing_inactive_plugins * * @param int $total The number of installed plugins. * @param int $active The number of active plugins. @@ -200,7 +200,7 @@ public function test_should_recommend_removing_inactive_plugins( $total, $active * * @return array[] */ - public static function data_inactive_plugins() { + public static function data_should_recommend_removing_inactive_plugins() { return array( 'one inactive plugin' => array( 2, 1, 'Your site has 1 inactive plugin.' ), 'two inactive plugins' => array( 3, 1, 'Your site has 2 inactive plugins.' ), diff --git a/tests/phpunit/tests/admin/wpUpgraderSkin.php b/tests/phpunit/tests/admin/wpUpgraderSkin.php index a4746e78a7375..55e60bb56f271 100644 --- a/tests/phpunit/tests/admin/wpUpgraderSkin.php +++ b/tests/phpunit/tests/admin/wpUpgraderSkin.php @@ -40,7 +40,7 @@ private function decrement_update_count( WP_Upgrader_Skin $skin, string $type ): * * @ticket 59446 * - * @dataProvider data_results_that_should_print_nothing + * @dataProvider data_decrement_update_count_should_print_nothing_without_a_usable_result * * @covers WP_Upgrader_Skin::decrement_update_count * @@ -58,7 +58,7 @@ public function test_decrement_update_count_should_print_nothing_without_a_usabl * * @return array */ - public static function data_results_that_should_print_nothing(): array { + public static function data_decrement_update_count_should_print_nothing_without_a_usable_result(): array { return array( 'a false result' => array( 'result' => false ), 'a WP_Error result' => array( 'result' => new WP_Error( 'test_error' ) ), diff --git a/tests/phpunit/tests/ai-client/wpAiClientPromptBuilder.php b/tests/phpunit/tests/ai-client/wpAiClientPromptBuilder.php index 89d864fa1f696..88aff2d76cc53 100644 --- a/tests/phpunit/tests/ai-client/wpAiClientPromptBuilder.php +++ b/tests/phpunit/tests/ai-client/wpAiClientPromptBuilder.php @@ -2749,7 +2749,7 @@ public function test_support_check_methods_return_false_in_error_state() { * * @ticket 65781 * - * @dataProvider data_support_check_methods + * @dataProvider data_support_check_methods_return_false_when_builder_throws * * @param string $method The support check method on the wrapper. * @param string $wrapped_method The matching method on the wrapped builder. @@ -2785,7 +2785,7 @@ public function test_support_check_methods_return_false_when_builder_throws( $me * * @return array Support check method names, keyed by the method on the wrapper. */ - public static function data_support_check_methods(): array { + public static function data_support_check_methods_return_false_when_builder_throws(): array { return array( 'is_supported' => array( 'is_supported', 'isSupported' ), 'is_supported_for_text_generation' => array( 'is_supported_for_text_generation', 'isSupportedForTextGeneration' ), diff --git a/tests/phpunit/tests/ajax/wpAjaxCheckPluginDependencies.php b/tests/phpunit/tests/ajax/wpAjaxCheckPluginDependencies.php index 70dda155a4d79..a2df24402a4ee 100644 --- a/tests/phpunit/tests/ajax/wpAjaxCheckPluginDependencies.php +++ b/tests/phpunit/tests/ajax/wpAjaxCheckPluginDependencies.php @@ -129,7 +129,7 @@ public function test_should_reject_request_without_nonce() { * * @ticket 65819 * - * @dataProvider data_empty_slugs + * @dataProvider data_should_return_error_without_slug * * @param string|null $slug The slug, or null to leave it out. */ @@ -159,7 +159,7 @@ public function test_should_return_error_without_slug( $slug ) { * * @return array[] */ - public static function data_empty_slugs() { + public static function data_should_return_error_without_slug() { return array( 'missing slug' => array( null ), 'empty string' => array( '' ), diff --git a/tests/phpunit/tests/ajax/wpAjaxMetaBoxReordering.php b/tests/phpunit/tests/ajax/wpAjaxMetaBoxReordering.php index 26bc5b05749b4..7d14022bea639 100644 --- a/tests/phpunit/tests/ajax/wpAjaxMetaBoxReordering.php +++ b/tests/phpunit/tests/ajax/wpAjaxMetaBoxReordering.php @@ -15,7 +15,7 @@ class Tests_Ajax_wpAjaxMetaBoxReordering extends WP_Ajax_UnitTestCase { /** - * @dataProvider data_meta_box_reordering_states + * @dataProvider data_wp_ajax_meta_box_reordering_saves_user_option * * @param int|string $enabled Whether meta box reordering is enabled. * @param string $expected The expected stored user option. @@ -43,7 +43,7 @@ public function test_wp_ajax_meta_box_reordering_saves_user_option( $enabled, $e * * @return array[] */ - public static function data_meta_box_reordering_states() { + public static function data_wp_ajax_meta_box_reordering_saves_user_option() { return array( 'enabled' => array( 1, 'enabled' ), 'enabled as string' => array( '1', 'enabled' ), diff --git a/tests/phpunit/tests/block-bindings/patternOverridesSource.php b/tests/phpunit/tests/block-bindings/patternOverridesSource.php index 233e2758d656a..3fb6794a73c1d 100644 --- a/tests/phpunit/tests/block-bindings/patternOverridesSource.php +++ b/tests/phpunit/tests/block-bindings/patternOverridesSource.php @@ -55,7 +55,7 @@ public function test_source_registration() { * * @covers ::_block_bindings_pattern_overrides_get_value * - * @dataProvider data_empty_metadata_names + * @dataProvider data_get_value_returns_null_when_metadata_name_empty * * @param array $attributes Block attributes. */ @@ -79,7 +79,7 @@ public function test_get_value_returns_null_when_metadata_name_empty( array $att * * @return array[] */ - public static function data_empty_metadata_names() { + public static function data_get_value_returns_null_when_metadata_name_empty() { return array( 'empty attributes' => array( array() ), 'empty metadata array' => array( array( 'metadata' => array() ) ), @@ -194,7 +194,7 @@ public function test_source_get_value_method() { * * @covers ::_block_bindings_pattern_overrides_get_value * - * @dataProvider data_override_values_and_types + * @dataProvider data_get_value_handles_different_data_types * * @param mixed $expected Expected value. */ @@ -224,7 +224,7 @@ public function test_get_value_handles_different_data_types( $expected ) { * * @return array[] */ - public static function data_override_values_and_types() { + public static function data_get_value_handles_different_data_types() { return array( 'empty string' => array( '' ), 'zero integer' => array( 0 ), diff --git a/tests/phpunit/tests/block-bindings/postDataSource.php b/tests/phpunit/tests/block-bindings/postDataSource.php index 57a0d3d641750..74893be83d03f 100644 --- a/tests/phpunit/tests/block-bindings/postDataSource.php +++ b/tests/phpunit/tests/block-bindings/postDataSource.php @@ -195,7 +195,7 @@ public static function data_missing_or_empty_field_args() { * * @covers ::_block_bindings_post_data_get_value * - * @dataProvider data_missing_or_empty_post_id + * @dataProvider data_get_value_returns_null_when_post_id_missing * * @param array $context Block context. */ @@ -210,7 +210,7 @@ public function test_get_value_returns_null_when_post_id_missing( array $context * * @return array */ - public static function data_missing_or_empty_post_id() { + public static function data_get_value_returns_null_when_post_id_missing() { return array( 'missing postId context' => array( array() ), 'zero postId' => array( array( 'postId' => 0 ) ), diff --git a/tests/phpunit/tests/block-bindings/termDataSource.php b/tests/phpunit/tests/block-bindings/termDataSource.php index c8b95cedfc783..7e46826ea893b 100644 --- a/tests/phpunit/tests/block-bindings/termDataSource.php +++ b/tests/phpunit/tests/block-bindings/termDataSource.php @@ -151,7 +151,7 @@ public static function data_missing_or_empty_field_args() { * * @covers ::_block_bindings_term_data_get_value * - * @dataProvider data_missing_or_empty_context + * @dataProvider data_get_value_returns_null_when_context_empty * * @param array $context Context array. */ @@ -166,7 +166,7 @@ public function test_get_value_returns_null_when_context_empty( array $context ) * * @return array */ - public static function data_missing_or_empty_context() { + public static function data_get_value_returns_null_when_context_empty() { return array( 'missing taxonomy' => array( array( 'termId' => 123 ) ), 'missing termId' => array( array( 'taxonomy' => 'category' ) ), @@ -241,7 +241,7 @@ public function test_get_value_returns_null_for_unsupported_field() { * * @covers ::_block_bindings_term_data_get_value * - * @dataProvider data_supported_fields + * @dataProvider data_get_value_returns_supported_fields * * @param string $field Field name. * @param string $expected Expected field value. @@ -263,7 +263,7 @@ public function test_get_value_returns_supported_fields( $field, $expected ) { * * @return array */ - public static function data_supported_fields() { + public static function data_get_value_returns_supported_fields() { return array( 'name' => array( 'name', 'Test Category' ), 'slug' => array( 'slug', 'test-category' ), diff --git a/tests/phpunit/tests/block-processor/wpBlockProcessor.php b/tests/phpunit/tests/block-processor/wpBlockProcessor.php index 4cc96e6da0c39..70cfdddc8e85c 100644 --- a/tests/phpunit/tests/block-processor/wpBlockProcessor.php +++ b/tests/phpunit/tests/block-processor/wpBlockProcessor.php @@ -315,7 +315,7 @@ public static function data_invalid_block_delimiters_as_html_comments() { * * @ticket 66138 * - * @dataProvider data_terminal_non_delimiter_comments + * @dataProvider data_preserves_terminal_non_delimiter_comments_as_html * * @param string $html Input ending in a non-delimiter HTML comment. */ @@ -354,7 +354,7 @@ public function test_preserves_terminal_non_delimiter_comments_as_html( string $ * * @return array */ - public static function data_terminal_non_delimiter_comments(): array { + public static function data_preserves_terminal_non_delimiter_comments_as_html(): array { return array( 'Ordinary comment' => array( 'content' ), 'Abrupt empty comment' => array( 'content' ), @@ -429,7 +429,7 @@ public static function data_incomplete_html_comments_that_are_not_delimiters() { * * @ticket 66138 * - * @dataProvider data_documents_ending_in_a_partial_delimiter + * @dataProvider data_reports_no_delimiter_for_partial_delimiter_at_end_of_document * * @covers ::next_token() * @@ -463,7 +463,7 @@ public function test_reports_no_delimiter_for_partial_delimiter_at_end_of_docume * * @return array */ - public static function data_documents_ending_in_a_partial_delimiter(): array { + public static function data_reports_no_delimiter_for_partial_delimiter_at_end_of_document(): array { return array( // Documents ending in a partial delimiter with no earlier delimiter. 'Ends in <' => array( 'text<', array(), WP_Block_Processor::INCOMPLETE_INPUT ), @@ -602,7 +602,7 @@ public function test_does_not_match_block_with_content_after_json() { * * @ticket 66138 * - * @dataProvider data_delimiters_and_comment_endings + * @dataProvider data_delimiter_does_not_span_a_comment_ending * * @param string $html Document to scan. * @param string[] $block_types Printable block type of every delimiter in the document, in order. @@ -622,33 +622,12 @@ public function test_delimiter_does_not_span_a_comment_ending( string $html, arr ); } - /** - * Verifies that a comment ended by `--!>` at the end of the document is not - * reported as incomplete input: the comment is closed, so no delimiter could - * be completed by further input. - * - * @ticket 66138 - */ - public function test_exclamation_ending_at_end_of_document_is_not_incomplete_input(): void { - $processor = new WP_Block_Processor( '' ); - - $this->assertFalse( - $processor->next_delimiter(), - "Should have found no delimiter but found a '{$processor->get_block_type()}' instead." - ); - - $this->assertNull( - $processor->get_last_error(), - 'Should have completed without reporting an error.' - ); - } - /** * Data provider. * * @return array */ - public static function data_delimiters_and_comment_endings(): array { + public static function data_delimiter_does_not_span_a_comment_ending(): array { return array( // The comment ended at `--!>`, so the later `-->` is not the delimiter's end. 'Spans an exclamation ending' => array( '', array() ), @@ -674,6 +653,27 @@ public static function data_delimiters_and_comment_endings(): array { ); } + /** + * Verifies that a comment ended by `--!>` at the end of the document is not + * reported as incomplete input: the comment is closed, so no delimiter could + * be completed by further input. + * + * @ticket 66138 + */ + public function test_exclamation_ending_at_end_of_document_is_not_incomplete_input(): void { + $processor = new WP_Block_Processor( '' ); + + $this->assertFalse( + $processor->next_delimiter(), + "Should have found no delimiter but found a '{$processor->get_block_type()}' instead." + ); + + $this->assertNull( + $processor->get_last_error(), + 'Should have completed without reporting an error.' + ); + } + /** * Verifies that a comment whose JSON attributes are rejected is skipped whole. * @@ -684,7 +684,7 @@ public static function data_delimiters_and_comment_endings(): array { * * @ticket 66138 * - * @dataProvider data_comments_with_rejected_json_attributes + * @dataProvider data_skips_the_whole_comment_when_the_json_attributes_are_rejected * * @param string $html Document to scan. * @param string[] $block_types Printable block type of every delimiter in the document, in order. @@ -709,7 +709,7 @@ public function test_skips_the_whole_comment_when_the_json_attributes_are_reject * * @return array */ - public static function data_comments_with_rejected_json_attributes(): array { + public static function data_skips_the_whole_comment_when_the_json_attributes_are_rejected(): array { return array( // A `', array() ), @@ -1553,7 +1553,7 @@ public function test_scans_directly_to_requested_block_type( string $html, strin * * @ticket 64537 * - * @dataProvider data_various_block_posts + * @dataProvider data_extracts_equivalent_parses_as_parse_blocks * * @param string $test_document An HTML document to parse as blocks. */ @@ -1572,81 +1572,12 @@ public function test_extracts_equivalent_parses_as_parse_blocks( string $test_do ); } - /** - * Ensures that block extraction stops on the closing delimiter of a block with inner - * content, on freeform HTML, or on the token following a void block. - * - * @ticket 66138 - * - * @dataProvider data_extraction_stop_tokens - * - * @param string $test_document An HTML document containing blocks. - * @param string $block_type Block type at which to start extraction. - * @param string|null $stop_token Token on which extraction should stop, or null if - * extraction should reach the end of the document. - */ - public function test_extraction_stops_on_expected_token( string $test_document, string $block_type, ?string $stop_token ): void { - $processor = new WP_Block_Processor( $test_document ); - $this->assertTrue( - $processor->next_block( $block_type ), - "Failed to find a block of type '{$block_type}'." - ); - - $processor->extract_full_block_and_advance(); - $span = $processor->get_span(); - - $this->assertSame( - $stop_token, - isset( $span ) ? substr( $test_document, $span->start, $span->length ) : null, - 'Stopped on the wrong token after extracting a block.' - ); - } - - /** - * Ensures that inner HTML at the end of incomplete input appears only in the block containing it. - * - * @ticket 66138 - */ - public function test_extraction_does_not_copy_incomplete_inner_html_into_parent_block(): void { - $processor = new WP_Block_Processor( 'y<' ); - $this->assertTrue( $processor->next_block( 'g' ), "Failed to find a block of type 'g'." ); - $group = $processor->extract_full_block_and_advance(); - $this->assertIsArray( $group ); - $this->assertGreaterThan( 0, count( $group['innerBlocks'] ) ); - $this->assertIsArray( $group['innerBlocks'][0] ); - - $this->assertSame( array( null ), $group['innerContent'], 'Copied inner HTML into the parent block.' ); - $this->assertSame( array( 'y' ), $group['innerBlocks'][0]['innerContent'], 'Failed to extract inner HTML of the inner block.' ); - $this->assertSame( WP_Block_Processor::INCOMPLETE_INPUT, $processor->get_last_error(), 'Failed to report incomplete input.' ); - $this->assertSame( 'y', $processor->get_html_content(), 'Stopped on the wrong token after extracting a block from incomplete input.' ); - } - - /** - * Data provider for {@see self::test_extraction_stops_on_expected_token()}. - * - * @return array - */ - public static function data_extraction_stop_tokens(): array { - return array( - 'Block with inner content' => array( 'xy', 'a', '' ), - 'Block ending in void inner block' => array( 'x', 'g', '' ), - 'Void block' => array( '', 'a', '' ), - 'Void block before freeform HTML' => array( 'x', 'a', '' ), - 'Void block at end of document' => array( '', 'a', '' ), - 'Inner void block' => array( '', 'v', '' ), - 'Freeform HTML' => array( 'x', 'freeform', 'x' ), - 'Unclosed block' => array( 'x', 'a', null ), - 'Unclosed block ending in void inner block' => array( '', 'g', null ), - 'Incomplete input after void inner block' => array( 'x<', 'g', 'x' ), - ); - } - /** * Data provider. * * @return Generator */ - public static function data_various_block_posts() { + public static function data_extracts_equivalent_parses_as_parse_blocks() { yield 'Empty post' => array( '' ); yield 'Void block' => array( '' ); @@ -1744,6 +1675,75 @@ public static function data_various_block_posts() { ); } + /** + * Ensures that block extraction stops on the closing delimiter of a block with inner + * content, on freeform HTML, or on the token following a void block. + * + * @ticket 66138 + * + * @dataProvider data_extraction_stops_on_expected_token + * + * @param string $test_document An HTML document containing blocks. + * @param string $block_type Block type at which to start extraction. + * @param string|null $stop_token Token on which extraction should stop, or null if + * extraction should reach the end of the document. + */ + public function test_extraction_stops_on_expected_token( string $test_document, string $block_type, ?string $stop_token ): void { + $processor = new WP_Block_Processor( $test_document ); + $this->assertTrue( + $processor->next_block( $block_type ), + "Failed to find a block of type '{$block_type}'." + ); + + $processor->extract_full_block_and_advance(); + $span = $processor->get_span(); + + $this->assertSame( + $stop_token, + isset( $span ) ? substr( $test_document, $span->start, $span->length ) : null, + 'Stopped on the wrong token after extracting a block.' + ); + } + + /** + * Data provider for {@see self::test_extraction_stops_on_expected_token()}. + * + * @return array + */ + public static function data_extraction_stops_on_expected_token(): array { + return array( + 'Block with inner content' => array( 'xy', 'a', '' ), + 'Block ending in void inner block' => array( 'x', 'g', '' ), + 'Void block' => array( '', 'a', '' ), + 'Void block before freeform HTML' => array( 'x', 'a', '' ), + 'Void block at end of document' => array( '', 'a', '' ), + 'Inner void block' => array( '', 'v', '' ), + 'Freeform HTML' => array( 'x', 'freeform', 'x' ), + 'Unclosed block' => array( 'x', 'a', null ), + 'Unclosed block ending in void inner block' => array( '', 'g', null ), + 'Incomplete input after void inner block' => array( 'x<', 'g', 'x' ), + ); + } + + /** + * Ensures that inner HTML at the end of incomplete input appears only in the block containing it. + * + * @ticket 66138 + */ + public function test_extraction_does_not_copy_incomplete_inner_html_into_parent_block(): void { + $processor = new WP_Block_Processor( 'y<' ); + $this->assertTrue( $processor->next_block( 'g' ), "Failed to find a block of type 'g'." ); + $group = $processor->extract_full_block_and_advance(); + $this->assertIsArray( $group ); + $this->assertGreaterThan( 0, count( $group['innerBlocks'] ) ); + $this->assertIsArray( $group['innerBlocks'][0] ); + + $this->assertSame( array( null ), $group['innerContent'], 'Copied inner HTML into the parent block.' ); + $this->assertSame( array( 'y' ), $group['innerBlocks'][0]['innerContent'], 'Failed to extract inner HTML of the inner block.' ); + $this->assertSame( WP_Block_Processor::INCOMPLETE_INPUT, $processor->get_last_error(), 'Failed to report incomplete input.' ); + $this->assertSame( 'y', $processor->get_html_content(), 'Stopped on the wrong token after extracting a block from incomplete input.' ); + } + /** * Data provider. * diff --git a/tests/phpunit/tests/block-supports/layout.php b/tests/phpunit/tests/block-supports/layout.php index c1c121c9e2102..250568633e4ad 100644 --- a/tests/phpunit/tests/block-supports/layout.php +++ b/tests/phpunit/tests/block-supports/layout.php @@ -99,7 +99,7 @@ public function filter_set_theme_root() { * @ticket 66263 * @ticket 66427 * - * @dataProvider data_sanitize_block_gap_value + * @dataProvider data_sanitize_block_gap_value_normalizes_zero_and_rejects_other_non_string_values * * @covers ::wp_sanitize_block_gap_value */ @@ -112,7 +112,7 @@ public function test_sanitize_block_gap_value_normalizes_zero_and_rejects_other_ * * @return array[] Test data. */ - public static function data_sanitize_block_gap_value() { + public static function data_sanitize_block_gap_value_normalizes_zero_and_rejects_other_non_string_values() { return array( 'string value' => array( '1rem', '1rem' ), 'empty string' => array( '', null ), diff --git a/tests/phpunit/tests/block-supports/states.php b/tests/phpunit/tests/block-supports/states.php index eacd5d7c893d1..96d8947bdc6ad 100644 --- a/tests/phpunit/tests/block-supports/states.php +++ b/tests/phpunit/tests/block-supports/states.php @@ -183,7 +183,7 @@ public function test_text_clip_escape_unsets_the_background_image_when_a_state_e * @covers ::wp_get_state_text_fill_reset * @covers ::wp_state_paints_own_background * - * @dataProvider data_state_styles_that_paint_their_own_background + * @dataProvider data_text_clip_helpers_add_nothing_when_the_state_paints_its_own_background * * @param array $state_style State style object. */ @@ -197,7 +197,7 @@ public function test_text_clip_helpers_add_nothing_when_the_state_paints_its_own * * @return array[] */ - public static function data_state_styles_that_paint_their_own_background() { + public static function data_text_clip_helpers_add_nothing_when_the_state_paints_its_own_background() { $color = array( 'text' => '#ff0000' ); return array( @@ -240,7 +240,7 @@ public static function data_state_styles_that_paint_their_own_background() { * @ticket 66094 * @covers ::wp_get_state_text_clip_escape * - * @dataProvider data_base_clips_that_are_not_text + * @dataProvider data_text_clip_escape_adds_nothing_without_a_base_text_clip * * @param string $base_clip Background clip the state layers over. */ @@ -258,7 +258,7 @@ public function test_text_clip_escape_adds_nothing_without_a_base_text_clip( $ba * * @return array[] */ - public static function data_base_clips_that_are_not_text() { + public static function data_text_clip_escape_adds_nothing_without_a_base_text_clip() { return array( 'no base clip' => array( '' ), 'border-box' => array( 'border-box' ), @@ -272,7 +272,7 @@ public static function data_base_clips_that_are_not_text() { * @covers ::wp_get_state_text_clip_escape * @covers ::wp_get_state_text_fill_reset * - * @dataProvider data_empty_state_clips + * @dataProvider data_text_clip_helpers_treat_an_empty_state_clip_as_no_clip * * @param mixed $state_clip Background clip set by the state. */ @@ -295,7 +295,7 @@ public function test_text_clip_helpers_treat_an_empty_state_clip_as_no_clip( $st * * @return array[] */ - public static function data_empty_state_clips() { + public static function data_text_clip_helpers_treat_an_empty_state_clip_as_no_clip() { return array( 'false' => array( false ), 'zero' => array( 0 ), diff --git a/tests/phpunit/tests/blocks/wpBlockParser.php b/tests/phpunit/tests/blocks/wpBlockParser.php index be74610f0df2a..94c0c99a28b0f 100644 --- a/tests/phpunit/tests/blocks/wpBlockParser.php +++ b/tests/phpunit/tests/blocks/wpBlockParser.php @@ -49,7 +49,7 @@ public function test_parses_basic_empty_block() { * * @covers ::parse * - * @dataProvider data_non_string_documents + * @dataProvider data_returns_empty_array_for_non_string_document * * @expectedIncorrectUsage WP_Block_Parser::parse * @@ -66,7 +66,7 @@ public function test_returns_empty_array_for_non_string_document( $document ) { * * @return array[] */ - public static function data_non_string_documents() { + public static function data_returns_empty_array_for_non_string_document() { return array( 'null' => array( null ), 'false' => array( false ), @@ -109,7 +109,7 @@ public function __toString() { * * @ticket 66138 * - * @dataProvider data_documents_with_implicit_closings + * @dataProvider data_implicitly_closed_blocks_is_equivalent_to_explicitly_closed * * @param string[] $tokens List of block and HTML tokens comprising a document, where the first * is a partial document ending in open blocks, while the rest are the @@ -136,7 +136,7 @@ public function test_implicitly_closed_blocks_is_equivalent_to_explicitly_closed * * @return array> */ - public static function data_documents_with_implicit_closings() { + public static function data_implicitly_closed_blocks_is_equivalent_to_explicitly_closed() { return array( 'After a closed block' => array( array( diff --git a/tests/phpunit/tests/bookmark/sanitizeBookmarkField.php b/tests/phpunit/tests/bookmark/sanitizeBookmarkField.php index bab551aa34a68..890bc379bdd7c 100644 --- a/tests/phpunit/tests/bookmark/sanitizeBookmarkField.php +++ b/tests/phpunit/tests/bookmark/sanitizeBookmarkField.php @@ -87,7 +87,7 @@ public static function data_casts_integer_fields() { * * @covers ::sanitize_bookmark_field * - * @dataProvider data_link_category_values + * @dataProvider data_link_category_is_array_of_integers * * @param mixed $value Field value. * @param string $context Sanitization context. @@ -105,7 +105,7 @@ public function test_link_category_is_array_of_integers( $value, $context, $expe * * @return array[] */ - public static function data_link_category_values() { + public static function data_link_category_is_array_of_integers() { return array( 'array of mixed values, display' => array( array( '1', '-2', 'abc', 3 ), 'display', array( 1, 2, 0, 3 ) ), 'single value, edit' => array( '5', 'edit', array( 5 ) ), @@ -120,7 +120,7 @@ public static function data_link_category_values() { * * @covers ::sanitize_bookmark_field * - * @dataProvider data_link_visible_values + * @dataProvider data_link_visible_keeps_only_y_and_n * * @param string $value Field value. * @param string $expected Expected value. @@ -134,7 +134,7 @@ public function test_link_visible_keeps_only_y_and_n( $value, $expected ) { * * @return array[] */ - public static function data_link_visible_values() { + public static function data_link_visible_keeps_only_y_and_n() { return array( 'uppercase Y' => array( 'Y', 'Y' ), 'lowercase n' => array( 'n', 'n' ), @@ -151,7 +151,7 @@ public static function data_link_visible_values() { * * @covers ::sanitize_bookmark_field * - * @dataProvider data_link_target_values + * @dataProvider data_link_target_only_accepts_known_targets * * @param string $value Field value. * @param string $expected Expected value. @@ -165,7 +165,7 @@ public function test_link_target_only_accepts_known_targets( $value, $expected ) * * @return array[] */ - public static function data_link_target_values() { + public static function data_link_target_only_accepts_known_targets() { return array( '_blank' => array( '_blank', '_blank' ), '_top' => array( '_top', '_top' ), diff --git a/tests/phpunit/tests/category/catIsAncestorOf.php b/tests/phpunit/tests/category/catIsAncestorOf.php index f438f4afc0fa9..2d14668acef0d 100644 --- a/tests/phpunit/tests/category/catIsAncestorOf.php +++ b/tests/phpunit/tests/category/catIsAncestorOf.php @@ -137,7 +137,7 @@ public function test_returns_false_for_same_category() { * * @ticket 65819 * - * @dataProvider data_category_parameter_types + * @dataProvider data_accepts_category_objects_and_ids * * @param string $parent_type Parameter type for parent category. * @param string $child_type Parameter type for child category. @@ -154,7 +154,7 @@ public function test_accepts_category_objects_and_ids( $parent_type, $child_type * * @return array[] */ - public static function data_category_parameter_types() { + public static function data_accepts_category_objects_and_ids() { return array( 'both WP_Term objects' => array( 'object', 'object' ), 'parent ID and child WP_Term object' => array( 'id', 'object' ), diff --git a/tests/phpunit/tests/category/getCategory.php b/tests/phpunit/tests/category/getCategory.php index 84928446314ba..e97a3357285fa 100644 --- a/tests/phpunit/tests/category/getCategory.php +++ b/tests/phpunit/tests/category/getCategory.php @@ -139,7 +139,7 @@ static function ( $name ) { * * @ticket 65819 * - * @dataProvider data_empty_category_values + * @dataProvider data_returns_wp_error_for_empty_category * * @param mixed $empty_value Empty category input. */ @@ -155,7 +155,7 @@ public function test_returns_wp_error_for_empty_category( $empty_value ) { * * @return array[] */ - public static function data_empty_category_values() { + public static function data_returns_wp_error_for_empty_category() { return array( 'empty string' => array( '' ), 'zero int' => array( 0 ), diff --git a/tests/phpunit/tests/category/getTags.php b/tests/phpunit/tests/category/getTags.php index 800ff220d0628..1c13f78485dea 100644 --- a/tests/phpunit/tests/category/getTags.php +++ b/tests/phpunit/tests/category/getTags.php @@ -116,7 +116,7 @@ public function test_returns_empty_array_when_no_tags_found() { * * @ticket 65819 * - * @dataProvider data_fields_argument + * @dataProvider data_supports_fields_argument * * @param string $fields Fields argument value. */ @@ -146,7 +146,7 @@ public function test_supports_fields_argument( $fields ) { * * @return array[] */ - public static function data_fields_argument() { + public static function data_supports_fields_argument() { return array( 'ids' => array( 'ids' ), 'names' => array( 'names' ), diff --git a/tests/phpunit/tests/category/getTheCategoryList.php b/tests/phpunit/tests/category/getTheCategoryList.php index 8537cb149ad46..0df6f93cb77d3 100644 --- a/tests/phpunit/tests/category/getTheCategoryList.php +++ b/tests/phpunit/tests/category/getTheCategoryList.php @@ -87,7 +87,7 @@ private function category_link( $category_id ) { * * @ticket 65819 * - * @dataProvider data_parents_in_list + * @dataProvider data_builds_unordered_list_without_separator * * @param string $parents How to display the category parents. * @param string $expected Expected list, with %child%, %parent% and %other% placeholders for the links. @@ -107,7 +107,7 @@ public function test_builds_unordered_list_without_separator( $parents, $expecte * * @return array[] */ - public static function data_parents_in_list() { + public static function data_builds_unordered_list_without_separator() { return array( 'without parents' => array( '', @@ -152,7 +152,7 @@ public static function data_parents_in_list() { * * @ticket 65819 * - * @dataProvider data_parents_with_separator + * @dataProvider data_joins_links_with_separator * * @param string $parents How to display the category parents. * @param string $expected Expected list, with %child%, %parent% and %other% placeholders for the links. @@ -172,7 +172,7 @@ public function test_joins_links_with_separator( $parents, $expected ) { * * @return array[] */ - public static function data_parents_with_separator() { + public static function data_joins_links_with_separator() { return array( 'without parents' => array( '', diff --git a/tests/phpunit/tests/category/inCategory.php b/tests/phpunit/tests/category/inCategory.php index c14628170569b..064ca183fd8ed 100644 --- a/tests/phpunit/tests/category/inCategory.php +++ b/tests/phpunit/tests/category/inCategory.php @@ -61,7 +61,7 @@ public function test_returns_true_when_post_is_in_matching_category() { * @ticket 25706 * @ticket 65819 * - * @dataProvider data_empty_categories + * @dataProvider data_returns_false_when_category_is_empty * * @param mixed $empty_category Empty category value. */ @@ -74,7 +74,7 @@ public function test_returns_false_when_category_is_empty( $empty_category ) { * * @return array[] */ - public static function data_empty_categories() { + public static function data_returns_false_when_category_is_empty() { return array( 'empty string' => array( '' ), 'zero int' => array( 0 ), diff --git a/tests/phpunit/tests/category/sanitizeCategoryField.php b/tests/phpunit/tests/category/sanitizeCategoryField.php index de4e53244bd9b..3cc7b8d9f4fd9 100644 --- a/tests/phpunit/tests/category/sanitizeCategoryField.php +++ b/tests/phpunit/tests/category/sanitizeCategoryField.php @@ -104,7 +104,7 @@ public static function data_casts_integer_fields() { * * @ticket 65819 * - * @dataProvider data_raw_contexts + * @dataProvider data_raw_context_returns_value_unfiltered * * @param string $context Raw context variation. */ @@ -120,7 +120,7 @@ public function test_raw_context_returns_value_unfiltered( $context ) { * * @return array[] */ - public static function data_raw_contexts() { + public static function data_raw_context_returns_value_unfiltered() { return array( 'lowercase raw' => array( 'raw' ), 'uppercase RAW' => array( 'RAW' ), diff --git a/tests/phpunit/tests/category/walkerCategoryDropdown.php b/tests/phpunit/tests/category/walkerCategoryDropdown.php index 4ced237bf26df..d8d500bcdaee8 100644 --- a/tests/phpunit/tests/category/walkerCategoryDropdown.php +++ b/tests/phpunit/tests/category/walkerCategoryDropdown.php @@ -151,7 +151,7 @@ public static function data_start_el() { * * @covers ::start_el * - * @dataProvider data_start_el_with_zero_slug + * @dataProvider data_start_el_compares_zero_slug_as_string * * @param mixed $selected Selected value. * @param string $expected Expected option element, without the leading tab and trailing newline. @@ -184,7 +184,7 @@ public function test_start_el_compares_zero_slug_as_string( $selected, $expected * * @return array[] */ - public static function data_start_el_with_zero_slug() { + public static function data_start_el_compares_zero_slug_as_string() { return array( 'selected value is false' => array( false, '' ), 'selected value is \'0\'' => array( '0', '' ), diff --git a/tests/phpunit/tests/comment/getCommentType.php b/tests/phpunit/tests/comment/getCommentType.php index 22d65f579e9f4..beabc55ef7e0c 100644 --- a/tests/phpunit/tests/comment/getCommentType.php +++ b/tests/phpunit/tests/comment/getCommentType.php @@ -71,7 +71,7 @@ static function () { * @covers ::comment_type * @covers ::get_comment_type * - * @dataProvider data_default_labels + * @dataProvider data_comment_type_echoes_default_labels * * @param string $comment_type Comment type fixture. * @param string $expected Expected echoed label. @@ -95,7 +95,7 @@ public function test_comment_type_echoes_default_labels( $comment_type, $expecte * * @return array[] */ - public static function data_default_labels() { + public static function data_comment_type_echoes_default_labels() { return array( 'comment' => array( 'comment', 'Comment' ), 'pingback' => array( 'pingback', 'Pingback' ), @@ -109,7 +109,7 @@ public static function data_default_labels() { * @covers ::comment_type * @covers ::get_comment_type * - * @dataProvider data_custom_labels + * @dataProvider data_comment_type_echoes_custom_labels * * @param string $comment_type Comment type fixture. * @param string $expected Expected echoed label. @@ -133,7 +133,7 @@ public function test_comment_type_echoes_custom_labels( $comment_type, $expected * * @return array[] */ - public static function data_custom_labels() { + public static function data_comment_type_echoes_custom_labels() { return array( 'comment' => array( 'comment', 'Custom Comment' ), 'pingback' => array( 'pingback', 'Custom Pingback' ), diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 77f60a6f4c124..6481d1607dd9d 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -4509,7 +4509,7 @@ public function test_hierarchy_should_be_filled_when_cache_is_incomplete() { * * @covers WP_Comment_Query::fill_descendants * - * @dataProvider data_hierarchical_modes + * @dataProvider data_fill_descendants_should_skip_cached_child_ids_that_no_longer_exist * * @param 'threaded'|'flat' $hierarchical Value of the 'hierarchical' query var. * @@ -4557,7 +4557,7 @@ public function test_fill_descendants_should_skip_cached_child_ids_that_no_longe * * @return array */ - public static function data_hierarchical_modes(): array { + public static function data_fill_descendants_should_skip_cached_child_ids_that_no_longer_exist(): array { return array( 'threaded' => array( 'threaded' ), 'flat' => array( 'flat' ), diff --git a/tests/phpunit/tests/comment/wpGetUnapprovedCommentAuthorEmail.php b/tests/phpunit/tests/comment/wpGetUnapprovedCommentAuthorEmail.php index 7af4196fa056d..5c6a4e109459a 100644 --- a/tests/phpunit/tests/comment/wpGetUnapprovedCommentAuthorEmail.php +++ b/tests/phpunit/tests/comment/wpGetUnapprovedCommentAuthorEmail.php @@ -117,7 +117,7 @@ public function test_returns_comment_author_email_for_valid_hash() { * * @ticket 65819 * - * @dataProvider data_invalid_moderation_query_args + * @dataProvider data_falls_back_to_commenter_cookie * * @param string $scenario Which part of the query arguments is invalid. */ @@ -153,7 +153,7 @@ public function test_falls_back_to_commenter_cookie( $scenario ) { * * @return array */ - public static function data_invalid_moderation_query_args() { + public static function data_falls_back_to_commenter_cookie() { return array( 'wrong hash' => array( 'wrong hash' ), 'missing hash' => array( 'missing hash' ), diff --git a/tests/phpunit/tests/connectors/wpConnectorsRestSettingsDispatch.php b/tests/phpunit/tests/connectors/wpConnectorsRestSettingsDispatch.php index 210c0954b3a7d..f14ae3cb0a0f7 100644 --- a/tests/phpunit/tests/connectors/wpConnectorsRestSettingsDispatch.php +++ b/tests/phpunit/tests/connectors/wpConnectorsRestSettingsDispatch.php @@ -215,7 +215,7 @@ public function test_keeps_and_masks_submitted_valid_ai_key(): void { * * @ticket 66330 * - * @dataProvider data_settings_route_spellings + * @dataProvider data_masks_credentials_for_every_settings_route_spelling * * @param string $route Requested settings route. */ @@ -246,13 +246,28 @@ public function test_masks_credentials_for_every_settings_route_spelling( string ); } + /** + * Data provider for spellings of the settings route that the REST server + * dispatches to the settings controller. + * + * @return array Test cases. + */ + public static function data_masks_credentials_for_every_settings_route_spelling(): array { + return array( + 'lowercase' => array( '/wp/v2/settings' ), + 'mixed case' => array( '/wp/v2/Settings' ), + 'uppercase' => array( '/WP/V2/SETTINGS' ), + 'trailing newline' => array( "/wp/v2/settings\n" ), + ); + } + /** * Ensures settings endpoint responses mask credentials for every `rest_route` * query variable value that the REST server dispatches to the settings controller. * * @ticket 66330 * - * @dataProvider data_settings_rest_route_query_values + * @dataProvider data_settings_endpoint_masks_credentials_for_every_rest_route_spelling * * @param string $rest_route Raw `rest_route` query variable value. */ @@ -293,28 +308,13 @@ public function test_settings_endpoint_masks_credentials_for_every_rest_route_sp ); } - /** - * Data provider for spellings of the settings route that the REST server - * dispatches to the settings controller. - * - * @return array Test cases. - */ - public static function data_settings_route_spellings(): array { - return array( - 'lowercase' => array( '/wp/v2/settings' ), - 'mixed case' => array( '/wp/v2/Settings' ), - 'uppercase' => array( '/WP/V2/SETTINGS' ), - 'trailing newline' => array( "/wp/v2/settings\n" ), - ); - } - /** * Data provider for raw `rest_route` query variable values that the REST * server dispatches to the settings controller. * * @return array Test cases. */ - public static function data_settings_rest_route_query_values(): array { + public static function data_settings_endpoint_masks_credentials_for_every_rest_route_spelling(): array { return array( 'lowercase' => array( '/wp/v2/settings' ), 'mixed case' => array( '/wp/v2/Settings' ), diff --git a/tests/phpunit/tests/date/getFeedBuildDate.php b/tests/phpunit/tests/date/getFeedBuildDate.php index e5530af9783db..98185a24833ee 100644 --- a/tests/phpunit/tests/date/getFeedBuildDate.php +++ b/tests/phpunit/tests/date/getFeedBuildDate.php @@ -135,7 +135,7 @@ public function test_should_return_correct_build_date_for_id_only_query() { * Cold ID-only and partial results must retain the feed's latest date. * * @ticket 59956 - * @dataProvider data_cold_post_query_fields + * @dataProvider data_should_return_correct_build_date_for_cold_query_fields * * @param non-falsy-string $fields Fields arg. */ @@ -178,7 +178,7 @@ public function test_should_return_correct_build_date_for_cold_query_fields( str * * @return array */ - public static function data_cold_post_query_fields(): array { + public static function data_should_return_correct_build_date_for_cold_query_fields(): array { return array( 'IDs' => array( 'ids' ), 'partial' => array( 'id=>parent' ), diff --git a/tests/phpunit/tests/date/getPostDatetime.php b/tests/phpunit/tests/date/getPostDatetime.php index d4f4ce171aa73..b9f6b32960e2f 100644 --- a/tests/phpunit/tests/date/getPostDatetime.php +++ b/tests/phpunit/tests/date/getPostDatetime.php @@ -157,7 +157,7 @@ public function test_get_post_datetime_returns_false_for_missing_post() { * * @covers ::get_post_datetime * - * @dataProvider data_get_post_datetime_invalid_times + * @dataProvider data_get_post_datetime_returns_false_for_invalid_time * * @param string $field Field to read, 'date' or 'modified'. * @param string $source Source to read, 'local' or 'gmt'. @@ -186,7 +186,7 @@ public function test_get_post_datetime_returns_false_for_invalid_time( $field, $ * * @return array[] */ - public static function data_get_post_datetime_invalid_times() { + public static function data_get_post_datetime_returns_false_for_invalid_time() { return array( 'empty published local time' => array( 'date', 'local', '' ), 'zero published UTC time' => array( 'date', 'gmt', '0000-00-00 00:00:00' ), diff --git a/tests/phpunit/tests/dependencies/scripts.php b/tests/phpunit/tests/dependencies/scripts.php index 75e919355c76c..628c840ec27d9 100644 --- a/tests/phpunit/tests/dependencies/scripts.php +++ b/tests/phpunit/tests/dependencies/scripts.php @@ -223,7 +223,7 @@ public static function data_provider_delayed_strategies() { * Tests that inline scripts do not include a false entry when no data exists yet. * * @ticket 52320 - * @dataProvider data_inline_script_positions + * @dataProvider data_add_inline_script_does_not_store_false_for_empty_existing_data * * @param string $position Inline script position. */ @@ -244,7 +244,7 @@ public function test_add_inline_script_does_not_store_false_for_empty_existing_d * * @return array Inline script positions. */ - public static function data_inline_script_positions(): array { + public static function data_add_inline_script_does_not_store_false_for_empty_existing_data(): array { return array( 'before' => array( 'before' ), 'after' => array( 'after' ), diff --git a/tests/phpunit/tests/dependencies/wpPrefetchAdminAssets.php b/tests/phpunit/tests/dependencies/wpPrefetchAdminAssets.php index 1daabba5e8435..56126b22f3f44 100644 --- a/tests/phpunit/tests/dependencies/wpPrefetchAdminAssets.php +++ b/tests/phpunit/tests/dependencies/wpPrefetchAdminAssets.php @@ -122,7 +122,7 @@ public function test_login_prefetches_render_blocking_admin_assets(): void { * * @ticket 57548 * - * @dataProvider data_editor_destinations + * @dataProvider data_login_prefetches_editor_assets_for_editor_destination * * @param string $redirect_to Where the login redirects to. * @param bool $is_editor Whether that is the block editor. @@ -146,7 +146,7 @@ public function test_login_prefetches_editor_assets_for_editor_destination( stri * * @return array */ - public static function data_editor_destinations(): array { + public static function data_login_prefetches_editor_assets_for_editor_destination(): array { return array( 'Dashboard' => array( '/wp-admin/', false ), 'Dashboard, no trailing slash' => array( '/wp-admin', false ), @@ -182,7 +182,7 @@ public function test_login_prefetches_editor_assets_for_absolute_editor_url(): v * * @ticket 57548 * - * @dataProvider data_editor_destinations_by_post_type + * @dataProvider data_login_checks_block_editor_for_post_type * * @param non-falsy-string $redirect_to Where the login redirects to. * @param bool $is_editor Whether that is expected to be the block editor. @@ -213,7 +213,7 @@ static function ( bool $use_block_editor, string $post_type ): bool { * * @return array */ - public static function data_editor_destinations_by_post_type(): array { + public static function data_login_checks_block_editor_for_post_type(): array { return array( 'new post' => array( '/wp-admin/post-new.php', true ), 'new page' => array( '/wp-admin/post-new.php?post_type=page', false ), @@ -246,7 +246,7 @@ public function test_login_prints_no_editor_assets_for_classic_editor(): void { * * @ticket 57548 * - * @dataProvider data_login_screens + * @dataProvider data_login_prefetches_on_every_login_screen * * @param array $request Request parameters of the login screen. */ @@ -261,7 +261,7 @@ public function test_login_prefetches_on_every_login_screen( array $request ): v * * @return array }> */ - public static function data_login_screens(): array { + public static function data_login_prefetches_on_every_login_screen(): array { return array( 'login form' => array( array() ), 'lost password' => array( array( 'action' => 'lostpassword' ) ), @@ -296,7 +296,7 @@ public static function data_login_screens(): array { * * @ticket 57548 * - * @dataProvider data_login_requests_not_leading_to_admin + * @dataProvider data_login_prints_nothing_when_not_leading_to_admin * * @param array $request Request parameters of the login screen. */ @@ -312,7 +312,7 @@ public function test_login_prints_nothing_when_not_leading_to_admin( array $requ * * @return array }> */ - public static function data_login_requests_not_leading_to_admin(): array { + public static function data_login_prints_nothing_when_not_leading_to_admin(): array { return array( 'front end redirect' => array( array( 'redirect_to' => '/hello-world/' ) ), 'lookalike admin path' => array( array( 'redirect_to' => '/wp-admin-lookalike/' ) ), @@ -480,7 +480,7 @@ public function test_login_prints_nothing_for_protocol_relative_admin_url_over_h * * @ticket 57548 * - * @dataProvider data_admin_screens_leading_to_editor + * @dataProvider data_admin_screen_prefetches_editor_assets * * @param string $screen Screen ID. * @param string $post_type Post type of the editor expected to be prefetched for. @@ -503,7 +503,7 @@ public function test_admin_screen_prefetches_editor_assets( string $screen, stri * * @return array */ - public static function data_admin_screens_leading_to_editor(): array { + public static function data_admin_screen_prefetches_editor_assets(): array { return array( 'Dashboard' => array( 'dashboard', 'post' ), 'Posts list' => array( 'edit', 'post' ), @@ -516,7 +516,7 @@ public static function data_admin_screens_leading_to_editor(): array { * * @ticket 57548 * - * @dataProvider data_other_admin_screens + * @dataProvider data_other_admin_screen_prints_nothing * * @param string $screen Screen ID. */ @@ -531,7 +531,7 @@ public function test_other_admin_screen_prints_nothing( string $screen ): void { * * @return array */ - public static function data_other_admin_screens(): array { + public static function data_other_admin_screen_prints_nothing(): array { return array( 'Plugins' => array( 'plugins' ), 'Network Admin Dashboard' => array( 'dashboard-network' ), @@ -930,7 +930,7 @@ static function (): array { * * @ticket 57548 * - * @dataProvider data_filter_turning_off + * @dataProvider data_filter_can_turn_off_prefetching * * @param mixed $filtered Value the filter returns. */ @@ -945,6 +945,18 @@ static function () use ( $filtered ) { $this->assertSame( '', $this->get_login_footer_output() ); } + /** + * Data provider for {@see self::test_filter_can_turn_off_prefetching()}. + * + * @return array + */ + public static function data_filter_can_turn_off_prefetching(): array { + return array( + 'empty array' => array( array() ), + 'not an array' => array( null ), + ); + } + /** * Tests that the script prefetching the links in browsers that lack `rel="prefetch"` is printed * once, after all of the prefetch links it reads from the page. @@ -974,18 +986,6 @@ public function test_prints_polyfill_after_prefetch_links(): void { $this->assertStringContainsString( '//# sourceURL=wp_prefetch_admin_assets', $scripts[0] ); } - /** - * Data provider for {@see self::test_filter_can_turn_off_prefetching()}. - * - * @return array - */ - public static function data_filter_turning_off(): array { - return array( - 'empty array' => array( array() ), - 'not an array' => array( null ), - ); - } - /** * Runs the login screen's prefetching and returns the links it printed. * diff --git a/tests/phpunit/tests/dependencies/wpStyles/getRtlSrc.php b/tests/phpunit/tests/dependencies/wpStyles/getRtlSrc.php index 3ca8cb530d19e..48ba06c496803 100644 --- a/tests/phpunit/tests/dependencies/wpStyles/getRtlSrc.php +++ b/tests/phpunit/tests/dependencies/wpStyles/getRtlSrc.php @@ -214,6 +214,18 @@ public function test_matches_printed_href( $rtl, int $expected ): void { $this->assertSame( $href, $this->styles->get_rtl_src( 'test' ) ); } + /** + * Data provider for {@see self::test_matches_printed_href()}. + * + * @return array + */ + public static function data_matches_printed_href(): array { + return array( + 'alongside' => array( true, 2 ), + 'replacing' => array( 'replace', 1 ), + ); + } + /** * Tests that printing a right-to-left stylesheet sanitizes its URL only once, so the * {@see 'clean_url'} filter runs once for it, as it did before get_rtl_src() was introduced. @@ -245,16 +257,4 @@ static function ( array $args ): array { ) ); } - - /** - * Data provider for {@see self::test_matches_printed_href()}. - * - * @return array - */ - public static function data_matches_printed_href(): array { - return array( - 'alongside' => array( true, 2 ), - 'replacing' => array( 'replace', 1 ), - ); - } } diff --git a/tests/phpunit/tests/entity-fields/wpRegisterCoreFieldCollections.php b/tests/phpunit/tests/entity-fields/wpRegisterCoreFieldCollections.php index 6f9f4ab660089..57a3bb09084c6 100644 --- a/tests/phpunit/tests/entity-fields/wpRegisterCoreFieldCollections.php +++ b/tests/phpunit/tests/entity-fields/wpRegisterCoreFieldCollections.php @@ -234,23 +234,6 @@ public function test_the_notes_field_follows_the_editor_support_argument() { $this->assertNotContains( 'notesCount', self::get_field_ids( 'test_note' ), 'The post type without notes does not get the field.' ); } - /** - * Data provider. - * - * @return array[] The id of each field and whether the design post types - * exclude it. - */ - public static function data_default_fields_of_every_post_type() { - return array( - 'date' => array( 'date', true ), - 'last_edited_date' => array( 'last_edited_date', false ), - 'password' => array( 'password', true ), - 'scheduled_date' => array( 'scheduled_date', true ), - 'status' => array( 'status', true ), - 'template' => array( 'template', true ), - ); - } - /** * A default field of every post type is registered on a post type * supporting nothing, and on the design post types unless they exclude @@ -258,7 +241,7 @@ public static function data_default_fields_of_every_post_type() { * * @ticket 66229 * - * @dataProvider data_default_fields_of_every_post_type + * @dataProvider data_a_default_field_of_every_post_type * * @param string $field_id The id of the field. * @param bool $excluded_for_design Whether the design post types exclude it. @@ -280,16 +263,17 @@ public function test_a_default_field_of_every_post_type( $field_id, $excluded_fo /** * Data provider. * - * @return array[] The id of each field and the supports that give it. + * @return array[] The id of each field and whether the design post types + * exclude it. */ - public static function data_default_fields_and_their_supports() { + public static function data_a_default_field_of_every_post_type() { return array( - 'discussion' => array( 'discussion', array( 'comments', 'trackbacks' ) ), - 'excerpt' => array( 'excerpt', array( 'excerpt' ) ), - 'parent' => array( 'parent', array( 'page-attributes' ) ), - 'ping_status' => array( 'ping_status', array( 'trackbacks' ) ), - 'title' => array( 'title', array( 'title' ) ), - 'post-content-info' => array( 'post-content-info', array( 'editor' ) ), + 'date' => array( 'date', true ), + 'last_edited_date' => array( 'last_edited_date', false ), + 'password' => array( 'password', true ), + 'scheduled_date' => array( 'scheduled_date', true ), + 'status' => array( 'status', true ), + 'template' => array( 'template', true ), ); } @@ -299,7 +283,7 @@ public static function data_default_fields_and_their_supports() { * * @ticket 66229 * - * @dataProvider data_default_fields_and_their_supports + * @dataProvider data_a_default_field_follows_its_supports * * @param string $field_id The id of the field. * @param string[] $supports The supports that give the field. @@ -318,6 +302,22 @@ public function test_a_default_field_follows_its_supports( $field_id, $supports $this->assertNotContains( $field_id, self::get_field_ids( 'test_without' ), 'A post type without the supports does not get the field.' ); } + /** + * Data provider. + * + * @return array[] The id of each field and the supports that give it. + */ + public static function data_a_default_field_follows_its_supports() { + return array( + 'discussion' => array( 'discussion', array( 'comments', 'trackbacks' ) ), + 'excerpt' => array( 'excerpt', array( 'excerpt' ) ), + 'parent' => array( 'parent', array( 'page-attributes' ) ), + 'ping_status' => array( 'ping_status', array( 'trackbacks' ) ), + 'title' => array( 'title', array( 'title' ) ), + 'post-content-info' => array( 'post-content-info', array( 'editor' ) ), + ); + } + /** * The default fields come from the `field.php` files of the * `post_type_supports` folder. diff --git a/tests/phpunit/tests/error-protection/functions.php b/tests/phpunit/tests/error-protection/functions.php index ac9fa2a86f008..62d8f4f10a066 100644 --- a/tests/phpunit/tests/error-protection/functions.php +++ b/tests/phpunit/tests/error-protection/functions.php @@ -203,7 +203,7 @@ public function test_wp_is_fatal_error_handler_enabled_can_be_disabled_by_filter * * @covers ::wp_is_fatal_error_handler_enabled * - * @dataProvider data_disable_fatal_error_handler_constant + * @dataProvider data_wp_is_fatal_error_handler_enabled_respects_constant * * @runInSeparateProcess * @preserveGlobalState disabled @@ -226,7 +226,7 @@ public function test_wp_is_fatal_error_handler_enabled_respects_constant( $const * * @return array[] */ - public static function data_disable_fatal_error_handler_constant() { + public static function data_wp_is_fatal_error_handler_enabled_respects_constant() { return array( 'constant is true' => array( true, false ), 'constant is false' => array( false, true ), diff --git a/tests/phpunit/tests/error-protection/wpFatalErrorHandler.php b/tests/phpunit/tests/error-protection/wpFatalErrorHandler.php index e379ca5677acb..397a4293aab9c 100644 --- a/tests/phpunit/tests/error-protection/wpFatalErrorHandler.php +++ b/tests/phpunit/tests/error-protection/wpFatalErrorHandler.php @@ -204,7 +204,7 @@ public static function data_should_handle_error() { * * @covers ::should_handle_error * - * @dataProvider data_should_handle_error_filter_values + * @dataProvider data_should_handle_error_uses_filter_for_other_error_types * * @param mixed $filtered Value returned by the filter. * @param bool $expected Whether the error should be handled. @@ -234,7 +234,7 @@ static function () use ( $filtered ) { * * @return array[] */ - public static function data_should_handle_error_filter_values() { + public static function data_should_handle_error_uses_filter_for_other_error_types() { return array( 'true' => array( true, true ), 'false' => array( false, false ), @@ -475,7 +475,7 @@ public function test_handle_does_nothing_while_sandbox_scraping() { * * @covers ::display_default_error_template * - * @dataProvider data_default_error_template_messages + * @dataProvider data_display_default_error_template_message * * @param bool $is_admin Whether the request is for an admin page. * @param bool $is_initialized Whether recovery mode is initialized. @@ -520,7 +520,7 @@ public function test_display_default_error_template_message( $is_admin, $is_init * * @return array[] */ - public static function data_default_error_template_messages() { + public static function data_display_default_error_template_message() { $generic = 'There has been a critical error on this website.'; $recovery = 'There has been a critical error on this website, putting it in recovery mode. Please check the Themes and Plugins screens for more details. If you just installed or updated a theme or plugin, check the relevant page for that first.'; diff --git a/tests/phpunit/tests/error-protection/wpRecoveryMode.php b/tests/phpunit/tests/error-protection/wpRecoveryMode.php index 4a9392e687719..d564b75bdd42b 100644 --- a/tests/phpunit/tests/error-protection/wpRecoveryMode.php +++ b/tests/phpunit/tests/error-protection/wpRecoveryMode.php @@ -329,7 +329,7 @@ public function test_initialize_dies_on_invalid_cookie() { * @covers ::handle_error * @covers ::get_extension_for_error * - * @dataProvider data_errors_without_extension + * @dataProvider data_handle_error_returns_invalid_source_without_extension * * @param array $error Error details. */ @@ -347,7 +347,7 @@ public function test_handle_error_returns_invalid_source_without_extension( $err * * @return array[] */ - public static function data_errors_without_extension() { + public static function data_handle_error_returns_invalid_source_without_extension() { return array( 'empty error' => array( array() ), 'missing file' => array( @@ -593,7 +593,7 @@ public function test_exit_recovery_mode_clears_session_data() { * * @covers ::handle_exit_recovery_mode * - * @dataProvider data_non_exit_actions + * @dataProvider data_handle_exit_recovery_mode_ignores_other_actions * * @param array $query Query arguments. */ @@ -617,7 +617,7 @@ public function test_handle_exit_recovery_mode_ignores_other_actions( $query ) { * * @return array[] */ - public static function data_non_exit_actions() { + public static function data_handle_exit_recovery_mode_ignores_other_actions() { return array( 'no action' => array( array() ), 'empty action' => array( array( 'action' => '' ) ), @@ -634,7 +634,7 @@ public static function data_non_exit_actions() { * * @covers ::handle_exit_recovery_mode * - * @dataProvider data_invalid_exit_nonces + * @dataProvider data_handle_exit_recovery_mode_dies_on_invalid_nonce * * @param array $query Query arguments. */ @@ -666,7 +666,7 @@ public function test_handle_exit_recovery_mode_dies_on_invalid_nonce( $query ) { * * @return array[] */ - public static function data_invalid_exit_nonces() { + public static function data_handle_exit_recovery_mode_dies_on_invalid_nonce() { return array( 'missing nonce' => array( array( 'action' => 'exit_recovery_mode' ) ), 'empty nonce' => array( diff --git a/tests/phpunit/tests/error-protection/wpRecoveryModeCookieService.php b/tests/phpunit/tests/error-protection/wpRecoveryModeCookieService.php index bc06f6facd61b..471c3011b4c01 100644 --- a/tests/phpunit/tests/error-protection/wpRecoveryModeCookieService.php +++ b/tests/phpunit/tests/error-protection/wpRecoveryModeCookieService.php @@ -256,7 +256,7 @@ public function test_validate_cookie_prefers_cookie_argument_over_request() { * * @covers WP_Recovery_Mode_Cookie_Service::validate_cookie * - * @dataProvider data_filtered_cookie_lengths + * @dataProvider data_validate_cookie_uses_filtered_cookie_length * * @param int $age Age of the cookie in seconds. * @param int $cookie_length Filtered cookie length in seconds. @@ -291,7 +291,7 @@ static function () use ( $cookie_length ) { * * @return array[] */ - public static function data_filtered_cookie_lengths() { + public static function data_validate_cookie_uses_filtered_cookie_length() { return array( 'shorter length expires a recent cookie' => array( 2 * HOUR_IN_SECONDS, HOUR_IN_SECONDS, 'expired' ), 'zero length expires any older cookie' => array( MINUTE_IN_SECONDS, 0, 'expired' ), @@ -350,7 +350,7 @@ public function test_get_session_id_from_cookie_returns_wp_error_if_no_cookie_is * * @covers WP_Recovery_Mode_Cookie_Service::get_session_id_from_cookie * - * @dataProvider data_cookies_with_invalid_format + * @dataProvider data_get_session_id_from_cookie_returns_wp_error_if_invalid_format * * @param string $cookie Cookie value. */ @@ -367,7 +367,7 @@ public function test_get_session_id_from_cookie_returns_wp_error_if_invalid_form * * @return array[] */ - public static function data_cookies_with_invalid_format() { + public static function data_get_session_id_from_cookie_returns_wp_error_if_invalid_format() { return array( 'not base64 encoded' => array( 'gibberish' ), 'too few parts' => array( base64_encode( 'recovery_mode|1234567890|abcdefghij0123456789' ) ), diff --git a/tests/phpunit/tests/error-protection/wpRecoveryModeNetworkPlugins.php b/tests/phpunit/tests/error-protection/wpRecoveryModeNetworkPlugins.php index 56bd451a90175..d88136968ecf7 100644 --- a/tests/phpunit/tests/error-protection/wpRecoveryModeNetworkPlugins.php +++ b/tests/phpunit/tests/error-protection/wpRecoveryModeNetworkPlugins.php @@ -16,7 +16,7 @@ class Tests_Error_Protection_wpRecoveryModeNetworkPlugins extends WP_UnitTestCas * * @ticket 66328 * - * @dataProvider data_network_activated_plugins + * @dataProvider data_handle_error_rejects_error_from_network_activated_plugin * * @param string $plugin Plugin basename to network-activate. * @param string $error_file Path of the file that caused the error, relative to the plugins directory. @@ -43,7 +43,7 @@ public function test_handle_error_rejects_error_from_network_activated_plugin( $ * * @return array[] */ - public static function data_network_activated_plugins() { + public static function data_handle_error_rejects_error_from_network_activated_plugin() { return array( 'plugin in a directory, main file' => array( 'custom-internationalized-plugin/custom-internationalized-plugin.php', @@ -65,7 +65,7 @@ public static function data_network_activated_plugins() { * * @ticket 66328 * - * @dataProvider data_plugins_that_are_not_network_activated + * @dataProvider data_handle_error_does_not_reject_error_from_other_plugin * * @param string $network_plugin Plugin basename to network-activate. * @param string $error_file Path of the file that caused the error, relative to the plugins directory. @@ -92,7 +92,7 @@ public function test_handle_error_does_not_reject_error_from_other_plugin( $netw * * @return array[] */ - public static function data_plugins_that_are_not_network_activated() { + public static function data_handle_error_does_not_reject_error_from_other_plugin() { return array( 'other directory plugin' => array( 'custom-internationalized-plugin/custom-internationalized-plugin.php', diff --git a/tests/phpunit/tests/feed/feedContentType.php b/tests/phpunit/tests/feed/feedContentType.php index 30dc9bb98bc74..de74fdeb23cc4 100644 --- a/tests/phpunit/tests/feed/feedContentType.php +++ b/tests/phpunit/tests/feed/feedContentType.php @@ -11,7 +11,7 @@ class Tests_Feed_FeedContentType extends WP_UnitTestCase { /** * @ticket 65819 * - * @dataProvider data_known_feed_content_types + * @dataProvider data_returns_content_type_for_known_feed_types * * @param string $type Feed type. * @param string $expected Expected content type. @@ -25,7 +25,7 @@ public function test_returns_content_type_for_known_feed_types( $type, $expected * * @return array[] */ - public static function data_known_feed_content_types() { + public static function data_returns_content_type_for_known_feed_types() { return array( 'rss' => array( 'rss', 'application/rss+xml' ), 'rss2' => array( 'rss2', 'application/rss+xml' ), diff --git a/tests/phpunit/tests/formatting/wpSprintf.php b/tests/phpunit/tests/formatting/wpSprintf.php index 37ffad988acdf..18862e702dd9d 100644 --- a/tests/phpunit/tests/formatting/wpSprintf.php +++ b/tests/phpunit/tests/formatting/wpSprintf.php @@ -82,7 +82,7 @@ static function ( $fragment, $arg ) { * @covers ::wp_sprintf * @covers ::wp_sprintf_l * - * @dataProvider data_wp_sprintf_l + * @dataProvider data_wp_sprintf_formats_lists * * @param string $pattern Pattern. * @param mixed $items Items passed for the %l specifier. @@ -97,7 +97,7 @@ public function test_wp_sprintf_formats_lists( $pattern, $items, $expected ) { * * @return array[] */ - public static function data_wp_sprintf_l() { + public static function data_wp_sprintf_formats_lists() { return array( 'one item' => array( 'Tags: %l.', array( 'one' ), 'Tags: one.' ), 'two items' => array( 'Tags: %l.', array( 'one', 'two' ), 'Tags: one and two.' ), @@ -114,7 +114,7 @@ public static function data_wp_sprintf_l() { * * @covers ::wp_sprintf_l * - * @dataProvider data_wp_sprintf_l_patterns + * @dataProvider data_wp_sprintf_l * * @param string $pattern Pattern. * @param array $items Items. @@ -129,7 +129,7 @@ public function test_wp_sprintf_l( $pattern, $items, $expected ) { * * @return array[] */ - public static function data_wp_sprintf_l_patterns() { + public static function data_wp_sprintf_l() { return array( 'list specifier with a suffix' => array( '%l!', array( 'a', 'b', 'c' ), 'a, b, and c!' ), 'other specifier' => array( '%s', array( 'a', 'b' ), '%s' ), diff --git a/tests/phpunit/tests/functions.php b/tests/phpunit/tests/functions.php index 9e04db504de13..cb20bcb1a8247 100644 --- a/tests/phpunit/tests/functions.php +++ b/tests/phpunit/tests/functions.php @@ -1900,7 +1900,7 @@ static function ( $mimes ) use ( $woff_mime_type ) { * @group ms-excluded * @requires extension fileinfo * - * @dataProvider data_wp_check_filetype_and_ext_with_ttf_mime_types + * @dataProvider data_wp_check_filetype_and_ext_accepts_either_ttf_mime_type * * @covers ::wp_check_filetype_and_ext * @@ -1937,7 +1937,7 @@ public function test_wp_check_filetype_and_ext_accepts_either_ttf_mime_type( $mi * * @return array[] */ - public static function data_wp_check_filetype_and_ext_with_ttf_mime_types() { + public static function data_wp_check_filetype_and_ext_accepts_either_ttf_mime_type() { return array( 'font/ttf' => array( 'font/ttf' ), 'font/sfnt' => array( 'font/sfnt' ), diff --git a/tests/phpunit/tests/functions/wpCheckJsonpCallback.php b/tests/phpunit/tests/functions/wpCheckJsonpCallback.php index 9a3c8086b08e7..96e290b860509 100644 --- a/tests/phpunit/tests/functions/wpCheckJsonpCallback.php +++ b/tests/phpunit/tests/functions/wpCheckJsonpCallback.php @@ -14,7 +14,7 @@ class Tests_Functions_WpCheckJsonpCallback extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_valid_callbacks + * @dataProvider data_returns_true_for_valid_callbacks * * @param string $callback Valid callback name. */ @@ -27,7 +27,7 @@ public function test_returns_true_for_valid_callbacks( $callback ) { * * @return array[] */ - public static function data_valid_callbacks() { + public static function data_returns_true_for_valid_callbacks() { return array( 'empty string' => array( '' ), ); @@ -38,7 +38,7 @@ public static function data_valid_callbacks() { * * @ticket 65819 * - * @dataProvider data_invalid_callbacks + * @dataProvider data_returns_false_for_invalid_callbacks * * @param mixed $callback Invalid callback value. */ @@ -51,7 +51,7 @@ public function test_returns_false_for_invalid_callbacks( $callback ) { * * @return array[] */ - public static function data_invalid_callbacks() { + public static function data_returns_false_for_invalid_callbacks() { return array( 'parentheses' => array( 'alert(1)' ), 'array' => array( array( 'callback' ) ), diff --git a/tests/phpunit/tests/functions/wpGetUpdateData.php b/tests/phpunit/tests/functions/wpGetUpdateData.php index 8f1e5b4e35aa9..780465803b01a 100644 --- a/tests/phpunit/tests/functions/wpGetUpdateData.php +++ b/tests/phpunit/tests/functions/wpGetUpdateData.php @@ -130,7 +130,7 @@ public function test_should_count_all_updates() { * * @ticket 65819 * - * @dataProvider data_plugin_and_theme_counts + * @dataProvider data_should_pluralize_titles * * @param int $plugins The number of plugin updates. * @param int $themes The number of theme updates. @@ -150,7 +150,7 @@ public function test_should_pluralize_titles( $plugins, $themes, $expected ) { * * @return array[] */ - public static function data_plugin_and_theme_counts() { + public static function data_should_pluralize_titles() { return array( 'one plugin' => array( 1, 0, '1 Plugin Update' ), 'two plugins' => array( 2, 0, '2 Plugin Updates' ), @@ -164,7 +164,7 @@ public static function data_plugin_and_theme_counts() { * * @ticket 65819 * - * @dataProvider data_core_responses + * @dataProvider data_should_count_core_update_by_response * * @param string $response The core update response type. * @param int $expected The expected count. @@ -182,7 +182,7 @@ public function test_should_count_core_update_by_response( $response, $expected * * @return array[] */ - public static function data_core_responses() { + public static function data_should_count_core_update_by_response() { return array( 'upgrade' => array( 'upgrade', 1 ), 'latest' => array( 'latest', 0 ), @@ -303,7 +303,7 @@ public static function data_capabilities() { * * @ticket 65819 * - * @dataProvider data_update_transients + * @dataProvider data_should_count_translation_updates_once * * @param string $transient The update transient holding the translations. */ @@ -331,7 +331,7 @@ public function test_should_count_translation_updates_once( $transient ) { * * @return array[] */ - public static function data_update_transients() { + public static function data_should_count_translation_updates_once() { return self::text_array_to_dataprovider( self::$transients ); } diff --git a/tests/phpunit/tests/functions/wpListFilter.php b/tests/phpunit/tests/functions/wpListFilter.php index 2c9a8a7d6b134..3464eb44cd35d 100644 --- a/tests/phpunit/tests/functions/wpListFilter.php +++ b/tests/phpunit/tests/functions/wpListFilter.php @@ -24,32 +24,6 @@ public function test_wp_list_filter( $input_list, $args, $operator, $expected ) $this->assertEqualSetsWithIndex( $expected, wp_list_filter( $input_list, $args, $operator ) ); } - /** - * Tests that the 'AND' operator is used when no operator is passed. - * - * @ticket 53987 - */ - public function test_wp_list_filter_should_default_to_and_operator() { - $input_list = array( - (object) array( - 'foo' => 'bar', - 'bar' => 'baz', - ), - (object) array( 'foo' => 'bar' ), - ); - - $this->assertEqualSetsWithIndex( - array( 0 => $input_list[0] ), - wp_list_filter( - $input_list, - array( - 'foo' => 'bar', - 'bar' => 'baz', - ) - ) - ); - } - /** * Data provider. * @@ -502,4 +476,30 @@ public static function data_wp_list_filter() { ), ); } + + /** + * Tests that the 'AND' operator is used when no operator is passed. + * + * @ticket 53987 + */ + public function test_wp_list_filter_should_default_to_and_operator() { + $input_list = array( + (object) array( + 'foo' => 'bar', + 'bar' => 'baz', + ), + (object) array( 'foo' => 'bar' ), + ); + + $this->assertEqualSetsWithIndex( + array( 0 => $input_list[0] ), + wp_list_filter( + $input_list, + array( + 'foo' => 'bar', + 'bar' => 'baz', + ) + ) + ); + } } diff --git a/tests/phpunit/tests/functions/wpScheduleUpdateChecks.php b/tests/phpunit/tests/functions/wpScheduleUpdateChecks.php index 05429e0834f41..d529ee1fc43d7 100644 --- a/tests/phpunit/tests/functions/wpScheduleUpdateChecks.php +++ b/tests/phpunit/tests/functions/wpScheduleUpdateChecks.php @@ -79,7 +79,7 @@ public function test_should_schedule_update_checks() { * * @ticket 65819 * - * @dataProvider data_hooks + * @dataProvider data_should_not_reschedule_scheduled_update_check * * @param string $scheduled The update check that is already scheduled. */ @@ -100,7 +100,7 @@ public function test_should_not_reschedule_scheduled_update_check( $scheduled ) * * @return array[] */ - public static function data_hooks() { + public static function data_should_not_reschedule_scheduled_update_check() { return self::text_array_to_dataprovider( self::$hooks ); } diff --git a/tests/phpunit/tests/general/getTheGenerator.php b/tests/phpunit/tests/general/getTheGenerator.php index 62100e9d1b2b7..26e1bc2c7f7ae 100644 --- a/tests/phpunit/tests/general/getTheGenerator.php +++ b/tests/phpunit/tests/general/getTheGenerator.php @@ -17,7 +17,7 @@ class Tests_General_GetTheGenerator extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_generator_types + * @dataProvider data_get_the_generator_types * * @param string $type Generator type. * @param string $expected Expected markup template with placeholder for version. @@ -35,7 +35,7 @@ public function test_get_the_generator_types( $type, $expected ) { * * @return array[] */ - public static function data_generator_types() { + public static function data_get_the_generator_types() { return array( 'html' => array( 'html', diff --git a/tests/phpunit/tests/general/singleMonthTitle.php b/tests/phpunit/tests/general/singleMonthTitle.php index 7023dde81a325..9b5131f6cfb90 100644 --- a/tests/phpunit/tests/general/singleMonthTitle.php +++ b/tests/phpunit/tests/general/singleMonthTitle.php @@ -15,7 +15,7 @@ class Tests_General_SingleMonthTitle extends WP_UnitTestCase { * * @covers ::single_month_title * - * @dataProvider data_month_titles + * @dataProvider data_returns_month_title * * @param string $query Query string of the request. * @param string $prefix Prefix passed to the function. @@ -32,7 +32,7 @@ public function test_returns_month_title( $query, $prefix, $expected ) { * * @return array[] */ - public static function data_month_titles() { + public static function data_returns_month_title() { return array( 'year and monthnum, no prefix' => array( 'year=2024&monthnum=3', '', 'March2024' ), 'year and monthnum, custom prefix' => array( 'year=2024&monthnum=3', ' / ', ' / March / 2024' ), @@ -49,7 +49,7 @@ public static function data_month_titles() { * * @covers ::single_month_title * - * @dataProvider data_no_month + * @dataProvider data_returns_false_without_month * * @param string $query Query string of the request. */ @@ -64,7 +64,7 @@ public function test_returns_false_without_month( $query ) { * * @return array[] */ - public static function data_no_month() { + public static function data_returns_false_without_month() { return array( 'no date query variables' => array( '' ), 'm with year only' => array( 'm=2024' ), diff --git a/tests/phpunit/tests/general/singlePostTitle.php b/tests/phpunit/tests/general/singlePostTitle.php index 3a030e4d8e055..ae3f7f5e3de7b 100644 --- a/tests/phpunit/tests/general/singlePostTitle.php +++ b/tests/phpunit/tests/general/singlePostTitle.php @@ -52,7 +52,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { * * @covers ::single_post_title * - * @dataProvider data_singular_titles + * @dataProvider data_returns_title_on_singular_views * * @param string $post_type Post type to view. * @param string $prefix Prefix passed to the function. @@ -69,7 +69,7 @@ public function test_returns_title_on_singular_views( $post_type, $prefix, $expe * * @return array[] */ - public static function data_singular_titles() { + public static function data_returns_title_on_singular_views() { return array( 'post, no prefix' => array( 'post', '', 'Hello Title' ), 'post, with prefix' => array( 'post', 'Blog » ', 'Blog » Hello Title' ), diff --git a/tests/phpunit/tests/general/singleTermTitle.php b/tests/phpunit/tests/general/singleTermTitle.php index 751cf2755f573..6bbd7e59dc2b4 100644 --- a/tests/phpunit/tests/general/singleTermTitle.php +++ b/tests/phpunit/tests/general/singleTermTitle.php @@ -98,7 +98,7 @@ private function go_to_archive( $archive ) { * * @ticket 65819 * - * @dataProvider data_term_archives + * @dataProvider data_returns_title_for_term_archives * * @param string $archive Archive type. * @param string $expected Expected title. @@ -114,7 +114,7 @@ public function test_returns_title_for_term_archives( $archive, $expected ) { * * @return array[] */ - public static function data_term_archives() { + public static function data_returns_title_for_term_archives() { return array( 'category' => array( 'category', 'Archive: News & Notes' ), 'tag' => array( 'tag', 'Archive: Featured' ), @@ -153,7 +153,7 @@ public function test_displays_prefix() { * * @ticket 65819 * - * @dataProvider data_not_term_archives + * @dataProvider data_returns_null_outside_term_archives * * @param string $archive Archive type, or an empty string for the home page. */ @@ -175,7 +175,7 @@ public function test_returns_null_outside_term_archives( $archive ) { * * @return array[] */ - public static function data_not_term_archives() { + public static function data_returns_null_outside_term_archives() { return array( 'home page' => array( '' ), 'author archive' => array( 'author' ), @@ -188,7 +188,7 @@ public static function data_not_term_archives() { * * @ticket 65819 * - * @dataProvider data_filters + * @dataProvider data_applies_filter_for_archive_type * * @param string $archive Archive type. * @param string $hook Filter expected to run. @@ -228,7 +228,7 @@ static function ( $title ) { * * @return array[] */ - public static function data_filters() { + public static function data_applies_filter_for_archive_type() { return array( 'category' => array( 'category', 'single_cat_title', 'News & Notes', 'NEWS & NOTES' ), 'tag' => array( 'tag', 'single_tag_title', 'Featured', 'FEATURED' ), diff --git a/tests/phpunit/tests/general/wpGetCodeEditorSettings.php b/tests/phpunit/tests/general/wpGetCodeEditorSettings.php index eac4883b5ef2f..09c4b4b641b8e 100644 --- a/tests/phpunit/tests/general/wpGetCodeEditorSettings.php +++ b/tests/phpunit/tests/general/wpGetCodeEditorSettings.php @@ -14,7 +14,7 @@ class Tests_General_wpGetCodeEditorSettings extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_mime_types + * @dataProvider data_codemirror_settings_for_mime_type * * @param string $type MIME type. * @param array $expected Expected CodeMirror settings, in addition to the defaults. @@ -47,7 +47,7 @@ public function test_codemirror_settings_for_mime_type( $type, $expected ) { * * @return array[] */ - public static function data_mime_types() { + public static function data_codemirror_settings_for_mime_type() { $css = array( 'lint' => false, 'autoCloseBrackets' => true, @@ -171,7 +171,7 @@ public static function data_mime_types() { * * @ticket 65819 * - * @dataProvider data_file_names + * @dataProvider data_codemirror_mode_for_file * * @param string $file File name. * @param string|array $mode Expected CodeMirror mode. @@ -185,7 +185,7 @@ public function test_codemirror_mode_for_file( $file, $mode ) { * * @return array[] */ - public static function data_file_names() { + public static function data_codemirror_mode_for_file() { return array( // Extensions known to wp_get_mime_types(). 'CSS file' => array( 'style.css', 'text/css' ), @@ -254,7 +254,7 @@ public function test_type_takes_precedence_over_file() { * * @ticket 65819 * - * @dataProvider data_module_files + * @dataProvider data_jshint_module_for_mjs_files * * @param array $args Arguments. * @param bool $expected Whether the script should be parsed as a module. @@ -268,7 +268,7 @@ public function test_jshint_module_for_mjs_files( $args, $expected ) { * * @return array[] */ - public static function data_module_files() { + public static function data_jshint_module_for_mjs_files() { return array( '.mjs file' => array( array( 'file' => 'module.mjs' ), true ), '.js file' => array( array( 'file' => 'script.js' ), false ), @@ -282,7 +282,7 @@ public static function data_module_files() { * * @ticket 65819 * - * @dataProvider data_unfiltered_html + * @dataProvider data_htmlhint_kses_rules_for_html * * @param bool $can_use_unfiltered_html Whether the user can use unfiltered HTML. */ @@ -304,7 +304,7 @@ public function test_htmlhint_kses_rules_for_html( $can_use_unfiltered_html ) { * * @return array[] */ - public static function data_unfiltered_html() { + public static function data_htmlhint_kses_rules_for_html() { return array( 'user can use unfiltered HTML' => array( true ), 'user cannot use unfiltered HTML' => array( false ), diff --git a/tests/phpunit/tests/general/wpGetTooltip.php b/tests/phpunit/tests/general/wpGetTooltip.php index a6bd3e3fdd854..d905db590a0fc 100644 --- a/tests/phpunit/tests/general/wpGetTooltip.php +++ b/tests/phpunit/tests/general/wpGetTooltip.php @@ -295,7 +295,7 @@ public function test_wp_get_toggletip_bubble_uses_dialog_role_and_autofocus() { * * @ticket 65914 * - * @dataProvider data_button_markup_containing_percent_signs + * @dataProvider data_wp_get_tooltip_preserves_percent_signs_in_button_markup * * @param string $button Button markup containing a percent sign. * @param string $expected Substring that must be preserved in the output. @@ -313,42 +313,12 @@ public function test_wp_get_tooltip_preserves_percent_signs_in_button_markup( $b ); } - /** - * Tests that a percent-encoded URL in anchor markup is not rewritten. - * - * @ticket 65914 - * - * @dataProvider data_percent_encoded_hrefs - * - * @param string $href A percent-encoded URL. - */ - public function test_wp_get_tooltip_preserves_percent_encoding_in_anchor_href( $href ) { - $html = wp_get_tooltip( - 'Helpful text.', - array( 'button' => 'Search' ) - ); - - $this->assertStringContainsString( 'href="' . $href . '"', $html ); - } - - /** - * Data provider. - * - * @return array[] - */ - public static function data_percent_encoded_hrefs() { - return array( - 'an encoded space' => array( '/wp-admin/edit.php?s=hello%20world' ), - 'an encoded slash' => array( '/x?p=a%2Fb' ), - ); - } - /** * Data provider. * * @return array[] */ - public static function data_button_markup_containing_percent_signs() { + public static function data_wp_get_tooltip_preserves_percent_signs_in_button_markup() { return array( 'a literal percent sign' => array( '', @@ -377,6 +347,36 @@ public static function data_button_markup_containing_percent_signs() { ); } + /** + * Tests that a percent-encoded URL in anchor markup is not rewritten. + * + * @ticket 65914 + * + * @dataProvider data_wp_get_tooltip_preserves_percent_encoding_in_anchor_href + * + * @param string $href A percent-encoded URL. + */ + public function test_wp_get_tooltip_preserves_percent_encoding_in_anchor_href( $href ) { + $html = wp_get_tooltip( + 'Helpful text.', + array( 'button' => 'Search' ) + ); + + $this->assertStringContainsString( 'href="' . $href . '"', $html ); + } + + /** + * Data provider. + * + * @return array[] + */ + public static function data_wp_get_tooltip_preserves_percent_encoding_in_anchor_href() { + return array( + 'an encoded space' => array( '/wp-admin/edit.php?s=hello%20world' ), + 'an encoded slash' => array( '/x?p=a%2Fb' ), + ); + } + /** * Data provider. * diff --git a/tests/phpunit/tests/general/wpLoginout.php b/tests/phpunit/tests/general/wpLoginout.php index 8d99ebe977355..207e890b196a6 100644 --- a/tests/phpunit/tests/general/wpLoginout.php +++ b/tests/phpunit/tests/general/wpLoginout.php @@ -27,7 +27,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { * * @covers ::wp_loginout * - * @dataProvider data_login_link + * @dataProvider data_login_link_when_logged_out * * @param string $redirect Redirect path passed to the function. * @param string $expected Expected markup after the host. @@ -41,7 +41,7 @@ public function test_login_link_when_logged_out( $redirect, $expected ) { * * @return array[] */ - public static function data_login_link() { + public static function data_login_link_when_logged_out() { return array( 'no redirect' => array( '', '/wp-login.php">Log in' ), 'with redirect' => array( '/sample-page/', '/wp-login.php?redirect_to=%2Fsample-page%2F">Log in' ), @@ -55,7 +55,7 @@ public static function data_login_link() { * * @covers ::wp_loginout * - * @dataProvider data_logout_link + * @dataProvider data_logout_link_when_logged_in * * @param string $redirect Redirect path passed to the function. * @param string $query Expected query string before the nonce. @@ -74,7 +74,7 @@ public function test_logout_link_when_logged_in( $redirect, $query ) { * * @return array[] */ - public static function data_logout_link() { + public static function data_logout_link_when_logged_in() { return array( 'no redirect' => array( '', 'action=logout' ), 'with redirect' => array( '/sample-page/', 'action=logout&redirect_to=%2Fsample-page%2F' ), @@ -119,7 +119,7 @@ public function test_echoes_link_by_default() { * * @covers ::wp_loginout * - * @dataProvider data_display + * @dataProvider data_loginout_filter * * @param bool $display Whether to echo the link. */ @@ -152,7 +152,7 @@ static function ( $link ) use ( &$received ) { * * @return array[] */ - public static function data_display() { + public static function data_loginout_filter() { return array( 'echo' => array( true ), 'return' => array( false ), diff --git a/tests/phpunit/tests/general/wpRegister.php b/tests/phpunit/tests/general/wpRegister.php index fb5bc19c9325e..7df9766bc2bc5 100644 --- a/tests/phpunit/tests/general/wpRegister.php +++ b/tests/phpunit/tests/general/wpRegister.php @@ -47,7 +47,7 @@ private function set_users_can_register( $enabled ) { * * @covers ::wp_register * - * @dataProvider data_register_link + * @dataProvider data_register_link_when_registration_is_enabled * * @param string $before Text before the link. * @param string $after Text after the link. @@ -66,7 +66,7 @@ public function test_register_link_when_registration_is_enabled( $before, $after * * @return array[] */ - public static function data_register_link() { + public static function data_register_link_when_registration_is_enabled() { return array( 'custom wrapper' => array( '

', '

' ), 'no wrapper' => array( '', '' ), diff --git a/tests/phpunit/tests/hooks/wpCallAllHook.php b/tests/phpunit/tests/hooks/wpCallAllHook.php index 0b8f18d82246d..2b40166a78e58 100644 --- a/tests/phpunit/tests/hooks/wpCallAllHook.php +++ b/tests/phpunit/tests/hooks/wpCallAllHook.php @@ -31,7 +31,7 @@ class Tests_Hooks_WpCallAllHook extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_hook_calls + * @dataProvider data_should_pass_hook_name_and_arguments_to_all_hook * * @param string $hook_function The hook function to call. * @param array $args The arguments after the hook name. @@ -50,7 +50,7 @@ public function test_should_pass_hook_name_and_arguments_to_all_hook( $hook_func * * @return array[] */ - public static function data_hook_calls() { + public static function data_should_pass_hook_name_and_arguments_to_all_hook() { return array( 'do_action with arguments' => array( 'do_action', array( 'a', 2, false ) ), 'do_action_ref_array' => array( 'do_action_ref_array', array( array( 'a', 2 ) ) ), diff --git a/tests/phpunit/tests/html-api/wpHtmlDecoder.php b/tests/phpunit/tests/html-api/wpHtmlDecoder.php index 894cfee43f9f5..049c80c0df777 100644 --- a/tests/phpunit/tests/html-api/wpHtmlDecoder.php +++ b/tests/phpunit/tests/html-api/wpHtmlDecoder.php @@ -251,7 +251,7 @@ public static function data_semicolonless_attribute_behaviors(): array { * * @ticket 61072 * - * @dataProvider data_ambiguous_ampersands + * @dataProvider data_decodes_ambiguous_ampersands * * @param string $context 'attribute' or 'data'. * @param string $raw_text Raw text. @@ -270,7 +270,7 @@ public function test_decodes_ambiguous_ampersands( string $context, string $raw_ * * @return array */ - public static function data_ambiguous_ampersands(): array { + public static function data_decodes_ambiguous_ampersands(): array { return array( 'Semicolonless reference (data)' => array( 'data', '&', '&' ), 'Semicolonless reference (attr)' => array( 'attribute', '&', '&' ), @@ -560,7 +560,7 @@ public static function data_attributes_with_prefix_and_case_sensitive_match() { * * @ticket 61072 * - * @dataProvider data_decode_attribute_named_character_references + * @dataProvider data_decode_attribute_decodes_named_character_references * * @param string $raw_text Raw attribute value containing named character reference. * @param string $expected Expected decoded string. @@ -581,7 +581,7 @@ public function test_decode_attribute_decodes_named_character_references( string * * @return array */ - public static function data_decode_attribute_named_character_references(): array { + public static function data_decode_attribute_decodes_named_character_references(): array { return array( // The main syntax characters. 'Ampersand with semicolon' => array( '&', '&' ), @@ -617,7 +617,7 @@ public static function data_decode_attribute_named_character_references(): array * * @ticket 61072 * - * @dataProvider data_numeric_character_references + * @dataProvider data_decodes_numeric_character_references * * @param string $raw_text Raw numeric character reference. * @param string $expected Expected decoded string. @@ -646,7 +646,7 @@ public function test_decodes_numeric_character_references( string $raw_text, str * * @return Generator Test cases. */ - public static function data_numeric_character_references(): Generator { + public static function data_decodes_numeric_character_references(): Generator { $code_points = array( 'ASCII' => array( 0x41, 'A' ), 'Two-byte UTF-8' => array( 0xE9, 'é' ), @@ -691,7 +691,7 @@ public static function data_numeric_character_references(): Generator { * * @ticket 61072 * - * @dataProvider data_windows_1252_mapped_characters + * @dataProvider data_decodes_windows_1252_mapped_characters * * @param string $raw_text Raw numeric character reference. * @param string $expected Expected decoded character. @@ -714,7 +714,7 @@ public function test_decodes_windows_1252_mapped_characters( string $raw_text, s * * @return array */ - public static function data_windows_1252_mapped_characters(): array { + public static function data_decodes_windows_1252_mapped_characters(): array { return array( 'Euro sign' => array( '€', '€' ), 'Unmapped U+81' => array( '', "\u{81}" ), diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index 1bfaa01bf0453..0df3178508fc6 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -2374,7 +2374,7 @@ public static function data_script_tag(): Generator { * * @ticket 65372 * - * @dataProvider data_rcdata_and_rawtext_tag_name_terminators + * @dataProvider data_rcdata_and_rawtext_end_tags_accept_tag_name_terminators * * @param non-falsy-string $tag_name The RCDATA or RAWTEXT tag name. * @param non-falsy-string $tag_name_terminator The tag-name-terminating character. @@ -2394,7 +2394,7 @@ public function test_rcdata_and_rawtext_end_tags_accept_tag_name_terminators( st * * @return Generator Test cases. */ - public static function data_rcdata_and_rawtext_tag_name_terminators(): Generator { + public static function data_rcdata_and_rawtext_end_tags_accept_tag_name_terminators(): Generator { foreach ( array( 'IFRAME', 'NOEMBED', 'NOFRAMES', 'STYLE', 'XMP', 'TEXTAREA', 'TITLE' ) as $tag_name ) { foreach ( self::data_tag_name_terminators() as $terminator_name => $terminator_data ) { yield "{$tag_name} + {$terminator_name}" => array( strtolower( $tag_name ), $terminator_data[0] ); diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php index cd844a8cee326..7459a3b1b690c 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php @@ -584,7 +584,7 @@ public function test_replaces_previous_processing_instruction_data_update(): voi * * @ticket 65984 * - * @dataProvider data_rcdata_element_names + * @dataProvider data_escapes_rcdata_content * * @param 'TITLE'|'TEXTAREA' $element_name Which RCDATA element to verify. */ @@ -644,7 +644,7 @@ public function test_escapes_rcdata_content( string $element_name ): void { * * @return array[] */ - public static function data_rcdata_element_names(): array { + public static function data_escapes_rcdata_content(): array { return array( array( 'TEXTAREA' ), array( 'TITLE' ), @@ -727,7 +727,7 @@ public static function data_unallowed_modifiable_text_updates() { * * @ticket 65824 * - * @dataProvider data_raw_text_resembling_a_closing_tag + * @dataProvider data_allows_raw_text_which_cannot_close_its_element * * @param string $html HTML whose first tag holds the raw text to replace. * @param string $update Text resembling, but not forming, that element's closing tag. @@ -763,7 +763,7 @@ public function test_allows_raw_text_which_cannot_close_its_element( string $htm * * @return array[] */ - public static function data_raw_text_resembling_a_closing_tag(): array { + public static function data_allows_raw_text_which_cannot_close_its_element(): array { return array( 'IFRAME with ' => array( '', 'Just a ', '' ), 'NOEMBED with ' => array( 'Replace me', 'Just a ', 'Just a </NOEMBEDDED>' ), diff --git a/tests/phpunit/tests/http/wpHttpEncoding.php b/tests/phpunit/tests/http/wpHttpEncoding.php index c44800648311d..b2700dc3a4972 100644 --- a/tests/phpunit/tests/http/wpHttpEncoding.php +++ b/tests/phpunit/tests/http/wpHttpEncoding.php @@ -76,7 +76,7 @@ public function test_compress_uses_compression_level() { * @covers ::decompress * @covers ::compatible_gzinflate * - * @dataProvider data_compressed_content + * @dataProvider data_decompress * * @requires function gzdeflate * @requires function gzinflate @@ -101,7 +101,7 @@ public function test_decompress( $encoder, $args ) { * * @return array[] */ - public static function data_compressed_content() { + public static function data_decompress() { return array( 'raw deflate' => array( 'gzdeflate', array( self::CONTENT ) ), 'raw deflate without compression' => array( 'gzdeflate', array( self::CONTENT, 0 ) ), @@ -118,7 +118,7 @@ public static function data_compressed_content() { * * @covers ::decompress * - * @dataProvider data_content_that_is_not_compressed + * @dataProvider data_decompress_returns_uncompressed_content_unchanged * * @requires function gzinflate * @requires function gzuncompress @@ -134,7 +134,7 @@ public function test_decompress_returns_uncompressed_content_unchanged( $content * * @return array[] */ - public static function data_content_that_is_not_compressed() { + public static function data_decompress_returns_uncompressed_content_unchanged() { return array( 'plain text' => array( self::CONTENT ), 'empty string' => array( '' ), @@ -149,7 +149,7 @@ public static function data_content_that_is_not_compressed() { * * @covers ::compatible_gzinflate * - * @dataProvider data_gzip_streams + * @dataProvider data_compatible_gzinflate_decodes_gzip_streams * * @requires function gzdeflate * @requires function gzinflate @@ -172,7 +172,7 @@ public function test_compatible_gzinflate_decodes_gzip_streams( $encoder, $args * * @return array[] */ - public static function data_gzip_streams() { + public static function data_compatible_gzinflate_decodes_gzip_streams() { $build = array( self::class, 'build_gzip_stream' ); return array( @@ -193,7 +193,7 @@ public static function data_gzip_streams() { * * @covers ::compatible_gzinflate * - * @dataProvider data_invalid_gzip_streams + * @dataProvider data_compatible_gzinflate_returns_false_for_invalid_data * * @requires function gzinflate * @@ -208,7 +208,7 @@ public function test_compatible_gzinflate_returns_false_for_invalid_data( $gz_da * * @return array[] */ - public static function data_invalid_gzip_streams() { + public static function data_compatible_gzinflate_returns_false_for_invalid_data() { return array( 'plain text' => array( self::CONTENT ), 'empty string' => array( '' ), diff --git a/tests/phpunit/tests/http/wpHttpProxy.php b/tests/phpunit/tests/http/wpHttpProxy.php index c09c16732a0a7..8c52aa0ee9f56 100644 --- a/tests/phpunit/tests/http/wpHttpProxy.php +++ b/tests/phpunit/tests/http/wpHttpProxy.php @@ -91,7 +91,7 @@ public function test_proxy_settings_are_read_from_constants() { * @covers ::is_enabled * @covers ::use_authentication * - * @dataProvider data_incomplete_constants + * @dataProvider data_proxy_is_disabled_with_incomplete_constants * * @runInSeparateProcess * @preserveGlobalState disabled @@ -112,7 +112,7 @@ public function test_proxy_is_disabled_with_incomplete_constants( $constant ) { * * @return array[] */ - public static function data_incomplete_constants() { + public static function data_proxy_is_disabled_with_incomplete_constants() { return array( 'host only' => array( 'WP_PROXY_HOST' ), 'port only' => array( 'WP_PROXY_PORT' ), @@ -164,7 +164,7 @@ public static function data_send_through_proxy() { * * @covers ::send_through_proxy * - * @dataProvider data_pre_send_through_proxy + * @dataProvider data_send_through_proxy_can_be_short_circuited * * @param string $uri Request URI. * @param mixed $filtered Value returned by the filter. @@ -188,7 +188,7 @@ static function () use ( $filtered ) { * * @return array[] */ - public static function data_pre_send_through_proxy() { + public static function data_send_through_proxy_can_be_short_circuited() { return array( 'bypass proxy for an external host' => array( 'https://api.wordpress.org/', false, false ), 'use proxy for the site host' => array( 'http://example.org/', true, true ), diff --git a/tests/phpunit/tests/icons/wpIconCollectionsRegistry.php b/tests/phpunit/tests/icons/wpIconCollectionsRegistry.php index f66661a71745e..bcde8a038b848 100644 --- a/tests/phpunit/tests/icons/wpIconCollectionsRegistry.php +++ b/tests/phpunit/tests/icons/wpIconCollectionsRegistry.php @@ -220,7 +220,7 @@ public function test_register_collection_defaults_to_public() { * * @ticket 66087 * - * @dataProvider data_boolean_public_properties + * @dataProvider data_register_collection_accepts_boolean_public_property * * @covers ::register * @@ -244,7 +244,7 @@ public function test_register_collection_accepts_boolean_public_property( $is_pu * * @return array[] */ - public static function data_boolean_public_properties() { + public static function data_register_collection_accepts_boolean_public_property() { return array( 'public collection' => array( true ), 'non-public collection' => array( false ), @@ -256,7 +256,7 @@ public static function data_boolean_public_properties() { * * @ticket 66087 * - * @dataProvider data_non_boolean_public_properties + * @dataProvider data_register_collection_rejects_non_boolean_public_property * * @covers ::register * @@ -282,7 +282,7 @@ public function test_register_collection_rejects_non_boolean_public_property( $i * * @return array[] */ - public static function data_non_boolean_public_properties() { + public static function data_register_collection_rejects_non_boolean_public_property() { return array( 'string' => array( 'false' ), 'integer' => array( 0 ), diff --git a/tests/phpunit/tests/icons/wpIconsRegistry.php b/tests/phpunit/tests/icons/wpIconsRegistry.php index ddfef00218a02..36aa638517709 100644 --- a/tests/phpunit/tests/icons/wpIconsRegistry.php +++ b/tests/phpunit/tests/icons/wpIconsRegistry.php @@ -618,29 +618,12 @@ public function test_register_icon_without_keywords() { $this->assertArrayNotHasKey( 'keywords', $icon ); } - /** - * Provides values that are not an array of strings. - * - * @return array - */ - public static function data_invalid_keywords() { - return array( - 'null' => array( null ), - 'a string' => array( 'alpha' ), - 'an integer' => array( 5 ), - 'an array of integers' => array( array( 1, 2 ) ), - 'a mixed array' => array( array( 'alpha', 5 ) ), - 'a nested array' => array( array( array( 'alpha' ) ) ), - 'an array of null' => array( array( null ) ), - ); - } - /** * Should fail to register an icon whose `keywords` is not an array of strings. * * @ticket 66158 * - * @dataProvider data_invalid_keywords + * @dataProvider data_register_icon_with_invalid_keywords * @expectedIncorrectUsage WP_Icons_Registry::register * * @param mixed $keywords Invalid keywords candidate. @@ -661,6 +644,23 @@ public function test_register_icon_with_invalid_keywords( $keywords ) { $this->assertFalse( $this->registry->is_registered( $name ) ); } + /** + * Provides values that are not an array of strings. + * + * @return array + */ + public static function data_register_icon_with_invalid_keywords() { + return array( + 'null' => array( null ), + 'a string' => array( 'alpha' ), + 'an integer' => array( 5 ), + 'an array of integers' => array( array( 1, 2 ) ), + 'a mixed array' => array( array( 'alpha', 5 ) ), + 'a nested array' => array( array( array( 'alpha' ) ) ), + 'an array of null' => array( array( null ) ), + ); + } + /** * Should match an icon by keyword when neither its name nor its label match. * @@ -773,7 +773,7 @@ public function test_get_admin_icon_name_for_dashicon_returns_null_for_unregiste * * @covers ::get_admin_icon_name_for_dashicon * - * @dataProvider data_get_admin_icon_name_for_dashicon_without_replacement + * @dataProvider data_get_admin_icon_name_for_dashicon_returns_null_without_replacement * * @param mixed $value The value to look up. */ @@ -794,7 +794,7 @@ public function test_get_admin_icon_name_for_dashicon_returns_null_without_repla * * @return array */ - public static function data_get_admin_icon_name_for_dashicon_without_replacement() { + public static function data_get_admin_icon_name_for_dashicon_returns_null_without_replacement() { return array( 'Dashicon without replacement' => array( 'dashicons-heart' ), 'Dashicon name without prefix' => array( 'admin-post' ), diff --git a/tests/phpunit/tests/icons/wpIsValidIconName.php b/tests/phpunit/tests/icons/wpIsValidIconName.php index 68202ff10a5d0..c75a3877620a3 100644 --- a/tests/phpunit/tests/icons/wpIsValidIconName.php +++ b/tests/phpunit/tests/icons/wpIsValidIconName.php @@ -15,7 +15,7 @@ class Tests_Icons_WpIsValidIconName extends WP_UnitTestCase { /** * @ticket 65089 * - * @dataProvider data_icon_names + * @dataProvider data_returns_true_for_namespaced_icon_names * * @param mixed $value The value to check. */ @@ -28,7 +28,7 @@ public function test_returns_true_for_namespaced_icon_names( $value ): void { * * @return array */ - public static function data_icon_names(): array { + public static function data_returns_true_for_namespaced_icon_names(): array { return array( 'core icon' => array( 'core/plus' ), 'hyphens' => array( 'core-admin/chart-bar' ), @@ -41,7 +41,7 @@ public static function data_icon_names(): array { /** * @ticket 65089 * - * @dataProvider data_values_that_are_not_icon_names + * @dataProvider data_returns_false_for_other_values * * @param mixed $value The value to check. */ @@ -54,7 +54,7 @@ public function test_returns_false_for_other_values( $value ): void { * * @return array */ - public static function data_values_that_are_not_icon_names(): array { + public static function data_returns_false_for_other_values(): array { return array( 'Dashicons class' => array( 'dashicons-admin-post' ), 'none' => array( 'none' ), diff --git a/tests/phpunit/tests/icons/wpRestIconCollectionsController.php b/tests/phpunit/tests/icons/wpRestIconCollectionsController.php index f65bf44c3a89f..370129747781b 100644 --- a/tests/phpunit/tests/icons/wpRestIconCollectionsController.php +++ b/tests/phpunit/tests/icons/wpRestIconCollectionsController.php @@ -411,7 +411,7 @@ public function test_get_items_omits_non_public_collections() { * @ticket 66087 * @ticket 66287 * - * @dataProvider data_non_public_collections + * @dataProvider data_get_item_returns_404_for_non_public_collection * * @covers ::get_item * @covers ::get_icon_collection @@ -434,7 +434,7 @@ public function test_get_item_returns_404_for_non_public_collection( $slug ) { * * @return array[] */ - public static function data_non_public_collections() { + public static function data_get_item_returns_404_for_non_public_collection() { return array( 'custom non-public collection' => array( 'rest-visibility-private' ), 'built-in core-admin' => array( 'core-admin' ), diff --git a/tests/phpunit/tests/icons/wpRestIconsController.php b/tests/phpunit/tests/icons/wpRestIconsController.php index bdd04bc16555a..521bdb73d0a99 100644 --- a/tests/phpunit/tests/icons/wpRestIconsController.php +++ b/tests/phpunit/tests/icons/wpRestIconsController.php @@ -697,7 +697,7 @@ public function test_get_item_requires_authentication() { * * @ticket 66087 * - * @dataProvider data_icon_visibility_searches + * @dataProvider data_get_items_omits_icons_in_non_public_collections * * @covers ::get_items * @@ -724,7 +724,7 @@ public function test_get_items_omits_icons_in_non_public_collections( $search ) * * @return array[] */ - public static function data_icon_visibility_searches() { + public static function data_get_items_omits_icons_in_non_public_collections() { return array( 'all icons' => array( '' ), 'search icons' => array( 'visibility' ), @@ -759,7 +759,7 @@ public function test_get_item_returns_404_for_icon_in_non_public_collection() { * * @ticket 66087 * - * @dataProvider data_non_public_collection_requests + * @dataProvider data_get_items_returns_404_for_non_public_collection * * @covers ::get_items * @@ -783,7 +783,7 @@ public function test_get_items_returns_404_for_non_public_collection( $route, $q * * @return array[] */ - public static function data_non_public_collection_requests() { + public static function data_get_items_returns_404_for_non_public_collection() { return array( 'collection route' => array( '/wp/v2/icons/rest-visibility-private', array() ), 'collection query' => array( '/wp/v2/icons', array( 'collection' => 'rest-visibility-private' ) ), diff --git a/tests/phpunit/tests/image/imageEditApplyChanges.php b/tests/phpunit/tests/image/imageEditApplyChanges.php index 3b519ca03d072..c3a36ce1fcb2c 100644 --- a/tests/phpunit/tests/image/imageEditApplyChanges.php +++ b/tests/phpunit/tests/image/imageEditApplyChanges.php @@ -81,7 +81,7 @@ private static function to_changes( array $changes ) { * * @ticket 65819 * - * @dataProvider data_changes_that_are_not_an_array + * @dataProvider data_returns_image_unchanged_when_changes_are_not_an_array * * @param mixed $changes Changes. */ @@ -101,7 +101,7 @@ public function test_returns_image_unchanged_when_changes_are_not_an_array( $cha * * @return array[] */ - public static function data_changes_that_are_not_an_array() { + public static function data_returns_image_unchanged_when_changes_are_not_an_array() { return array( 'null' => array( null ), 'object' => array( (object) array( 'r' => 90 ) ), @@ -113,7 +113,7 @@ public static function data_changes_that_are_not_an_array() { * * @ticket 65819 * - * @dataProvider data_changes + * @dataProvider data_applies_changes_to_editor * * @param array[] $changes Change operations. * @param array[] $expected Expected editor calls, each as the method name followed by its arguments. @@ -130,7 +130,7 @@ public function test_applies_changes_to_editor( $changes, $expected ) { * * @return array[] */ - public static function data_changes() { + public static function data_applies_changes_to_editor() { return array( 'no changes' => array( array(), array() ), 'rotate' => array( diff --git a/tests/phpunit/tests/includes/factory.php b/tests/phpunit/tests/includes/factory.php index a94342c03e65b..c378e81002de0 100644 --- a/tests/phpunit/tests/includes/factory.php +++ b/tests/phpunit/tests/includes/factory.php @@ -72,7 +72,7 @@ public function test_create_should_throw_an_exception_when_a_wp_error_is_returne * * @ticket 66111 * - * @dataProvider data_non_positive_object_ids + * @dataProvider data_create_should_throw_an_exception_when_a_non_positive_id_is_returned * * @param int $object_id The invalid ID returned by create_object(). */ @@ -90,7 +90,7 @@ public function test_create_should_throw_an_exception_when_a_non_positive_id_is_ * * @return array */ - public static function data_non_positive_object_ids() { + public static function data_create_should_throw_an_exception_when_a_non_positive_id_is_returned() { return array( 'zero' => array( 0 ), 'a negative ID' => array( -1 ), @@ -284,7 +284,7 @@ public function test_term_factory_create_and_get_should_honor_the_taxonomy_argum * * @ticket 66111 * - * @dataProvider data_term_taxonomy_sources + * @dataProvider data_term_factory_should_apply_an_after_create_callback * * @param non-falsy-string $taxonomy The taxonomy the term is created in. * @param bool $in_definitions Whether the taxonomy is given in the generation definitions @@ -321,7 +321,7 @@ static function ( int $created_id ) { * * @return array */ - public static function data_term_taxonomy_sources(): array { + public static function data_term_factory_should_apply_an_after_create_callback(): array { return array( 'factory taxonomy, in the args' => array( 'post_tag', false ), 'another taxonomy, in the args' => array( 'category', false ), @@ -446,7 +446,7 @@ public function test_create_should_throw_an_exception_when_a_legacy_factory_upda * * @ticket 66111 * - * @dataProvider data_legacy_retrieval_failures + * @dataProvider data_create_and_get_should_throw_an_exception_when_a_legacy_factory_cannot_retrieve * * @param WP_Error|null|false $retrieved The value the legacy get_object_by_id() returns. * @param string $message The expected exception message. @@ -465,7 +465,7 @@ public function test_create_and_get_should_throw_an_exception_when_a_legacy_fact * * @return array */ - public static function data_legacy_retrieval_failures(): array { + public static function data_create_and_get_should_throw_an_exception_when_a_legacy_factory_cannot_retrieve(): array { return array( 'null' => array( null, 'Unable to retrieve the object with ID 5. Args: []' ), 'false' => array( false, 'Unable to retrieve the object with ID 5. Args: []' ), diff --git a/tests/phpunit/tests/includes/registeredMeta.php b/tests/phpunit/tests/includes/registeredMeta.php index 53e6b3d23114a..98b7476537224 100644 --- a/tests/phpunit/tests/includes/registeredMeta.php +++ b/tests/phpunit/tests/includes/registeredMeta.php @@ -15,7 +15,7 @@ class Tests_Includes_RegisteredMeta extends PHPUnit_Adapter_TestCase { /** - * @dataProvider data_registered_metadata + * @dataProvider data_restores_metadata_registered_before_test_methods * * @param string $object_type Metadata object type. * @param string $object_subtype Metadata object subtype. @@ -83,7 +83,7 @@ public function test_restores_metadata_registered_before_test_methods( $object_t /** * @return array[] */ - public static function data_registered_metadata() { + public static function data_restores_metadata_registered_before_test_methods() { // Each case boots WordPress separately. Cover the scopes and mutation modes // without repeating their full cross-product in isolated processes. return array( diff --git a/tests/phpunit/tests/includes/uploadSnapshot.php b/tests/phpunit/tests/includes/uploadSnapshot.php index f86ac782f651a..6e9d9a2f89160 100644 --- a/tests/phpunit/tests/includes/uploadSnapshot.php +++ b/tests/phpunit/tests/includes/uploadSnapshot.php @@ -10,7 +10,7 @@ */ class Tests_Includes_UploadSnapshot extends PHPUnit_Adapter_TestCase { /** - * @dataProvider data_initial_uploads + * @dataProvider data_scan_user_uploads_preserves_initial_snapshot * * @param string[] $initial_files Files present when uploads are first scanned. */ @@ -29,7 +29,7 @@ public function test_scan_user_uploads_preserves_initial_snapshot( $initial_file /** * @return array[] */ - public static function data_initial_uploads() { + public static function data_scan_user_uploads_preserves_initial_snapshot() { return array( 'empty uploads' => array( array() ), 'existing upload' => array( array( 'existing.jpg' ) ), diff --git a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php index 5d6306827faf1..f8ba7d2a340f6 100644 --- a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php +++ b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-bind.php @@ -990,19 +990,6 @@ public function test_wp_bind_removes_existing_attribute_for_non_scalar_value( $v ); } - /** - * Data provider for event handler bindings. - * - * @return array Data provider. - */ - public static function data_event_handler_bindings(): array { - return array( - 'event handler' => array( 'attribute' => 'data-wp-bind--onclick' ), - 'event handler with an empty unique ID' => array( 'attribute' => 'data-wp-bind--onclick---' ), - 'event handler with a unique ID' => array( 'attribute' => 'data-wp-bind--onclick---unique-id' ), - ); - } - /** * Tests that `data-wp-bind` removes event handler bindings. * @@ -1010,7 +997,7 @@ public static function data_event_handler_bindings(): array { * * @covers ::process_directives * - * @dataProvider data_event_handler_bindings + * @dataProvider data_wp_bind_removes_event_handler_bindings * * @expectedIncorrectUsage WP_Interactivity_API::data_wp_bind_processor * @@ -1022,6 +1009,19 @@ public function test_wp_bind_removes_event_handler_bindings( string $attribute ) $this->assertEqualHTML( '', $new_html ); } + /** + * Data provider for event handler bindings. + * + * @return array Data provider. + */ + public static function data_wp_bind_removes_event_handler_bindings(): array { + return array( + 'event handler' => array( 'attribute' => 'data-wp-bind--onclick' ), + 'event handler with an empty unique ID' => array( 'attribute' => 'data-wp-bind--onclick---' ), + 'event handler with a unique ID' => array( 'attribute' => 'data-wp-bind--onclick---unique-id' ), + ); + } + /** * Tests that `data-wp-bind` removes an event handler binding but still * processes valid bind directives on the same element. diff --git a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-html.php b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-html.php index 5223808a71ebf..9a361c78a1fe5 100644 --- a/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-html.php +++ b/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-html.php @@ -190,7 +190,7 @@ private function announced_paths(): array { * * @covers ::process_directives * - * @dataProvider data_ways_to_reach_a_token + * @dataProvider data_token_reaches_the_output_only_as_host_content * * @param callable $make_state Callable returning the state to set. * @param string $printed How `state.html` is expected to print in the client data. @@ -232,7 +232,7 @@ public function test_token_reaches_the_output_only_as_host_content( callable $ma * * @return array Data provider. */ - public static function data_ways_to_reach_a_token(): array { + public static function data_token_reaches_the_output_only_as_host_content(): array { return array( 'token in state' => array( static function () { @@ -276,7 +276,7 @@ static function () { * @covers ::process_directives * @covers wp_interactivity_as_dangerous_html * - * @dataProvider data_html_strings + * @dataProvider data_html_strings_render_byte_for_byte * * @param string $html The trusted HTML. */ @@ -297,7 +297,7 @@ public function test_html_strings_render_byte_for_byte( string $html ) { * * @return array Data provider. */ - public static function data_html_strings(): array { + public static function data_html_strings_render_byte_for_byte(): array { return array( 'attributes and entities' => array( '
<tag>  Ã©
' ), 'empty string' => array( '' ), @@ -363,7 +363,7 @@ public function test_host_resolves_in_its_own_context() { * @covers ::process_directives * @covers WP_Interactivity_Dangerous_HTML::get_html * - * @dataProvider data_values_that_are_not_tokens + * @dataProvider data_value_that_is_not_a_token_empties_the_host_with_one_notice * * @param string $attributes The attributes of the host. * @param array $state The state of the `test` namespace. @@ -386,7 +386,7 @@ public function test_value_that_is_not_a_token_empties_the_host_with_one_notice( * * @return array Data provider. */ - public static function data_values_that_are_not_tokens(): array { + public static function data_value_that_is_not_a_token_empties_the_host_with_one_notice(): array { $token = wp_interactivity_as_dangerous_html( '

Hi

' ); return array( @@ -427,7 +427,7 @@ public function jsonSerialize(): array { * * @covers ::process_directives * - * @dataProvider data_references_that_resolve_to_nothing + * @dataProvider data_reference_that_resolves_to_nothing_empties_the_host_without_notice * * @param string $attributes The attributes of the host. */ @@ -452,7 +452,7 @@ public function test_reference_that_resolves_to_nothing_empties_the_host_without * * @return array Data provider. */ - public static function data_references_that_resolve_to_nothing(): array { + public static function data_reference_that_resolves_to_nothing_empties_the_host_without_notice(): array { return array( 'null in state' => array( 'data-wp-html="state.nul"' ), 'missing path' => array( 'data-wp-html="state.missing"' ), @@ -473,7 +473,7 @@ public static function data_references_that_resolve_to_nothing(): array { * * @covers ::process_directives * - * @dataProvider data_references_whose_evaluation_fails + * @dataProvider data_failed_evaluation_empties_the_host_without_a_data_wp_html_notice * * @param string $input The HTML to process. * @param string $expected The expected output. @@ -498,7 +498,7 @@ public function test_failed_evaluation_empties_the_host_without_a_data_wp_html_n * * @return array Data provider. */ - public static function data_references_whose_evaluation_fails(): array { + public static function data_failed_evaluation_empties_the_host_without_a_data_wp_html_notice(): array { return array( 'throwing closure' => array( '
' . self::CHILDREN . '
', @@ -525,7 +525,7 @@ public static function data_references_whose_evaluation_fails(): array { * * @covers ::process_directives * - * @dataProvider data_islands_that_name_no_namespace + * @dataProvider data_host_under_an_island_that_names_no_namespace_is_emptied * * @param string $island The attributes of the inner `data-wp-interactive` element. */ @@ -549,7 +549,7 @@ public function test_host_under_an_island_that_names_no_namespace_is_emptied( st * * @return array Data provider. */ - public static function data_islands_that_name_no_namespace(): array { + public static function data_host_under_an_island_that_names_no_namespace_is_emptied(): array { return array( 'no value' => array( 'data-wp-interactive' ), 'object without a namespace' => array( 'data-wp-interactive=\'{"a":1}\'' ), @@ -591,7 +591,7 @@ public function test_host_under_a_unique_id_interactive_directive_keeps_the_encl * * @covers ::process_directives * - * @dataProvider data_directives_that_conflict + * @dataProvider data_conflicting_directive_ignores_data_wp_html_with_one_notice * * @param string $host The host markup. * @param string $expected The expected host markup. @@ -622,7 +622,7 @@ public function test_conflicting_directive_ignores_data_wp_html_with_one_notice( * * @return array Data provider. */ - public static function data_directives_that_conflict(): array { + public static function data_conflicting_directive_ignores_data_wp_html_with_one_notice(): array { return array( 'data-wp-text' => array( '
Fallback
', @@ -669,7 +669,7 @@ public static function data_directives_that_conflict(): array { * * @covers ::process_directives * - * @dataProvider data_directives_the_client_drops + * @dataProvider data_directive_the_client_drops_is_ignored * * @param string $host The host markup. * @param string $expected The expected host markup. @@ -689,7 +689,7 @@ public function test_directive_the_client_drops_is_ignored( string $host, string * * @return array Data provider. */ - public static function data_directives_the_client_drops(): array { + public static function data_directive_the_client_drops_is_ignored(): array { return array( 'reserved namespace in the value' => array( '
' . self::CHILDREN . '
', @@ -799,7 +799,7 @@ public function test_unique_id_entry_does_not_prevent_processing_children() { * * @covers ::process_directives * - * @dataProvider data_hosts_that_cannot_hold_html + * @dataProvider data_host_that_cannot_hold_html * * @param string $host The host markup. * @param string $expected The expected host markup. @@ -836,7 +836,7 @@ public function test_host_that_cannot_hold_html( string $host, string $expected, * * @return array Data provider. */ - public static function data_hosts_that_cannot_hold_html(): array { + public static function data_host_that_cannot_hold_html(): array { $cases = array(); $attributes = array( 'null' => 'data-wp-html="state.nul"', @@ -922,7 +922,7 @@ public function test_hosts_beyond_the_seek_limit_render() { * * @covers ::process_directives * - * @dataProvider data_ways_to_make_a_nested_call + * @dataProvider data_nested_call_keeps_the_outer_call_processing * * @param callable $make_value Callable that receives a callable making the nested call, and * returns the value of `state.inner` whose `markup` is its result. @@ -961,7 +961,7 @@ static function () { * * @return array Data provider. */ - public static function data_ways_to_make_a_nested_call(): array { + public static function data_nested_call_keeps_the_outer_call_processing(): array { return array( 'derived-state closure' => array( static function ( callable $render ) { diff --git a/tests/phpunit/tests/interactivity-api/wpInteractivityAPIFunctions.php b/tests/phpunit/tests/interactivity-api/wpInteractivityAPIFunctions.php index 678db25bc136c..feb679e70e91e 100644 --- a/tests/phpunit/tests/interactivity-api/wpInteractivityAPIFunctions.php +++ b/tests/phpunit/tests/interactivity-api/wpInteractivityAPIFunctions.php @@ -699,7 +699,7 @@ public function test_state_is_included_in_script_module_data() { * * @ticket 65893 * - * @dataProvider data_original_global_instance_runs + * @dataProvider data_original_global_instance_is_restored_after_tear_down * * @param string $store_namespace Store namespace to set state for. */ @@ -723,7 +723,7 @@ public function test_original_global_instance_is_restored_after_tear_down( $stor * * @return array */ - public static function data_original_global_instance_runs() { + public static function data_original_global_instance_is_restored_after_tear_down() { return array( 'first run' => array( 'isolationTest' ), 'second run' => array( 'isolationTest' ), diff --git a/tests/phpunit/tests/json-schema.php b/tests/phpunit/tests/json-schema.php index 6e52cdfc6e1ce..cb3b3ac852369 100644 --- a/tests/phpunit/tests/json-schema.php +++ b/tests/phpunit/tests/json-schema.php @@ -138,6 +138,25 @@ public function test_wp_prepare_json_schema_for_client_normalizes_schema_for_cli $this->assertArrayNotHasKey( 'sanitize_callback', $prepared['additionalProperties'] ); } + /** + * Tests that an empty default on an object schema is sent to clients as a JSON object. + * + * An empty PHP array is encoded as `[]`, which does not match an object schema. + * Defaults that allow arrays stay unchanged. + * + * @ticket 66267 + * + * @dataProvider data_wp_prepare_json_schema_for_client_encodes_default + * + * @param array $schema The schema to prepare. + * @param string $expected The expected JSON for the default. + */ + public function test_wp_prepare_json_schema_for_client_encodes_default( $schema, $expected ) { + $prepared = wp_prepare_json_schema_for_client( $schema ); + + $this->assertSame( $expected, wp_json_encode( $prepared['default'] ) ); + } + /** * Data provider. * @@ -197,25 +216,6 @@ public static function data_wp_prepare_json_schema_for_client_encodes_default() ); } - /** - * Tests that an empty default on an object schema is sent to clients as a JSON object. - * - * An empty PHP array is encoded as `[]`, which does not match an object schema. - * Defaults that allow arrays stay unchanged. - * - * @ticket 66267 - * - * @dataProvider data_wp_prepare_json_schema_for_client_encodes_default - * - * @param array $schema The schema to prepare. - * @param string $expected The expected JSON for the default. - */ - public function test_wp_prepare_json_schema_for_client_encodes_default( $schema, $expected ) { - $prepared = wp_prepare_json_schema_for_client( $schema ); - - $this->assertSame( $expected, wp_json_encode( $prepared['default'] ) ); - } - /** * Tests that defaults use the same preparation as other JSON values. * @@ -872,20 +872,6 @@ public function test_wp_prepare_json_value_for_client( $value, $schema, $expecte $this->assertSame( $expected, wp_json_encode( $prepared ) ); } - /** - * Data provider for test_nested_array_branch_preference(). - * - * @return array - */ - public static function data_nested_array_branch_preference() { - return array( - 'anyOf within anyOf, empty' => array( 'anyOf', 'anyOf', array() ), - 'oneOf within oneOf, empty' => array( 'oneOf', 'oneOf', array() ), - 'oneOf within anyOf, list' => array( 'anyOf', 'oneOf', array( array() ) ), - 'anyOf within oneOf, list' => array( 'oneOf', 'anyOf', array( array() ) ), - ); - } - /** * Tests that array preference requires a matching nested array branch. * @@ -930,6 +916,20 @@ public function test_nested_array_branch_preference( $outer_keyword, $inner_keyw ); } + /** + * Data provider for test_nested_array_branch_preference(). + * + * @return array + */ + public static function data_nested_array_branch_preference() { + return array( + 'anyOf within anyOf, empty' => array( 'anyOf', 'anyOf', array() ), + 'oneOf within oneOf, empty' => array( 'oneOf', 'oneOf', array() ), + 'oneOf within anyOf, list' => array( 'anyOf', 'oneOf', array( array() ) ), + 'anyOf within oneOf, list' => array( 'oneOf', 'anyOf', array( array() ) ), + ); + } + /** * Tests that nested JSON values are prepared using their sub-schemas. * @@ -1021,6 +1021,21 @@ public function test_wp_prepare_json_value_for_client_uses_pattern_properties() $this->assertSame( '{"item-1":{}}', wp_json_encode( $prepared ) ); } + /** + * Tests whether a value matches a schema through a given type. + * + * @ticket 66267 + * @dataProvider data_wp_json_schema_matches_type + * + * @param mixed $value The value to validate. + * @param array $schema The schema to inspect. + * @param string $type The type to match. + * @param bool $expected Whether the value is expected to match. + */ + public function test_wp_json_schema_matches_type( $value, $schema, $type, $expected ) { + $this->assertSame( $expected, _wp_json_schema_matches_type( $value, $schema, $type ) ); + } + /** * Data provider for test_wp_json_schema_matches_type(). * @@ -1051,19 +1066,4 @@ public static function data_wp_json_schema_matches_type() { ), ); } - - /** - * Tests whether a value matches a schema through a given type. - * - * @ticket 66267 - * @dataProvider data_wp_json_schema_matches_type - * - * @param mixed $value The value to validate. - * @param array $schema The schema to inspect. - * @param string $type The type to match. - * @param bool $expected Whether the value is expected to match. - */ - public function test_wp_json_schema_matches_type( $value, $schema, $type, $expected ) { - $this->assertSame( $expected, _wp_json_schema_matches_type( $value, $schema, $type ) ); - } } diff --git a/tests/phpunit/tests/kses.php b/tests/phpunit/tests/kses.php index 4fe2eb69b197b..a8f63d11b44ca 100644 --- a/tests/phpunit/tests/kses.php +++ b/tests/phpunit/tests/kses.php @@ -113,7 +113,7 @@ public static function data_wp_filter_post_kses_a() { * * @ticket 65984 * - * @dataProvider data_wp_kses_idempotent_inputs + * @dataProvider data_wp_kses_is_idempotent * * @param string $input Process this HTML. * @param array|null $allowed_html Optional. If provided, will be passed into `wp_kses()`. @@ -137,7 +137,7 @@ public function test_wp_kses_is_idempotent( string $input, ?array $allowed_html * * @return array[] */ - public static function data_wp_kses_idempotent_inputs(): array { + public static function data_wp_kses_is_idempotent(): array { return array( array( '
a < b
', diff --git a/tests/phpunit/tests/kses/wpKsesCheckAttrVal.php b/tests/phpunit/tests/kses/wpKsesCheckAttrVal.php index d02af65d96695..4322a12f2d6b5 100644 --- a/tests/phpunit/tests/kses/wpKsesCheckAttrVal.php +++ b/tests/phpunit/tests/kses/wpKsesCheckAttrVal.php @@ -14,7 +14,7 @@ class Tests_Kses_wpKsesCheckAttrVal extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_attribute_value_checks + * @dataProvider data_wp_kses_check_attr_val * * @param string $value Attribute value. * @param string $vless Whether the attribute is valueless, 'y' or 'n'. @@ -31,7 +31,7 @@ public function test_wp_kses_check_attr_val( $value, $vless, $checkname, $checkv * * @return array[] */ - public static function data_attribute_value_checks() { + public static function data_wp_kses_check_attr_val() { return array( // maxlen. 'maxlen: shorter value' => array( 'ab', 'n', 'maxlen', 3, true ), diff --git a/tests/phpunit/tests/l10n/wpTextdomainRegistry.php b/tests/phpunit/tests/l10n/wpTextdomainRegistry.php index 2da233049f579..d3a25e936105e 100644 --- a/tests/phpunit/tests/l10n/wpTextdomainRegistry.php +++ b/tests/phpunit/tests/l10n/wpTextdomainRegistry.php @@ -332,7 +332,7 @@ public function test_has_after_custom_path_is_registered_following_an_unsuccessf * * @covers ::get * @covers ::has - * @dataProvider data_text_domains_sharing_a_prefix + * @dataProvider data_translations_are_not_shared_between_text_domains_with_a_common_prefix * * @param string $domain Text domain that has no translations of its own. * @param string $locale Locale to look up. @@ -349,7 +349,7 @@ public function test_translations_are_not_shared_between_text_domains_with_a_com * * @return array[] */ - public static function data_text_domains_sharing_a_prefix() { + public static function data_translations_are_not_shared_between_text_domains_with_a_common_prefix() { return array( // "internationalized-plugin-{de_DE,es_ES}.mo" exist, "internationalized-*" do not. 'prefix of a domain with .mo files' => array( 'internationalized', 'de_DE' ), diff --git a/tests/phpunit/tests/link/editCommentLink.php b/tests/phpunit/tests/link/editCommentLink.php index d4c6fba28fd63..bde302d1f4ee4 100644 --- a/tests/phpunit/tests/link/editCommentLink.php +++ b/tests/phpunit/tests/link/editCommentLink.php @@ -93,7 +93,7 @@ public function test_should_output_custom_link_text() { * * @ticket 65819 * - * @dataProvider data_before_and_after_markup + * @dataProvider data_should_prepend_and_append_markup * * @param string $before The markup to prepend. * @param string $after The markup to append. @@ -112,7 +112,7 @@ public function test_should_prepend_and_append_markup( $before, $after ) { * * @return array> */ - public static function data_before_and_after_markup() { + public static function data_should_prepend_and_append_markup() { return array( 'paragraph tags' => array( '

', '

' ), ); diff --git a/tests/phpunit/tests/link/getEditUserLink.php b/tests/phpunit/tests/link/getEditUserLink.php index a64dfb5f7c7ba..1a00a43d01198 100644 --- a/tests/phpunit/tests/link/getEditUserLink.php +++ b/tests/phpunit/tests/link/getEditUserLink.php @@ -152,7 +152,7 @@ public function test_get_edit_user_link_logged_out_returns_empty_string() { * * @ticket 65819 * - * @dataProvider data_non_existent_user_ids + * @dataProvider data_get_edit_user_link_non_existent_user * * @param int $user_id Non-existent user ID. */ @@ -165,7 +165,7 @@ public function test_get_edit_user_link_non_existent_user( $user_id ) { * * @return array[] */ - public static function data_non_existent_user_ids() { + public static function data_get_edit_user_link_non_existent_user() { return array( 'negative ID' => array( -1 ), 'large non-existent ID' => array( 9999999 ), @@ -177,7 +177,7 @@ public static function data_non_existent_user_ids() { * * @ticket 65819 * - * @dataProvider data_falsy_user_ids + * @dataProvider data_get_edit_user_link_falsy_id_falls_back_to_current_user * * @param mixed $falsy_id Falsy user ID. */ @@ -192,7 +192,7 @@ public function test_get_edit_user_link_falsy_id_falls_back_to_current_user( $fa * * @return array[] */ - public static function data_falsy_user_ids() { + public static function data_get_edit_user_link_falsy_id_falls_back_to_current_user() { return array( 'zero int' => array( 0 ), 'zero string' => array( '0' ), diff --git a/tests/phpunit/tests/link/getSearchLink.php b/tests/phpunit/tests/link/getSearchLink.php index 863a20810eafc..38254228203c4 100644 --- a/tests/phpunit/tests/link/getSearchLink.php +++ b/tests/phpunit/tests/link/getSearchLink.php @@ -29,7 +29,7 @@ public function tear_down() { * Tests get_search_link() with plain permalinks and explicit query. * * @ticket 65819 - * @dataProvider data_plain_permastruct_queries + * @dataProvider data_get_search_link_plain_permastruct * * @param string $query Search query string. * @param string $expected Expected query parameter. @@ -45,7 +45,7 @@ public function test_get_search_link_plain_permastruct( $query, $expected ) { * * @return array */ - public static function data_plain_permastruct_queries() { + public static function data_get_search_link_plain_permastruct() { return array( 'special characters' => array( 'core & test', 'core+%26+test' ), 'slashes to be stripped' => array( "single\'quote", 'single%27quote' ), @@ -56,7 +56,7 @@ public static function data_plain_permastruct_queries() { * Tests get_search_link() with pretty permalinks. * * @ticket 65819 - * @dataProvider data_pretty_permastruct_queries + * @dataProvider data_get_search_link_pretty_permastruct * * @param string $query Search query string. * @param string $expected Expected path relative to home_url(). @@ -70,7 +70,7 @@ public function test_get_search_link_pretty_permastruct( $query, $expected ) { * * @return array */ - public static function data_pretty_permastruct_queries() { + public static function data_get_search_link_pretty_permastruct() { return array( 'words with spaces' => array( 'hello world', '/search/hello+world/' ), 'forward slash kept' => array( 'tag/subtag', '/search/tag/subtag/' ), diff --git a/tests/phpunit/tests/link/permalinkAnchor.php b/tests/phpunit/tests/link/permalinkAnchor.php index 1dc877335037d..ab6568950d722 100644 --- a/tests/phpunit/tests/link/permalinkAnchor.php +++ b/tests/phpunit/tests/link/permalinkAnchor.php @@ -92,7 +92,7 @@ public function test_permalink_anchor_mode_title_with_special_characters() { * * @ticket 65819 * - * @dataProvider data_unrecognized_modes + * @dataProvider data_permalink_anchor_unrecognized_mode_falls_back_to_id * * @param string $mode Mode to pass. */ @@ -107,7 +107,7 @@ public function test_permalink_anchor_unrecognized_mode_falls_back_to_id( $mode * * @return array[] */ - public static function data_unrecognized_modes() { + public static function data_permalink_anchor_unrecognized_mode_falls_back_to_id() { return array( 'arbitrary string' => array( 'custom' ), ); diff --git a/tests/phpunit/tests/link/theShortlink.php b/tests/phpunit/tests/link/theShortlink.php index c5534db65c402..6706e25535867 100644 --- a/tests/phpunit/tests/link/theShortlink.php +++ b/tests/phpunit/tests/link/theShortlink.php @@ -64,7 +64,7 @@ public function test_the_shortlink_default_text() { * * @ticket 65819 * - * @dataProvider data_custom_text + * @dataProvider data_the_shortlink_custom_text * * @param string $text Custom link text. */ @@ -76,6 +76,17 @@ public function test_the_shortlink_custom_text( $text ) { the_shortlink( $text ); } + /** + * Data provider of custom text values. + * + * @return array[] + */ + public static function data_the_shortlink_custom_text() { + return array( + 'html text' => array( 'Shortlink' ), + ); + } + /** * Tests that the_shortlink() outputs before and after markup around the anchor. * @@ -172,15 +183,4 @@ public function test_the_shortlink_outputs_nothing_when_shortlink_is_empty() { remove_filter( 'pre_get_shortlink', $filter ); } - - /** - * Data provider of custom text values. - * - * @return array[] - */ - public static function data_custom_text() { - return array( - 'html text' => array( 'Shortlink' ), - ); - } } diff --git a/tests/phpunit/tests/link/wpIsInternalLink.php b/tests/phpunit/tests/link/wpIsInternalLink.php index 2934a29498964..96a3dbbcf8245 100644 --- a/tests/phpunit/tests/link/wpIsInternalLink.php +++ b/tests/phpunit/tests/link/wpIsInternalLink.php @@ -55,7 +55,7 @@ static function ( $hosts ) { * * @ticket 65819 * - * @dataProvider data_internal_links + * @dataProvider data_wp_is_internal_link_returns_true_for_internal_urls * * @param string $scheme_and_path URL format with a `%s` placeholder for the home host. */ @@ -71,7 +71,7 @@ public function test_wp_is_internal_link_returns_true_for_internal_urls( $scheme * * @return array[] */ - public static function data_internal_links() { + public static function data_wp_is_internal_link_returns_true_for_internal_urls() { return array( 'http' => array( 'http://%s/sample-page/' ), 'https' => array( 'https://%s/sample-page/' ), @@ -95,7 +95,7 @@ public function test_wp_is_internal_link_is_case_insensitive_for_host() { * * @ticket 65819 * - * @dataProvider data_external_links + * @dataProvider data_wp_is_internal_link_returns_false_for_external_urls * * @param string $link URL to test. */ @@ -108,7 +108,7 @@ public function test_wp_is_internal_link_returns_false_for_external_urls( $link * * @return array[] */ - public static function data_external_links() { + public static function data_wp_is_internal_link_returns_false_for_external_urls() { return array( 'external https' => array( 'https://example.net/page/' ), 'external http' => array( 'http://wordpress.org/' ), diff --git a/tests/phpunit/tests/load/timerFloat.php b/tests/phpunit/tests/load/timerFloat.php index 4cff0c97050cc..ccd4ef8f775df 100644 --- a/tests/phpunit/tests/load/timerFloat.php +++ b/tests/phpunit/tests/load/timerFloat.php @@ -35,7 +35,7 @@ public function tear_down() { /** * @ticket 65819 * - * @dataProvider data_request_ages + * @dataProvider data_returns_elapsed_seconds_as_float * * @param float $request_age Age of the request in seconds. * @param float $minimum_elapsed Minimum expected elapsed seconds. @@ -53,7 +53,7 @@ public function test_returns_elapsed_seconds_as_float( $request_age, $minimum_el /** * @return array[] */ - public static function data_request_ages() { + public static function data_returns_elapsed_seconds_as_float() { return array( 'recent request' => array( 1.25, 1.25 ), 'older request' => array( 10.0, 10.0 ), diff --git a/tests/phpunit/tests/load/wpGetEnvironmentType.php b/tests/phpunit/tests/load/wpGetEnvironmentType.php index 733d029bcc69e..2988dac1f72ca 100644 --- a/tests/phpunit/tests/load/wpGetEnvironmentType.php +++ b/tests/phpunit/tests/load/wpGetEnvironmentType.php @@ -29,7 +29,7 @@ public function test_defaults_to_production_when_unset() { /** * @ticket 65819 * - * @dataProvider data_valid_environment_types + * @dataProvider data_returns_valid_environment_type_from_constant * * @runInSeparateProcess * @preserveGlobalState disabled @@ -47,7 +47,7 @@ public function test_returns_valid_environment_type_from_constant( $environment * * @return array[] */ - public static function data_valid_environment_types(): array { + public static function data_returns_valid_environment_type_from_constant(): array { return array( 'local' => array( 'local' ), 'development' => array( 'development' ), diff --git a/tests/phpunit/tests/load/wpIsFileModAllowed.php b/tests/phpunit/tests/load/wpIsFileModAllowed.php index c69a58fa4fbe1..db46a4029d251 100644 --- a/tests/phpunit/tests/load/wpIsFileModAllowed.php +++ b/tests/phpunit/tests/load/wpIsFileModAllowed.php @@ -44,7 +44,7 @@ public function test_returns_true_when_disallow_file_mods_is_false() { /** * @ticket 65819 * - * @dataProvider data_contexts + * @dataProvider data_passes_context_to_filter * * @param string $context Context passed to the function. */ @@ -67,7 +67,7 @@ public function test_passes_context_to_filter( $context ) { * * @return array[] */ - public static function data_contexts(): array { + public static function data_passes_context_to_filter(): array { return array( 'install_plugins' => array( 'install_plugins' ), 'automatic_updater' => array( 'automatic_updater' ), diff --git a/tests/phpunit/tests/load/wpIsJsonRequest.php b/tests/phpunit/tests/load/wpIsJsonRequest.php index dd2352d03f8ce..cc5702b0cb945 100644 --- a/tests/phpunit/tests/load/wpIsJsonRequest.php +++ b/tests/phpunit/tests/load/wpIsJsonRequest.php @@ -69,7 +69,7 @@ public function test_returns_false_for_non_json_headers() { * * @ticket 65819 * - * @dataProvider data_json_accept_headers + * @dataProvider data_returns_true_for_json_accept_header * * @param string $accept Accept header value. */ @@ -85,7 +85,7 @@ public function test_returns_true_for_json_accept_header( $accept ) { * * @return array[] */ - public static function data_json_accept_headers() { + public static function data_returns_true_for_json_accept_header() { return array( 'application/json' => array( 'application/json' ), 'vendor json' => array( 'application/vnd.api+json' ), @@ -98,7 +98,7 @@ public static function data_json_accept_headers() { * * @ticket 65819 * - * @dataProvider data_json_content_types + * @dataProvider data_returns_true_for_json_content_type * * @param string $content_type Content-Type header value. */ @@ -114,7 +114,7 @@ public function test_returns_true_for_json_content_type( $content_type ) { * * @return array[] */ - public static function data_json_content_types() { + public static function data_returns_true_for_json_content_type() { return array( 'application/json' => array( 'application/json' ), 'vendor json' => array( 'application/vnd.api+json' ), diff --git a/tests/phpunit/tests/load/wpIsJsonpRequest.php b/tests/phpunit/tests/load/wpIsJsonpRequest.php index 6d24a974f6a45..3cedaf7e91490 100644 --- a/tests/phpunit/tests/load/wpIsJsonpRequest.php +++ b/tests/phpunit/tests/load/wpIsJsonpRequest.php @@ -80,7 +80,7 @@ public function test_returns_true_for_dotted_jsonp_callback() { * * @ticket 65819 * - * @dataProvider data_invalid_jsonp_callbacks + * @dataProvider data_returns_false_for_invalid_jsonp_callback * * @param mixed $callback Invalid callback value. */ @@ -95,7 +95,7 @@ public function test_returns_false_for_invalid_jsonp_callback( $callback ) { * * @return array[] */ - public static function data_invalid_jsonp_callbacks() { + public static function data_returns_false_for_invalid_jsonp_callback() { return array( 'parentheses' => array( 'alert(1)' ), 'spaces' => array( 'my callback' ), diff --git a/tests/phpunit/tests/load/wpIsXmlRequest.php b/tests/phpunit/tests/load/wpIsXmlRequest.php index 2a59de544e9c5..cc0bd315b6e25 100644 --- a/tests/phpunit/tests/load/wpIsXmlRequest.php +++ b/tests/phpunit/tests/load/wpIsXmlRequest.php @@ -69,7 +69,7 @@ public function test_returns_false_for_non_xml_headers() { * * @ticket 65819 * - * @dataProvider data_xml_accept_headers + * @dataProvider data_returns_true_for_xml_accept_header * * @param string $accept Accept header value. */ @@ -85,7 +85,7 @@ public function test_returns_true_for_xml_accept_header( $accept ) { * * @return array[] */ - public static function data_xml_accept_headers() { + public static function data_returns_true_for_xml_accept_header() { return array( 'text/xml' => array( 'text/xml' ), 'application/rss+xml' => array( 'application/rss+xml' ), @@ -102,7 +102,7 @@ public static function data_xml_accept_headers() { * * @ticket 65819 * - * @dataProvider data_xml_content_types + * @dataProvider data_returns_true_for_xml_content_type * * @param string $content_type Content-Type header value. */ @@ -118,7 +118,7 @@ public function test_returns_true_for_xml_content_type( $content_type ) { * * @return array[] */ - public static function data_xml_content_types() { + public static function data_returns_true_for_xml_content_type() { return array( 'text/xml' => array( 'text/xml' ), 'application/rss+xml' => array( 'application/rss+xml' ), diff --git a/tests/phpunit/tests/media.php b/tests/phpunit/tests/media.php index af84065113267..3d2322e95055d 100644 --- a/tests/phpunit/tests/media.php +++ b/tests/phpunit/tests/media.php @@ -6283,7 +6283,7 @@ public function test_quality_with_image_conversion_file_sizes() { * Test AVIF quality filters for both Imagick and GD when AVIF support is available. * * @ticket 61614 - * @dataProvider data_test_quality_with_avif_conversion_file_sizes + * @dataProvider data_quality_with_avif_conversion_file_sizes */ public function test_quality_with_avif_conversion_file_sizes( string $editor_class ): void { // Set the engine for this test. @@ -6349,7 +6349,7 @@ function () use ( $editor_class ) { * * @return array}> Array of arrays, each containing an editor class name. */ - public static function data_test_quality_with_avif_conversion_file_sizes(): array { + public static function data_quality_with_avif_conversion_file_sizes(): array { return array( 'Imagick' => array( 'WP_Image_Editor_Imagick' ), 'GD' => array( 'WP_Image_Editor_GD' ), diff --git a/tests/phpunit/tests/media/getMediaEmbeddedInContent.php b/tests/phpunit/tests/media/getMediaEmbeddedInContent.php index 286abb8d7efb0..f06a42f617a5a 100644 --- a/tests/phpunit/tests/media/getMediaEmbeddedInContent.php +++ b/tests/phpunit/tests/media/getMediaEmbeddedInContent.php @@ -11,7 +11,7 @@ class Tests_Media_GetMediaEmbeddedInContent extends WP_UnitTestCase { /** * @ticket 65931 * - * @dataProvider data_content + * @dataProvider data_returns_expected_media * * @param string $content Content to search for media elements. * @param string[]|null $types Media types to limit the search to. @@ -26,7 +26,7 @@ public function test_returns_expected_media( $content, $types, $expected ) { * * @return array[] */ - public static function data_content() { + public static function data_returns_expected_media() { $audio = ''; $video = ''; $iframe = ''; diff --git a/tests/phpunit/tests/media/wpCrossOriginIsolation.php b/tests/phpunit/tests/media/wpCrossOriginIsolation.php index 64884b4e284f9..f63a0830e3ab6 100644 --- a/tests/phpunit/tests/media/wpCrossOriginIsolation.php +++ b/tests/phpunit/tests/media/wpCrossOriginIsolation.php @@ -354,7 +354,7 @@ public function test_deprecated_output_buffer_helper_does_not_buffer() { * * @expectedDeprecated wp_add_crossorigin_attributes * - * @dataProvider data_cross_origin_elements + * @dataProvider data_deprecated_attribute_injector_returns_html_unchanged * * @param string $html HTML input to process. */ @@ -367,7 +367,7 @@ public function test_deprecated_attribute_injector_returns_html_unchanged( strin * * @return array */ - public static function data_cross_origin_elements(): array { + public static function data_deprecated_attribute_injector_returns_html_unchanged(): array { return array( 'cross-origin script' => array( '', diff --git a/tests/phpunit/tests/media/wpExpandDimensions.php b/tests/phpunit/tests/media/wpExpandDimensions.php index 6e60663941132..b811a077a6c9b 100644 --- a/tests/phpunit/tests/media/wpExpandDimensions.php +++ b/tests/phpunit/tests/media/wpExpandDimensions.php @@ -14,7 +14,7 @@ class Tests_Media_WpExpandDimensions extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_expand_dimensions + * @dataProvider data_expands_example_to_max_bounds * * @param int|string $example_width Example width. * @param int|string $example_height Example height. @@ -34,7 +34,7 @@ public function test_expands_example_to_max_bounds( $example_width, $example_hei * * @return array[] */ - public static function data_expand_dimensions() { + public static function data_expands_example_to_max_bounds() { return array( 'matching 4:3 ratio fills the box' => array( 4, 3, 1024, 768, array( 1024, 768 ) ), 'landscape 16:9 limited by width' => array( 16, 9, 1024, 768, array( 1024, 576 ) ), diff --git a/tests/phpunit/tests/menu/isNavMenu.php b/tests/phpunit/tests/menu/isNavMenu.php index 1912ef69a5554..da430139bce95 100644 --- a/tests/phpunit/tests/menu/isNavMenu.php +++ b/tests/phpunit/tests/menu/isNavMenu.php @@ -26,7 +26,7 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) { * * @ticket 65819 * - * @dataProvider data_ways_to_identify_a_menu + * @dataProvider data_should_return_true_for_an_existing_menu * * @param string $field The menu field to identify the menu by. */ @@ -41,7 +41,7 @@ public function test_should_return_true_for_an_existing_menu( $field ) { * * @return array[] */ - public static function data_ways_to_identify_a_menu() { + public static function data_should_return_true_for_an_existing_menu() { return array( 'ID' => array( 'term_id' ), 'slug' => array( 'slug' ), @@ -92,7 +92,7 @@ public static function data_empty_values() { * * @ticket 65819 * - * @dataProvider data_unknown_menus + * @dataProvider data_should_return_false_for_an_unknown_menu * * @param int|string $menu A value that does not identify a menu. */ @@ -105,7 +105,7 @@ public function test_should_return_false_for_an_unknown_menu( $menu ) { * * @return array[] */ - public static function data_unknown_menus() { + public static function data_should_return_false_for_an_unknown_menu() { return array( 'ID' => array( PHP_INT_MAX ), 'slug' => array( 'no-such-menu' ), diff --git a/tests/phpunit/tests/menu/isNavMenuItem.php b/tests/phpunit/tests/menu/isNavMenuItem.php index 8b7ee6269a1b3..c47b585c06138 100644 --- a/tests/phpunit/tests/menu/isNavMenuItem.php +++ b/tests/phpunit/tests/menu/isNavMenuItem.php @@ -53,7 +53,7 @@ public function test_should_return_true_for_a_menu_item_post_object() { * * @ticket 65819 * - * @dataProvider data_other_post_types + * @dataProvider data_should_return_false_for_another_post_type * * @param string $post_type Post type. */ @@ -68,7 +68,7 @@ public function test_should_return_false_for_another_post_type( $post_type ) { * * @return array[] */ - public static function data_other_post_types() { + public static function data_should_return_false_for_another_post_type() { return array( 'post' => array( 'post' ), 'page' => array( 'page' ), diff --git a/tests/phpunit/tests/meta/wpMetadataLazyloader.php b/tests/phpunit/tests/meta/wpMetadataLazyloader.php index 119efb60b70f5..e2bd00d26e4d0 100644 --- a/tests/phpunit/tests/meta/wpMetadataLazyloader.php +++ b/tests/phpunit/tests/meta/wpMetadataLazyloader.php @@ -54,7 +54,7 @@ public function set_up() { * @covers ::queue_objects * @covers ::reset_queue * - * @dataProvider data_invalid_object_types + * @dataProvider data_invalid_object_type_returns_wp_error * * @param mixed $object_type Object type. */ @@ -81,7 +81,7 @@ public function test_invalid_object_type_returns_wp_error( $object_type ) { * * @return array[] */ - public static function data_invalid_object_types() { + public static function data_invalid_object_type_returns_wp_error() { return array( 'post' => array( 'post' ), 'user' => array( 'user' ), @@ -183,7 +183,7 @@ public function test_queue_objects_fires_queued_objects_action() { * @covers ::lazyload_meta_callback * @covers ::queue_objects * - * @dataProvider data_check_values + * @dataProvider data_lazyload_meta_callback_primes_cache_of_queued_objects * * @param mixed $check Value passed through the metadata filter. */ @@ -205,7 +205,7 @@ public function test_lazyload_meta_callback_primes_cache_of_queued_objects( $che * * @return array[] */ - public static function data_check_values() { + public static function data_lazyload_meta_callback_primes_cache_of_queued_objects() { return array( 'null' => array( null ), 'false' => array( false ), @@ -260,7 +260,7 @@ public function test_lazyload_meta_callback_resets_queue() { * * @covers ::lazyload_meta_callback * - * @dataProvider data_meta_types_without_queued_objects + * @dataProvider data_lazyload_meta_callback_does_nothing_without_queued_objects_of_type * * @param string $meta_type Metadata type requested through the filter. */ @@ -280,7 +280,7 @@ public function test_lazyload_meta_callback_does_nothing_without_queued_objects_ * * @return array[] */ - public static function data_meta_types_without_queued_objects() { + public static function data_lazyload_meta_callback_does_nothing_without_queued_objects_of_type() { return array( 'type with an empty queue' => array( 'comment' ), 'type that was never queued' => array( 'blog' ), diff --git a/tests/phpunit/tests/multisite/upgradeNetwork.php b/tests/phpunit/tests/multisite/upgradeNetwork.php index b8c83da6748df..7c8f0db12ef4b 100644 --- a/tests/phpunit/tests/multisite/upgradeNetwork.php +++ b/tests/phpunit/tests/multisite/upgradeNetwork.php @@ -21,7 +21,7 @@ public static function set_up_before_class() { * * @ticket 65980 * - * @dataProvider data_can_compress_scripts_deletion + * @dataProvider data_can_compress_scripts_is_deleted_below_its_db_version * * @param int $db_version Database version being upgraded from. * @param bool $expect_deleted Whether the option should be deleted. @@ -46,7 +46,7 @@ public function test_can_compress_scripts_is_deleted_below_its_db_version( int $ * * @return array */ - public static function data_can_compress_scripts_deletion(): array { + public static function data_can_compress_scripts_is_deleted_below_its_db_version(): array { return array( 'upgrading from just below the 7.2 db version' => array( 'db_version' => 64485, diff --git a/tests/phpunit/tests/oembed/wpOembed.php b/tests/phpunit/tests/oembed/wpOembed.php index 6c8c61f3246dd..736d817a5d0c9 100644 --- a/tests/phpunit/tests/oembed/wpOembed.php +++ b/tests/phpunit/tests/oembed/wpOembed.php @@ -322,7 +322,7 @@ public function test_get_provider_handles_provider_without_regex_flag(): void { * * @covers ::get_provider * - * @dataProvider data_reverbnation_urls + * @dataProvider data_get_provider_uses_legacy_reverbnation_endpoint * * @param string $url ReverbNation URL. */ @@ -335,7 +335,7 @@ public function test_get_provider_uses_legacy_reverbnation_endpoint( $url ) { * * @return array[] */ - public static function data_reverbnation_urls() { + public static function data_get_provider_uses_legacy_reverbnation_endpoint() { return array( 'www subdomain' => array( 'https://www.reverbnation.com/artist/song/123' ), 'legacy subdomain' => array( 'https://legacy.reverbnation.com/artist/song/123' ), @@ -352,7 +352,7 @@ public static function data_reverbnation_urls() { * * @covers ::get_provider * - * @dataProvider data_someecards_urls + * @dataProvider data_get_provider_does_not_match_someecards * * @param string $url someecards.com URL. */ @@ -365,7 +365,7 @@ public function test_get_provider_does_not_match_someecards( $url ) { * * @return array[] */ - public static function data_someecards_urls() { + public static function data_get_provider_does_not_match_someecards() { return array( 'card' => array( 'https://www.someecards.com/birthday-cards/funny-birthday-card/' ), 'user card' => array( 'https://www.someecards.com/usercards/viewcard/MjAxMy0xMjM0NTY3ODk/' ), diff --git a/tests/phpunit/tests/phpunit/groupFilters.php b/tests/phpunit/tests/phpunit/groupFilters.php index 2ae59209af806..60d3e32122ce9 100644 --- a/tests/phpunit/tests/phpunit/groupFilters.php +++ b/tests/phpunit/tests/phpunit/groupFilters.php @@ -22,7 +22,7 @@ public function test_single_site_default_excluded_groups_are_reported() { } /** - * @dataProvider data_group_argument_syntax + * @dataProvider data_requested_group_is_not_reported_as_default_excluded * * @param string[] $arguments Command line arguments. */ @@ -40,7 +40,7 @@ public function test_requested_group_is_not_reported_as_default_excluded( $argum * * @return array>> */ - public static function data_group_argument_syntax() { + public static function data_requested_group_is_not_reported_as_default_excluded() { return array( 'spaced' => array( array( 'phpunit', '--group', 'ajax' ) ), 'equals' => array( array( 'phpunit', '--group=ajax' ) ), diff --git a/tests/phpunit/tests/post/getPageByPath.php b/tests/phpunit/tests/post/getPageByPath.php index cb8b8487fda7c..6dc94fac3fb92 100644 --- a/tests/phpunit/tests/post/getPageByPath.php +++ b/tests/phpunit/tests/post/getPageByPath.php @@ -63,7 +63,7 @@ public function test_should_match_top_level_page() { * @ticket 61996 * @covers ::get_page_by_path * - * @dataProvider data_page_post_types + * @dataProvider data_should_prefer_published_page_then_lowest_id * * @param string|string[] $post_type Post type argument. */ @@ -117,7 +117,7 @@ public function test_should_prefer_published_page_then_lowest_id( $post_type ) { * * @return array> { */ - public static function data_page_post_types(): array { + public static function data_should_prefer_published_page_then_lowest_id(): array { return array( 'string' => array( 'page' ), 'array of one type' => array( array( 'page' ) ), diff --git a/tests/phpunit/tests/post/getPostFormatString.php b/tests/phpunit/tests/post/getPostFormatString.php index f35512d2f8bee..6c64c16270e5d 100644 --- a/tests/phpunit/tests/post/getPostFormatString.php +++ b/tests/phpunit/tests/post/getPostFormatString.php @@ -15,7 +15,7 @@ class Tests_Post_GetPostFormatString extends WP_UnitTestCase { * * @covers ::get_post_format_string * - * @dataProvider data_post_format_strings + * @dataProvider data_get_post_format_string * * @param string $slug Post format slug. * @param string $expected Translated format label. @@ -29,7 +29,7 @@ public function test_get_post_format_string( $slug, $expected ) { * * @return array[] */ - public static function data_post_format_strings() { + public static function data_get_post_format_string() { return array( 'empty slug is standard' => array( '', 'Standard' ), 'known slug' => array( 'aside', 'Aside' ), diff --git a/tests/phpunit/tests/post/prependAttachment.php b/tests/phpunit/tests/post/prependAttachment.php index c95c9bc1ae0f7..45beadf580527 100644 --- a/tests/phpunit/tests/post/prependAttachment.php +++ b/tests/phpunit/tests/post/prependAttachment.php @@ -108,7 +108,7 @@ public function capture_shortcode_atts( $html, $atts ) { * * @covers ::prepend_attachment * - * @dataProvider data_not_an_attachment + * @dataProvider data_returns_content_unchanged_when_not_an_attachment * * @param bool $has_post Whether a regular post is the global post. */ @@ -123,7 +123,7 @@ public function test_returns_content_unchanged_when_not_an_attachment( $has_post * * @return array[] */ - public static function data_not_an_attachment() { + public static function data_returns_content_unchanged_when_not_an_attachment() { return array( 'regular post' => array( true ), 'no post' => array( false ), @@ -154,7 +154,7 @@ public function test_prepends_link_for_other_attachments() { * * @covers ::prepend_attachment * - * @dataProvider data_video_metadata + * @dataProvider data_prepends_video_shortcode * * @param array $metadata Attachment metadata. * @param array $dimensions Expected width and height attributes. @@ -175,7 +175,7 @@ public function test_prepends_video_shortcode( $metadata, $dimensions ) { * * @return array[] */ - public static function data_video_metadata() { + public static function data_prepends_video_shortcode() { return array( 'width and height as strings' => array( array( diff --git a/tests/phpunit/tests/post/theTitleAttribute.php b/tests/phpunit/tests/post/theTitleAttribute.php index 6c1ca02df653a..56cbd697ca84b 100644 --- a/tests/phpunit/tests/post/theTitleAttribute.php +++ b/tests/phpunit/tests/post/theTitleAttribute.php @@ -90,7 +90,7 @@ public function test_echoes_title_by_default() { * * @ticket 65819 * - * @dataProvider data_echo_false_arguments + * @dataProvider data_returns_title_when_echo_is_false * * @param array|string $echo_arg Arguments disabling echo. */ @@ -114,7 +114,7 @@ public function test_returns_title_when_echo_is_false( $echo_arg ) { * * @return array[] */ - public static function data_echo_false_arguments() { + public static function data_returns_title_when_echo_is_false() { return array( 'array with boolean false' => array( array( 'echo' => false ) ), 'query string with echo=0' => array( 'echo=0' ), diff --git a/tests/phpunit/tests/post/walkerPageDropdown.php b/tests/phpunit/tests/post/walkerPageDropdown.php index 29016e3ff584e..21e911b70fc5e 100644 --- a/tests/phpunit/tests/post/walkerPageDropdown.php +++ b/tests/phpunit/tests/post/walkerPageDropdown.php @@ -106,7 +106,7 @@ public static function data_start_el() { * * @covers ::start_el * - * @dataProvider data_page_titles + * @dataProvider data_start_el_displays_escaped_title * * @param string $post_title Page title. * @param string $expected Expected option text. @@ -126,7 +126,7 @@ public function test_start_el_displays_escaped_title( $post_title, $expected ) { * * @return array[] */ - public static function data_page_titles() { + public static function data_start_el_displays_escaped_title() { return array( 'title with markup' => array( 'Tom & Jerry "quoted"', 'Tom & <b>Jerry</b> "quoted"' ), 'empty title' => array( '', '#7 (no title)' ), @@ -178,7 +178,7 @@ public function test_start_el_appends_to_output() { * * @covers ::start_el * - * @dataProvider data_titles_for_list_pages_filter + * @dataProvider data_start_el_applies_list_pages_filter * * @param string $post_title Page title. * @param string $received Title the filter is expected to receive. @@ -211,7 +211,7 @@ static function () { * * @return array[] */ - public static function data_titles_for_list_pages_filter() { + public static function data_start_el_applies_list_pages_filter() { return array( 'page with a title' => array( 'About', 'About' ), 'page without a title' => array( '', '#7 (no title)' ), diff --git a/tests/phpunit/tests/post/wpListPages.php b/tests/phpunit/tests/post/wpListPages.php index 564106625211f..67b58050e5c2e 100644 --- a/tests/phpunit/tests/post/wpListPages.php +++ b/tests/phpunit/tests/post/wpListPages.php @@ -543,7 +543,7 @@ public function test_wp_list_pages_classes_with_hierarchical_cpt() { /** * @ticket 28801 - * @dataProvider data_wp_list_pages_omitted_ancestor + * @dataProvider data_wp_list_pages_preserves_hierarchy_when_menu_order_places_child_first * * @param int $depth Maximum depth to display. */ @@ -592,7 +592,7 @@ public function test_wp_list_pages_preserves_hierarchy_when_menu_order_places_ch * * @return array */ - public static function data_wp_list_pages_omitted_ancestor() { + public static function data_wp_list_pages_preserves_hierarchy_when_menu_order_places_child_first() { return array( 'unlimited depth' => array( 0 ), 'depth one' => array( 1 ), diff --git a/tests/phpunit/tests/privacy/wpPrivacyPolicyContentGetSuggestedPolicyText.php b/tests/phpunit/tests/privacy/wpPrivacyPolicyContentGetSuggestedPolicyText.php index c35c5fd8e40b3..28051bb99f3ab 100644 --- a/tests/phpunit/tests/privacy/wpPrivacyPolicyContentGetSuggestedPolicyText.php +++ b/tests/phpunit/tests/privacy/wpPrivacyPolicyContentGetSuggestedPolicyText.php @@ -319,7 +319,7 @@ public function test_marks_deactivated_plugin_as_removed() { * * @ticket 65819 * - * @dataProvider data_incomplete_entries + * @dataProvider data_leaves_out_incomplete_entries * * @param bool $is_registered Whether the entry is registered by a plugin, rather than stored. * @param array $entry Incomplete entry. @@ -340,7 +340,7 @@ public function test_leaves_out_incomplete_entries( $is_registered, $entry ) { * * @return array[] */ - public static function data_incomplete_entries() { + public static function data_leaves_out_incomplete_entries() { $no_name = array( 'plugin_name' => '', 'policy_text' => '

My policy.

', diff --git a/tests/phpunit/tests/query/randomContentRedirect.php b/tests/phpunit/tests/query/randomContentRedirect.php index a5a04107bb789..7de77a01058e3 100644 --- a/tests/phpunit/tests/query/randomContentRedirect.php +++ b/tests/phpunit/tests/query/randomContentRedirect.php @@ -902,7 +902,7 @@ public function test_random_redirect_ignores_pagination(): void { /** * Ensure unpublished and password protected posts are not selected, even for administrators. * - * @dataProvider data_ineligible_posts + * @dataProvider data_random_redirect_excludes_ineligible_posts * * @param array $args Post arguments. */ @@ -922,7 +922,7 @@ public function test_random_redirect_excludes_ineligible_posts( array $args ): v * * @return array }> */ - public static function data_ineligible_posts(): array { + public static function data_random_redirect_excludes_ineligible_posts(): array { return array( 'draft' => array( array( 'post_status' => 'draft' ) ), 'pending' => array( array( 'post_status' => 'pending' ) ), @@ -1055,7 +1055,7 @@ public function test_no_redirect_for_static_front_page_with_random_query_var_fro /** * Ensure feeds do not redirect with the random query variable. * - * @dataProvider data_feed_urls + * @dataProvider data_no_redirect_for_feeds * * @param string $path Feed path. */ @@ -1071,7 +1071,7 @@ public function test_no_redirect_for_feeds( string $path ): void { * * @return array */ - public static function data_feed_urls(): array { + public static function data_no_redirect_for_feeds(): array { return array( 'site feed' => array( '/feed/?random' ), 'category feed' => array( '/category/arts/feed/?random' ), @@ -1131,7 +1131,7 @@ static function ( string $where, WP_Query $query ): string { /** * Ensure requests using HTTP methods other than GET or HEAD do not redirect. * - * @dataProvider data_non_redirecting_http_methods + * @dataProvider data_no_redirect_for_non_get_requests * * @param string $method HTTP request method. */ @@ -1148,7 +1148,7 @@ public function test_no_redirect_for_non_get_requests( string $method ): void { * * @return array */ - public static function data_non_redirecting_http_methods(): array { + public static function data_no_redirect_for_non_get_requests(): array { return array( 'POST' => array( 'POST' ), 'PUT' => array( 'PUT' ), @@ -1171,7 +1171,7 @@ public function test_no_redirect_without_request_method(): void { /** * Ensure GET and HEAD requests redirect, regardless of case. * - * @dataProvider data_redirecting_http_methods + * @dataProvider data_redirect_for_get_and_head_requests * * @param string $method HTTP request method. */ @@ -1188,7 +1188,7 @@ public function test_redirect_for_get_and_head_requests( string $method ): void * * @return array */ - public static function data_redirecting_http_methods(): array { + public static function data_redirect_for_get_and_head_requests(): array { return array( 'GET' => array( 'GET' ), 'HEAD' => array( 'HEAD' ), @@ -1361,7 +1361,7 @@ public function test_draft_page_named_random_does_not_take_precedence(): void { /** * Ensure random content redirects resume once a page named "random" no longer conflicts. * - * @dataProvider data_page_named_random_changes + * @dataProvider data_random_content_redirects_resume_when_the_page_no_longer_conflicts * * @param callable $change Callback to change the page so it no longer conflicts. */ @@ -1387,7 +1387,7 @@ public function test_random_content_redirects_resume_when_the_page_no_longer_con * * @return array */ - public static function data_page_named_random_changes(): array { + public static function data_random_content_redirects_resume_when_the_page_no_longer_conflicts(): array { return array( 'renamed' => array( static function ( int $page_id ): void { @@ -2042,7 +2042,7 @@ public function test_random_selection_varies_between_requests(): void { /** * Ensure the random query selects a single post when a theme overrides the limit. * - * @dataProvider data_query_vars_overriding_the_limit + * @dataProvider data_random_query_is_limited_to_one_post_when_a_theme_overrides_the_limit * * @param string $path Request path. * @param string $query_var Query variable set by a theme. @@ -2073,7 +2073,7 @@ static function ( WP_Query $query ) use ( $query_var, $value ): void { * * @return array */ - public static function data_query_vars_overriding_the_limit(): array { + public static function data_random_query_is_limited_to_one_post_when_a_theme_overrides_the_limit(): array { $overrides = array( 'nopaging' => array( 'nopaging', true ), 'posts_per_archive_page' => array( 'posts_per_archive_page', 10 ), @@ -2256,7 +2256,7 @@ static function ( WP_Query $query ): void { /** * Ensure the enabled filter value is cast to a boolean. * - * @dataProvider data_enabled_filter_values + * @dataProvider data_wp_is_random_content_redirect_enabled_returns_a_boolean * * @param mixed $value Value returned by the filter. * @param bool $expected Expected result. @@ -2277,7 +2277,7 @@ static function () use ( $value ) { * * @return array */ - public static function data_enabled_filter_values(): array { + public static function data_wp_is_random_content_redirect_enabled_returns_a_boolean(): array { return array( 'default true' => array( true, true ), 'false' => array( false, false ), @@ -2449,7 +2449,7 @@ public function test_password_protected_page_named_random_takes_precedence(): vo /** * Ensure paths beneath the random base without random rules do not redirect. * - * @dataProvider data_unsupported_random_paths + * @dataProvider data_no_redirect_for_paths_without_random_rules * * @global WP $wp Current WordPress environment instance. * @@ -2469,7 +2469,7 @@ public function test_no_redirect_for_paths_without_random_rules( string $path ): * * @return array */ - public static function data_unsupported_random_paths(): array { + public static function data_no_redirect_for_paths_without_random_rules(): array { return array( 'pagination' => array( '/random/page/2/' ), 'feed' => array( '/random/feed/' ), @@ -2538,7 +2538,7 @@ public function test_handle_random_runs_the_main_query_for_random_requests(): vo /** * Ensure the main query is only run once for random content requests. * - * @dataProvider data_random_requests + * @dataProvider data_main_query_is_run_once_for_random_requests * * @param string $path Path to request. */ @@ -2556,7 +2556,7 @@ public function test_main_query_is_run_once_for_random_requests( string $path ): * * @return array */ - public static function data_random_requests(): array { + public static function data_main_query_is_run_once_for_random_requests(): array { return array( 'random post' => array( '/random/' ), 'random empty archive' => array( '/random/category/empty/' ), diff --git a/tests/phpunit/tests/readme.php b/tests/phpunit/tests/readme.php index f31dc31b6e197..47cc8bf3ca00f 100644 --- a/tests/phpunit/tests/readme.php +++ b/tests/phpunit/tests/readme.php @@ -206,7 +206,7 @@ private function get_skipped_test_error_class() { /** * @ticket 63914 * - * @dataProvider data_availability_error_messages + * @dataProvider data_get_response_body_skips_on_availability_failures * * @param string $message Error message. */ @@ -232,7 +232,7 @@ public function test_get_response_body_skips_on_availability_failures( $message * * @return array[] */ - public static function data_availability_error_messages() { + public static function data_get_response_body_skips_on_availability_failures() { return array( 'host resolution' => array( 'cURL error 6: Could not resolve host: endoflife.date' ), 'fsocket timed out' => array( 'fsocket timed out' ), @@ -280,7 +280,7 @@ public function test_get_response_body_fails_on_request_not_executed() { /** * @ticket 63914 * - * @dataProvider data_availability_status_codes + * @dataProvider data_get_response_body_skips_on_server_availability_status_codes * * @param int $status_code The HTTP status code. */ @@ -310,7 +310,7 @@ public function test_get_response_body_skips_on_server_availability_status_codes * * @return array[] */ - public static function data_availability_status_codes() { + public static function data_get_response_body_skips_on_server_availability_status_codes() { return array( '429 Too Many Requests' => array( 429 ), '500 Server Error' => array( 500 ), diff --git a/tests/phpunit/tests/rest-api/rest-comments-controller.php b/tests/phpunit/tests/rest-api/rest-comments-controller.php index 898b344842f9a..1666d178f1445 100644 --- a/tests/phpunit/tests/rest-api/rest-comments-controller.php +++ b/tests/phpunit/tests/rest-api/rest-comments-controller.php @@ -4763,7 +4763,7 @@ public function test_create_reaction_requires_login() { * * @ticket 64638 * - * @dataProvider data_curated_reaction_keys + * @dataProvider data_create_reaction_accepts_curated_key * * @param string $key The reaction hex key to submit. */ @@ -4802,7 +4802,7 @@ public function test_create_reaction_accepts_curated_key( $key ) { $this->assertSame( $key, $new_comment->comment_content ); } - public static function data_curated_reaction_keys() { + public static function data_create_reaction_accepts_curated_key() { return array( 'thumbs up' => array( '1f44d' ), 'plus' => array( '2795' ), @@ -4949,7 +4949,7 @@ public function test_create_reaction_on_note_from_different_post() { * * @ticket 64638 * - * @dataProvider data_uncurated_reaction_keys + * @dataProvider data_create_reaction_rejects_uncurated_key * * @param string $key The reaction content to submit. */ @@ -4985,7 +4985,7 @@ public function test_create_reaction_rejects_uncurated_key( $key ) { $this->assertErrorResponse( 'rest_comment_invalid_reaction', $response, 400 ); } - public static function data_uncurated_reaction_keys() { + public static function data_create_reaction_rejects_uncurated_key() { return array( 'uncurated emoji' => array( '1f525' ), 'ZWJ sequence' => array( '1f468-200d-1f4bb' ), @@ -5121,7 +5121,7 @@ public function test_create_reaction_accepts_raw_content_object() { * * @ticket 64638 * - * @dataProvider data_invalid_reaction_content_objects + * @dataProvider data_create_reaction_rejects_invalid_content_object * * @param array $content The reaction content to submit. */ @@ -5156,7 +5156,7 @@ public function test_create_reaction_rejects_invalid_content_object( $content ) $this->assertErrorResponse( 'rest_comment_invalid_reaction', $response, 400 ); } - public static function data_invalid_reaction_content_objects() { + public static function data_create_reaction_rejects_invalid_content_object() { return array( 'raw content not a key' => array( array( 'raw' => 'invalid_emoji' ) ), 'content without raw' => array( array( 'rendered' => '2764' ) ), @@ -5171,7 +5171,7 @@ public static function data_invalid_reaction_content_objects() { * * @ticket 64638 * - * @dataProvider data_create_reaction_status + * @dataProvider data_create_reaction_only_allows_approved_status * * @param string $status Requested status. * @param int $expected_status Expected HTTP status. @@ -5231,7 +5231,7 @@ public function test_create_reaction_only_allows_approved_status( $status, $expe * * @return array */ - public static function data_create_reaction_status() { + public static function data_create_reaction_only_allows_approved_status() { return array( 'approve' => array( 'approve', 201 ), 'hold' => array( 'hold', 400 ), @@ -6002,7 +6002,7 @@ public function test_delete_own_reaction_on_another_users_note() { * * @ticket 66447 * - * @dataProvider data_users_who_cannot_delete_another_users_reaction + * @dataProvider data_cannot_delete_another_users_reaction * * @param string $user Name of the static property holding the user ID. */ @@ -6043,7 +6043,7 @@ public function test_cannot_delete_another_users_reaction( string $user ): void * * @return array */ - public static function data_users_who_cannot_delete_another_users_reaction(): array { + public static function data_cannot_delete_another_users_reaction(): array { return array( 'post author' => array( 'author_id' ), 'administrator' => array( 'admin_id' ), @@ -6112,7 +6112,7 @@ public function test_cannot_delete_reaction_on_resolved_thread( bool $on_reply ) * * @ticket 64638 * - * @dataProvider data_hidden_note_statuses + * @dataProvider data_create_reaction_on_hidden_note * * @param string $status Status to move the parent note to. */ @@ -6153,7 +6153,7 @@ public function test_create_reaction_on_hidden_note( $status ) { * * @return array[] */ - public static function data_hidden_note_statuses() { + public static function data_create_reaction_on_hidden_note() { return array( 'trash' => array( 'trash' ), 'spam' => array( 'spam' ), @@ -6237,7 +6237,7 @@ public static function data_resolved_thread_targets() { * * @ticket 64638 * - * @dataProvider data_other_post_note_states + * @dataProvider data_create_reaction_on_note_from_uneditable_post_does_not_reveal_its_status * * @param string $state The state to put the other post's note in. */ @@ -6283,7 +6283,7 @@ public function test_create_reaction_on_note_from_uneditable_post_does_not_revea * * @return array[] */ - public static function data_other_post_note_states() { + public static function data_create_reaction_on_note_from_uneditable_post_does_not_reveal_its_status() { return array( 'open' => array( 'open' ), 'trash' => array( 'trash' ), diff --git a/tests/phpunit/tests/rest-api/rest-controller.php b/tests/phpunit/tests/rest-api/rest-controller.php index b6a6ae74df58e..a042b5edae81d 100644 --- a/tests/phpunit/tests/rest-api/rest-controller.php +++ b/tests/phpunit/tests/rest-api/rest-controller.php @@ -441,20 +441,6 @@ public function test_get_fields_for_response_respects_embed() { $this->assertContains( '_embedded', $controller->get_fields_for_response( $request ) ); } - /** - * Data provider for test_get_fields_for_response_respects_data_processing(). - * - * @return array - */ - public static function data_get_fields_for_response_respects_data_processing(): array { - return array( - 'false' => array( false, false ), - 'fields false' => array( array( 'fields' => false ), false ), - 'links false' => array( array( 'links' => false ), true ), - 'true' => array( true, true ), - ); - } - /** * @ticket 66372 * @dataProvider data_get_fields_for_response_respects_data_processing @@ -478,6 +464,20 @@ public function test_get_fields_for_response_respects_data_processing( $data_pro } } + /** + * Data provider for test_get_fields_for_response_respects_data_processing(). + * + * @return array + */ + public static function data_get_fields_for_response_respects_data_processing(): array { + return array( + 'false' => array( false, false ), + 'fields false' => array( array( 'fields' => false ), false ), + 'links false' => array( array( 'links' => false ), true ), + 'true' => array( true, true ), + ); + } + public function test_get_fields_for_response_filters_by_context() { $controller = new WP_REST_Test_Controller(); diff --git a/tests/phpunit/tests/rest-api/rest-cors-headers.php b/tests/phpunit/tests/rest-api/rest-cors-headers.php index 0d531809f88f8..3dc27a4ea13e1 100644 --- a/tests/phpunit/tests/rest-api/rest-cors-headers.php +++ b/tests/phpunit/tests/rest-api/rest-cors-headers.php @@ -146,7 +146,7 @@ public function test_response_value_drops_invalid_method_tokens() { * * @ticket 46992 * - * @dataProvider data_response_value_without_valid_methods + * @dataProvider data_response_value_without_valid_methods_falls_back_to_the_default * * @param string $response_value Access-Control-Allow-Methods value set on the response. */ @@ -161,7 +161,7 @@ public function test_response_value_without_valid_methods_falls_back_to_the_defa * * @return array */ - public static function data_response_value_without_valid_methods(): array { + public static function data_response_value_without_valid_methods_falls_back_to_the_default(): array { return array( 'empty' => array( '' ), 'whitespace' => array( ' ' ), @@ -403,7 +403,7 @@ static function ( WP_HTTP_Response $response ) { * * @ticket 46992 * - * @dataProvider data_filter_value_that_is_not_a_list + * @dataProvider data_filter_value_that_is_not_a_list_is_ignored * * @param callable $callback Filter callback returning a value that is not a list. * @param array $response_headers Headers to set on the response. @@ -422,7 +422,7 @@ public function test_filter_value_that_is_not_a_list_is_ignored( callable $callb * * @return array, 2: string }> */ - public static function data_filter_value_that_is_not_a_list(): array { + public static function data_filter_value_that_is_not_a_list_is_ignored(): array { return array( 'null' => array( '__return_null', array(), self::DEFAULT_ALLOW_METHODS ), 'false' => array( '__return_false', array(), self::DEFAULT_ALLOW_METHODS ), diff --git a/tests/phpunit/tests/rest-api/rest-pages-controller.php b/tests/phpunit/tests/rest-api/rest-pages-controller.php index f10b029e4b1cf..8dc583220c0de 100644 --- a/tests/phpunit/tests/rest-api/rest-pages-controller.php +++ b/tests/phpunit/tests/rest-api/rest-pages-controller.php @@ -995,7 +995,7 @@ public function test_homepage_action_links_do_not_exist_for_editor() { /** * @ticket 66327 * - * @dataProvider data_unpublished_page_statuses + * @dataProvider data_homepage_action_links_do_not_exist_for_unpublished_pages * * @covers WP_REST_Posts_Controller::get_available_actions * @@ -1022,7 +1022,7 @@ public function test_homepage_action_links_do_not_exist_for_unpublished_pages( $ * * @return array[] */ - public static function data_unpublished_page_statuses() { + public static function data_homepage_action_links_do_not_exist_for_unpublished_pages() { return array( 'draft' => array( 'draft' ), 'pending' => array( 'pending' ), diff --git a/tests/phpunit/tests/rest-api/rest-revisions-controller.php b/tests/phpunit/tests/rest-api/rest-revisions-controller.php index fcf6b69393865..c508b6efd83f3 100644 --- a/tests/phpunit/tests/rest-api/rest-revisions-controller.php +++ b/tests/phpunit/tests/rest-api/rest-revisions-controller.php @@ -1600,7 +1600,7 @@ public function test_restoring_revision_keeps_meta_that_is_not_revisioned() { * * @ticket 66329 * - * @dataProvider data_pattern_sync_statuses + * @dataProvider data_restoring_pattern_revision_keeps_sync_status * * @covers WP_REST_Revisions_Controller::prepare_item_for_response * @@ -1644,7 +1644,7 @@ public function test_restoring_pattern_revision_keeps_sync_status( $sync_status * * @return array[] */ - public static function data_pattern_sync_statuses() { + public static function data_restoring_pattern_revision_keeps_sync_status() { return array( 'synced pattern' => array( '' ), 'unsynced pattern' => array( 'unsynced' ), diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php index b822e3289b822..43b9cd1c2952e 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -2950,6 +2950,18 @@ private function register_data_processing_route( $data, bool $with_link, array $ ); } + /** + * @ticket 66372 + * @dataProvider data_resolve_data_processing + * + * @param array $handler The route handler. + * @param array|null $route_options The route options. + * @param array $expected The expected settings. + */ + public function test_resolve_data_processing( array $handler, ?array $route_options, array $expected ): void { + $this->assertSame( $expected, WP_REST_Server::resolve_data_processing( $handler, $route_options ), 'The settings should be resolved feature by feature.' ); + } + /** * Data provider for test_resolve_data_processing(). * @@ -3021,14 +3033,19 @@ public static function data_resolve_data_processing(): array { /** * @ticket 66372 - * @dataProvider data_resolve_data_processing + * @dataProvider data_data_processing_false_serves_the_data_as_returned * - * @param array $handler The route handler. - * @param array|null $route_options The route options. - * @param array $expected The expected settings. + * @param mixed $data The response data. + * @param string $expected The expected response body. */ - public function test_resolve_data_processing( array $handler, ?array $route_options, array $expected ): void { - $this->assertSame( $expected, WP_REST_Server::resolve_data_processing( $handler, $route_options ), 'The settings should be resolved feature by feature.' ); + public function test_data_processing_false_serves_the_data_as_returned( $data, string $expected ): void { + $this->register_data_processing_route( $data, true, array( 'data_processing' => false ) ); + + $_GET['_fields'] = 'a'; + $_GET['_embed'] = '1'; + rest_get_server()->serve_request( '/test-ns/data-processing' ); + + $this->assertSame( $expected, rest_get_server()->sent_body, 'The data should be served as returned, without links or filtering.' ); } /** @@ -3054,23 +3071,6 @@ public static function data_data_processing_false_serves_the_data_as_returned(): ); } - /** - * @ticket 66372 - * @dataProvider data_data_processing_false_serves_the_data_as_returned - * - * @param mixed $data The response data. - * @param string $expected The expected response body. - */ - public function test_data_processing_false_serves_the_data_as_returned( $data, string $expected ): void { - $this->register_data_processing_route( $data, true, array( 'data_processing' => false ) ); - - $_GET['_fields'] = 'a'; - $_GET['_embed'] = '1'; - rest_get_server()->serve_request( '/test-ns/data-processing' ); - - $this->assertSame( $expected, rest_get_server()->sent_body, 'The data should be served as returned, without links or filtering.' ); - } - /** * @ticket 66372 */ @@ -3113,20 +3113,6 @@ public function test_data_processing_fields_false_leaves_the_data_unfiltered(): $this->assertSame( array( 'a', 'b', '_links', '_embedded' ), array_keys( $data ), 'Only the _fields parameter should be ignored.' ); } - /** - * Data provider for test_data_processing_links_false_leaves_out_the_links(). - * - * @return array - */ - public static function data_data_processing_links_false_leaves_out_the_links(): array { - return array( - 'associative array' => array( array( 'a' => 1 ), '{"a":1}' ), - 'list' => array( array( 'a', 'b' ), '["a","b"]' ), - 'empty object' => array( new stdClass(), '{}' ), - 'string' => array( 'value', '"value"' ), - ); - } - /** * @ticket 66372 * @dataProvider data_data_processing_links_false_leaves_out_the_links @@ -3143,6 +3129,20 @@ public function test_data_processing_links_false_leaves_out_the_links( $data, st $this->assertSame( $expected, rest_get_server()->sent_body, 'The response links should not be added or embedded.' ); } + /** + * Data provider for test_data_processing_links_false_leaves_out_the_links(). + * + * @return array + */ + public static function data_data_processing_links_false_leaves_out_the_links(): array { + return array( + 'associative array' => array( array( 'a' => 1 ), '{"a":1}' ), + 'list' => array( array( 'a', 'b' ), '["a","b"]' ), + 'empty object' => array( new stdClass(), '{}' ), + 'string' => array( 'value', '"value"' ), + ); + } + /** * @ticket 66372 */ @@ -3209,21 +3209,6 @@ public function test_data_processing_applies_to_enveloped_responses(): void { ); } - /** - * Data provider for test_handler_setting_takes_precedence_over_route_setting(). - * - * @return array, 1: array, 2: string[]}> - */ - public static function data_handler_setting_takes_precedence_over_route_setting(): array { - return array( - 'route false' => array( array(), array( 'data_processing' => false ), array( 'a', 'b' ) ), - 'route false and handler true' => array( array( 'data_processing' => true ), array( 'data_processing' => false ), array( 'a', '_links' ) ), - 'route false and handler fields' => array( array( 'data_processing' => array( 'fields' => true ) ), array( 'data_processing' => false ), array( 'a' ) ), - 'route fields false and handler links off' => array( array( 'data_processing' => array( 'links' => false ) ), array( 'data_processing' => array( 'fields' => false ) ), array( 'a', 'b' ) ), - 'route links false and handler fields off' => array( array( 'data_processing' => array( 'fields' => false ) ), array( 'data_processing' => array( 'links' => false ) ), array( 'a', 'b' ) ), - ); - } - /** * @ticket 66372 * @dataProvider data_handler_setting_takes_precedence_over_route_setting @@ -3250,6 +3235,21 @@ public function test_handler_setting_takes_precedence_over_route_setting( array $this->assertSame( $expected_keys, array_keys( $data ), 'The handler setting should take precedence over the route setting, feature by feature.' ); } + /** + * Data provider for test_handler_setting_takes_precedence_over_route_setting(). + * + * @return array, 1: array, 2: string[]}> + */ + public static function data_handler_setting_takes_precedence_over_route_setting(): array { + return array( + 'route false' => array( array(), array( 'data_processing' => false ), array( 'a', 'b' ) ), + 'route false and handler true' => array( array( 'data_processing' => true ), array( 'data_processing' => false ), array( 'a', '_links' ) ), + 'route false and handler fields' => array( array( 'data_processing' => array( 'fields' => true ) ), array( 'data_processing' => false ), array( 'a' ) ), + 'route fields false and handler links off' => array( array( 'data_processing' => array( 'links' => false ) ), array( 'data_processing' => array( 'fields' => false ) ), array( 'a', 'b' ) ), + 'route links false and handler fields off' => array( array( 'data_processing' => array( 'fields' => false ) ), array( 'data_processing' => array( 'links' => false ) ), array( 'a', 'b' ) ), + ); + } + /** * @ticket 66372 */ @@ -3288,24 +3288,6 @@ public function test_routes_without_the_option_have_every_feature_on(): void { $this->assertSame( $expected, $response->get_data_processing(), 'The response should have every feature on.' ); } - /** - * Data provider for test_data_processing_applies_to_hijacked_responses(). - * - * @return array - */ - public static function data_data_processing_applies_to_hijacked_responses(): array { - return array( - 'associative array' => array( - array( - 'a' => 1, - 'b' => 2, - ), - '{"a":1,"b":2}', - ), - 'string' => array( 'value', '"value"' ), - ); - } - /** * @ticket 66372 * @dataProvider data_data_processing_applies_to_hijacked_responses @@ -3330,6 +3312,24 @@ static function () use ( $data ) { $this->assertSame( $expected, rest_get_server()->sent_body, 'A response returned by rest_pre_dispatch should follow the settings of the route it was returned for.' ); } + /** + * Data provider for test_data_processing_applies_to_hijacked_responses(). + * + * @return array + */ + public static function data_data_processing_applies_to_hijacked_responses(): array { + return array( + 'associative array' => array( + array( + 'a' => 1, + 'b' => 2, + ), + '{"a":1,"b":2}', + ), + 'string' => array( 'value', '"value"' ), + ); + } + /** * @ticket 66372 */ @@ -3433,6 +3433,31 @@ static function ( $response ) { $this->assertSame( '{"a":1,"b":2}', rest_get_server()->sent_body, 'A setting made on the response after dispatch should apply when the response is served.' ); } + /** + * @ticket 66372 + * @dataProvider data_response_set_data_processing + * + * @param mixed $processing The setting, in the form of the `data_processing` option. + * @param array $expected The expected settings of the response. + */ + public function test_response_set_data_processing( $processing, array $expected ): void { + $response = new WP_REST_Response(); + + $this->assertSame( + array( + 'fields' => true, + 'embed' => true, + 'links' => true, + ), + $response->get_data_processing(), + 'A new response should have every feature on.' + ); + + $response->set_data_processing( $processing ); + + $this->assertSame( $expected, $response->get_data_processing(), 'The setting should be resolved like the route option.' ); + } + /** * Data provider for test_response_set_data_processing(). * @@ -3477,27 +3502,17 @@ public static function data_response_set_data_processing(): array { /** * @ticket 66372 - * @dataProvider data_response_set_data_processing + * @dataProvider data_data_processing_applies_to_preloaded_requests * - * @param mixed $processing The setting, in the form of the `data_processing` option. - * @param array $expected The expected settings of the response. + * @param mixed $data The response data. + * @param string $expected The expected JSON encoding of the preloaded body. */ - public function test_response_set_data_processing( $processing, array $expected ): void { - $response = new WP_REST_Response(); - - $this->assertSame( - array( - 'fields' => true, - 'embed' => true, - 'links' => true, - ), - $response->get_data_processing(), - 'A new response should have every feature on.' - ); + public function test_data_processing_applies_to_preloaded_requests( $data, string $expected ): void { + $this->register_data_processing_route( $data, true, array( 'data_processing' => false ) ); - $response->set_data_processing( $processing ); + $preload = rest_preload_api_request( array(), '/test-ns/data-processing?_fields=a&_embed=1' ); - $this->assertSame( $expected, $response->get_data_processing(), 'The setting should be resolved like the route option.' ); + $this->assertSame( $expected, wp_json_encode( $preload['/test-ns/data-processing?_fields=a&_embed=1']['body'] ), 'The preloaded body should be the data as returned.' ); } /** @@ -3519,21 +3534,6 @@ public static function data_data_processing_applies_to_preloaded_requests(): arr ); } - /** - * @ticket 66372 - * @dataProvider data_data_processing_applies_to_preloaded_requests - * - * @param mixed $data The response data. - * @param string $expected The expected JSON encoding of the preloaded body. - */ - public function test_data_processing_applies_to_preloaded_requests( $data, string $expected ): void { - $this->register_data_processing_route( $data, true, array( 'data_processing' => false ) ); - - $preload = rest_preload_api_request( array(), '/test-ns/data-processing?_fields=a&_embed=1' ); - - $this->assertSame( $expected, wp_json_encode( $preload['/test-ns/data-processing?_fields=a&_embed=1']['body'] ), 'The preloaded body should be the data as returned.' ); - } - /** * @ticket 66372 */ @@ -3632,23 +3632,6 @@ public function test_array_access_data_gets_links_and_embedded_resources(): void $this->assertSame( array( 'a', '_links', '_embedded' ), array_keys( $data ), 'An object that acts as an array should get the links and the embedded resources.' ); } - /** - * Data provider for test_non_array_data_is_served_as_returned_by_default(). - * - * @return array - */ - public static function data_non_array_data_is_served_as_returned_by_default(): array { - return array( - 'string' => array( 'value', true, '"value"' ), - 'integer' => array( 5, true, '5' ), - 'object' => array( (object) array( 'b' => 2 ), true, '{"b":2}' ), - 'empty object' => array( new stdClass(), true, '{}' ), - 'list of scalars' => array( array( 'a', 'b' ), false, '["a","b"]' ), - 'mixed list' => array( array( array( 'b' => 2 ), 'c' ), false, '[[],"c"]' ), - 'list of objects' => array( array( (object) array( 'b' => 2 ) ), false, '[{"b":2}]' ), - ); - } - /** * @ticket 66372 * @dataProvider data_non_array_data_is_served_as_returned_by_default @@ -3666,4 +3649,21 @@ public function test_non_array_data_is_served_as_returned_by_default( $data, boo $this->assertSame( $expected, rest_get_server()->sent_body, 'Data without fields, or items without fields, should be served as returned.' ); } + + /** + * Data provider for test_non_array_data_is_served_as_returned_by_default(). + * + * @return array + */ + public static function data_non_array_data_is_served_as_returned_by_default(): array { + return array( + 'string' => array( 'value', true, '"value"' ), + 'integer' => array( 5, true, '5' ), + 'object' => array( (object) array( 'b' => 2 ), true, '{"b":2}' ), + 'empty object' => array( new stdClass(), true, '{}' ), + 'list of scalars' => array( array( 'a', 'b' ), false, '["a","b"]' ), + 'mixed list' => array( array( array( 'b' => 2 ), 'c' ), false, '[[],"c"]' ), + 'list of objects' => array( array( (object) array( 'b' => 2 ) ), false, '[{"b":2}]' ), + ); + } } diff --git a/tests/phpunit/tests/rest-api/restAreValuesEqual.php b/tests/phpunit/tests/rest-api/restAreValuesEqual.php index 360620dae203b..15283106a8d67 100644 --- a/tests/phpunit/tests/rest-api/restAreValuesEqual.php +++ b/tests/phpunit/tests/rest-api/restAreValuesEqual.php @@ -81,7 +81,7 @@ public static function data_equal_values() { /** * @ticket 65819 * - * @dataProvider data_unequal_values + * @dataProvider data_returns_false_for_unequal_values * * @param mixed $value1 First value. * @param mixed $value2 Second value. @@ -95,7 +95,7 @@ public function test_returns_false_for_unequal_values( $value1, $value2 ) { * * @return array[] */ - public static function data_unequal_values() { + public static function data_returns_false_for_unequal_values() { return array( 'different strings' => array( 'hello', 'world' ), 'string and integer' => array( '1', 1 ), diff --git a/tests/phpunit/tests/rest-api/restCookieCollectStatus.php b/tests/phpunit/tests/rest-api/restCookieCollectStatus.php index 530c3d1bfe7cc..0fe2b7af98e6c 100644 --- a/tests/phpunit/tests/rest-api/restCookieCollectStatus.php +++ b/tests/phpunit/tests/rest-api/restCookieCollectStatus.php @@ -26,7 +26,7 @@ public function test_sets_true_when_auth_cookie_valid() { /** * @ticket 65819 * - * @dataProvider data_auth_cookie_failure_actions + * @dataProvider data_stores_failure_status_from_action * * @param string $action Auth cookie action name. * @param string $expected Stored failure status. @@ -42,7 +42,7 @@ public function test_stores_failure_status_from_action( $action, $expected ) { * * @return array[] */ - public static function data_auth_cookie_failure_actions() { + public static function data_stores_failure_status_from_action() { return array( 'malformed' => array( 'auth_cookie_malformed', 'malformed' ), 'expired' => array( 'auth_cookie_expired', 'expired' ), diff --git a/tests/phpunit/tests/rest-api/restFindMatchingPatternPropertySchema.php b/tests/phpunit/tests/rest-api/restFindMatchingPatternPropertySchema.php index ae7af30d8f9bc..86a02acbf3096 100644 --- a/tests/phpunit/tests/rest-api/restFindMatchingPatternPropertySchema.php +++ b/tests/phpunit/tests/rest-api/restFindMatchingPatternPropertySchema.php @@ -14,7 +14,7 @@ class Tests_REST_API_RestFindMatchingPatternPropertySchema extends WP_UnitTestCa * * @ticket 65819 * - * @dataProvider data_matching_pattern_properties + * @dataProvider data_returns_schema_of_matching_pattern * * @param string|int $property Property name. Numeric names arrive as integers from array keys. * @param array $pattern_properties Value of the patternProperties keyword. @@ -31,7 +31,7 @@ public function test_returns_schema_of_matching_pattern( $property, $pattern_pro * * @return array[] */ - public static function data_matching_pattern_properties() { + public static function data_returns_schema_of_matching_pattern() { return array( 'integer property name' => array( 123, @@ -70,7 +70,7 @@ public static function data_matching_pattern_properties() { * * @ticket 65819 * - * @dataProvider data_no_matching_pattern_properties + * @dataProvider data_returns_null_without_matching_pattern * * @param string $property Property name. * @param array $schema Schema to search. @@ -84,7 +84,7 @@ public function test_returns_null_without_matching_pattern( $property, $schema ) * * @return array[] */ - public static function data_no_matching_pattern_properties() { + public static function data_returns_null_without_matching_pattern() { return array( 'no patternProperties' => array( 'prop', diff --git a/tests/phpunit/tests/rest-api/restIsIpAddress.php b/tests/phpunit/tests/rest-api/restIsIpAddress.php index 765a68ff88c67..94aab7f2764a0 100644 --- a/tests/phpunit/tests/rest-api/restIsIpAddress.php +++ b/tests/phpunit/tests/rest-api/restIsIpAddress.php @@ -14,7 +14,7 @@ class Tests_REST_API_RestIsIpAddress extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_valid_ip_addresses + * @dataProvider data_returns_valid_ip_address * * @param string $ip Valid IP address. */ @@ -27,7 +27,7 @@ public function test_returns_valid_ip_address( $ip ) { * * @return array[] */ - public static function data_valid_ip_addresses() { + public static function data_returns_valid_ip_address() { return array( 'ipv4' => array( '192.0.2.10' ), 'ipv6' => array( '2001:db8::1' ), @@ -39,7 +39,7 @@ public static function data_valid_ip_addresses() { * * @ticket 65819 * - * @dataProvider data_invalid_ip_addresses + * @dataProvider data_returns_false_for_invalid_ip_address * * @param mixed $ip Invalid IP value. */ @@ -52,7 +52,7 @@ public function test_returns_false_for_invalid_ip_address( $ip ) { * * @return array[] */ - public static function data_invalid_ip_addresses() { + public static function data_returns_false_for_invalid_ip_address() { return array( 'empty string' => array( '' ), 'out of range ipv4' => array( '256.0.0.1' ), diff --git a/tests/phpunit/tests/rest-api/restParseHexColor.php b/tests/phpunit/tests/rest-api/restParseHexColor.php index e2dc0ffc28634..710c1f1ead758 100644 --- a/tests/phpunit/tests/rest-api/restParseHexColor.php +++ b/tests/phpunit/tests/rest-api/restParseHexColor.php @@ -14,7 +14,7 @@ class Tests_REST_API_RestParseHexColor extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_valid_hex_colors + * @dataProvider data_returns_valid_hex_color * * @param string $color Valid hex color. */ @@ -27,7 +27,7 @@ public function test_returns_valid_hex_color( $color ) { * * @return array[] */ - public static function data_valid_hex_colors() { + public static function data_returns_valid_hex_color() { return array( '3-digit mixed case' => array( '#aBc' ), '6-digit mixed case' => array( '#aBcDeF' ), @@ -39,7 +39,7 @@ public static function data_valid_hex_colors() { * * @ticket 65819 * - * @dataProvider data_invalid_hex_colors + * @dataProvider data_returns_false_for_invalid_hex_color * * @param mixed $color Invalid color value. */ @@ -52,7 +52,7 @@ public function test_returns_false_for_invalid_hex_color( $color ) { * * @return array[] */ - public static function data_invalid_hex_colors() { + public static function data_returns_false_for_invalid_hex_color() { return array( 'missing hash' => array( 'abcdef' ), 'unsupported length' => array( '#ab' ), diff --git a/tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php b/tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php index 9eb1b4910edcb..68dbf48b544f5 100644 --- a/tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php +++ b/tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php @@ -742,6 +742,23 @@ public function test_output_validation(): void { ); } + /** + * Tests that ability results are prepared for JSON clients. + * + * @ticket 66267 + * @dataProvider data_output_is_prepared_for_json_clients + * + * @param string $ability_name The ability name. + * @param string $expected The expected encoded result. + */ + public function test_output_is_prepared_for_json_clients( string $ability_name, string $expected ): void { + $request = new WP_REST_Request( 'POST', "/wp-abilities/v1/abilities/{$ability_name}/run" ); + $response = $this->server->dispatch( $request ); + + $this->assertSame( 200, $response->get_status(), 'The ability should run successfully.' ); + $this->assertSame( $expected, wp_json_encode( $response->get_data() ), 'The result should be encoded as expected.' ); + } + /** * Data provider for test_output_is_prepared_for_json_clients(). * @@ -760,23 +777,6 @@ public static function data_output_is_prepared_for_json_clients(): array { ); } - /** - * Tests that ability results are prepared for JSON clients. - * - * @ticket 66267 - * @dataProvider data_output_is_prepared_for_json_clients - * - * @param string $ability_name The ability name. - * @param string $expected The expected encoded result. - */ - public function test_output_is_prepared_for_json_clients( string $ability_name, string $expected ): void { - $request = new WP_REST_Request( 'POST', "/wp-abilities/v1/abilities/{$ability_name}/run" ); - $response = $this->server->dispatch( $request ); - - $this->assertSame( 200, $response->get_status(), 'The ability should run successfully.' ); - $this->assertSame( $expected, wp_json_encode( $response->get_data() ), 'The result should be encoded as expected.' ); - } - /** * Tests that the global `_fields` and `_embed` parameters and response links leave * ability results unchanged. @@ -1873,25 +1873,11 @@ public function test_input_is_coerced_for_transport( string $method, array $anno ); } - /** - * Provides transports and input sources for input that fails sanitization. - * - * @return array - */ - public static function data_sanitization_error_inputs(): array { - return array( - 'query input' => array( 'GET', 'request' ), - 'JSON input' => array( 'POST', 'request' ), - 'schema default' => array( 'POST', 'default' ), - 'normalizer input' => array( 'POST', 'filter' ), - ); - } - /** * Tests that sanitization failures use existing REST error handling before permission checks. * * @ticket 66383 - * @dataProvider data_sanitization_error_inputs + * @dataProvider data_sanitization_error_returns_400 * * @param string $method HTTP method. * @param string $source Source of the input that fails sanitization. @@ -1940,6 +1926,20 @@ static function () use ( $input ) { $this->assertSame( 'ability_invalid_input', $data['code'] ); } + /** + * Provides transports and input sources for input that fails sanitization. + * + * @return array + */ + public static function data_sanitization_error_returns_400(): array { + return array( + 'query input' => array( 'GET', 'request' ), + 'JSON input' => array( 'POST', 'request' ), + 'schema default' => array( 'POST', 'default' ), + 'normalizer input' => array( 'POST', 'filter' ), + ); + } + /** * Data provider for input that sanitization must not rescue. * @@ -2107,18 +2107,6 @@ public function test_input_without_schema_passes_through(): void { $this->assertTrue( $response->get_data()['ran'] ); } - /** - * Provides explicit input and an omitted input using the schema default. - * - * @return array - */ - public static function data_permission_callback_input(): array { - return array( - 'explicit input' => array( array( 'count' => '10' ) ), - 'default input' => array( null ), - ); - } - /** * Tests that the permission callback receives natively typed input. * @@ -2127,7 +2115,7 @@ public static function data_permission_callback_input(): array { * string delivered. The gate runs first, so the first recorded type is the one it acted on. * * @ticket 65594 - * @dataProvider data_permission_callback_input + * @dataProvider data_permission_callback_receives_typed_input * * @param array|null $input Request input, or null to use the schema default. */ @@ -2171,14 +2159,14 @@ public function test_permission_callback_receives_typed_input( $input ): void { } /** - * Data provider for input sent with the request and input left out. + * Provides explicit input and an omitted input using the schema default. * - * @return array Request input, or null to use the schema default. + * @return array */ - public static function data_input_prepared_once(): array { + public static function data_permission_callback_receives_typed_input(): array { return array( - 'request input' => array( array( 'count' => '10' ) ), - 'schema default' => array( null ), + 'explicit input' => array( array( 'count' => '10' ) ), + 'default input' => array( null ), ); } @@ -2186,7 +2174,7 @@ public static function data_input_prepared_once(): array { * Tests that the input is prepared only once before the permission check. * * @ticket 66383 - * @dataProvider data_input_prepared_once + * @dataProvider data_input_is_prepared_once_before_permission_check * * @param array|null $input Request input, or null to use the schema default. */ @@ -2236,15 +2224,14 @@ static function ( $is_valid ) use ( $calls ) { } /** - * Data provider for requests rejected by the permission check. + * Data provider for input sent with the request and input left out. * - * @return array HTTP method, whether the - * ability is shown in REST, and the expected error code. + * @return array Request input, or null to use the schema default. */ - public static function data_invalid_input_does_not_hide_request_errors(): array { + public static function data_input_is_prepared_once_before_permission_check(): array { return array( - 'hidden ability' => array( 'GET', false, 'rest_ability_not_found' ), - 'wrong HTTP method' => array( 'POST', true, 'rest_ability_invalid_method' ), + 'request input' => array( array( 'count' => '10' ) ), + 'schema default' => array( null ), ); } @@ -2285,6 +2272,19 @@ public function test_invalid_input_does_not_hide_request_errors( string $method, $this->assertSame( $error_code, $response->get_data()['code'] ); } + /** + * Data provider for requests rejected by the permission check. + * + * @return array HTTP method, whether the + * ability is shown in REST, and the expected error code. + */ + public static function data_invalid_input_does_not_hide_request_errors(): array { + return array( + 'hidden ability' => array( 'GET', false, 'rest_ability_not_found' ), + 'wrong HTTP method' => array( 'POST', true, 'rest_ability_invalid_method' ), + ); + } + /** * Tests that a REST run normalizes the input only once. * diff --git a/tests/phpunit/tests/rewrite.php b/tests/phpunit/tests/rewrite.php index 1adfe0243e9c3..6213658f694ae 100644 --- a/tests/phpunit/tests/rewrite.php +++ b/tests/phpunit/tests/rewrite.php @@ -272,7 +272,7 @@ public function test_url_to_postid_url_has_only_path() { * * @covers ::url_to_postid * - * @dataProvider data_url_to_postid_host_matching + * @dataProvider data_url_to_postid_matches_www_prefix_only * * @param string $host Host of the URL to resolve. * @param bool $is_local Whether the host should be treated as this site. @@ -293,7 +293,7 @@ public function test_url_to_postid_matches_www_prefix_only( $host, $is_local ) { * * @return array[] */ - public static function data_url_to_postid_host_matching() { + public static function data_url_to_postid_matches_www_prefix_only() { return array( 'the site host' => array( 'example.com', true ), 'the site host with www' => array( 'www.example.com', true ), diff --git a/tests/phpunit/tests/rewrite/randomRewriteRules.php b/tests/phpunit/tests/rewrite/randomRewriteRules.php index eed927f53a39f..4e0f8d6146133 100644 --- a/tests/phpunit/tests/rewrite/randomRewriteRules.php +++ b/tests/phpunit/tests/rewrite/randomRewriteRules.php @@ -126,7 +126,7 @@ private function get_stored_rewrite_rules(): array { } /** - * @dataProvider data_core_random_rewrite_rules + * @dataProvider data_core_random_rewrite_rules_are_registered * * @param string $regex Expected rewrite rule regex. * @param string $query Expected rewrite rule query. @@ -143,7 +143,7 @@ public function test_core_random_rewrite_rules_are_registered( $regex, $query ): * * @return array */ - public static function data_core_random_rewrite_rules(): array { + public static function data_core_random_rewrite_rules_are_registered(): array { return array( 'any post' => array( 'random/?$', 'index.php?random=1' ), 'category' => array( 'random/category/(.+?)/?$', 'index.php?category_name=$matches[1]&random=1' ), @@ -864,7 +864,7 @@ public function test_random_root_rule_is_omitted_when_a_page_named_random_exists } /** - * @dataProvider data_pages_that_do_not_conflict + * @dataProvider data_random_root_rule_is_kept_for_pages_that_do_not_conflict * * @param array $args Page arguments. A `post_parent` is replaced with a parent page ID. */ @@ -883,7 +883,7 @@ public function test_random_root_rule_is_kept_for_pages_that_do_not_conflict( $a * * @return array}> */ - public static function data_pages_that_do_not_conflict(): array { + public static function data_random_root_rule_is_kept_for_pages_that_do_not_conflict(): array { return array( 'slug starting with random' => array( array( 'post_name' => 'random-is-just-patterns-we-cant-decipher' ) ), 'draft page named random' => array( @@ -1067,7 +1067,7 @@ public static function data_post_name_at_the_root_structures(): array { } /** - * @dataProvider data_posts_that_do_not_conflict + * @dataProvider data_random_root_rule_is_kept_for_posts_that_do_not_conflict * * @param string $structure Permalink structure. * @param array $args Post arguments. @@ -1086,7 +1086,7 @@ public function test_random_root_rule_is_kept_for_posts_that_do_not_conflict( st * * @return array}> */ - public static function data_posts_that_do_not_conflict(): array { + public static function data_random_root_rule_is_kept_for_posts_that_do_not_conflict(): array { return array( 'blog prefix' => array( '/blog/%postname%/', array() ), 'date and post name' => array( '/%year%/%monthnum%/%postname%/', array() ), diff --git a/tests/phpunit/tests/script-modules/wpScriptModules.php b/tests/phpunit/tests/script-modules/wpScriptModules.php index 47a79efb66a12..184e0f9d0f62c 100644 --- a/tests/phpunit/tests/script-modules/wpScriptModules.php +++ b/tests/phpunit/tests/script-modules/wpScriptModules.php @@ -2999,7 +2999,7 @@ private function register_script_with_module_dependencies( array $module_depende * * @ticket 66591 * - * @dataProvider data_module_dependencies_of_script + * @dataProvider data_print_script_module_translations_includes_module_dependencies_of_scripts * * @covers WP_Script_Modules::print_script_module_translations * @covers WP_Script_Modules::get_loadable_script_module_ids @@ -3039,7 +3039,7 @@ public function test_print_script_module_translations_includes_module_dependenci * * @return array> }> */ - public static function data_module_dependencies_of_script(): array { + public static function data_print_script_module_translations_includes_module_dependencies_of_scripts(): array { return array( 'module ID' => array( array( 'imported-module' ) ), 'static import' => array( @@ -3067,7 +3067,7 @@ public static function data_module_dependencies_of_script(): array { * * @ticket 66591 * - * @dataProvider data_enqueued_scripts_and_script_modules + * @dataProvider data_print_script_module_translations_includes_module_dependencies_of_enqueued_scripts_once * * @covers WP_Script_Modules::print_script_module_translations * @covers WP_Script_Modules::get_loadable_script_module_ids @@ -3098,7 +3098,7 @@ public function test_print_script_module_translations_includes_module_dependenci * * @return array */ - public static function data_enqueued_scripts_and_script_modules(): array { + public static function data_print_script_module_translations_includes_module_dependencies_of_enqueued_scripts_once(): array { return array( 'a dependency of the enqueued script' => array( array( 'dependent-script' ), array(), array( 'imported-module' ) ), 'a script that is not enqueued' => array( array(), array(), array() ), @@ -3197,7 +3197,7 @@ static function ( $data ) { * * @ticket 66591 * - * @dataProvider data_unregistered_or_circular_dependencies + * @dataProvider data_print_script_module_translations_and_data_output_with_unregistered_or_circular_dependencies * * @covers WP_Script_Modules::print_script_module_translations * @covers WP_Script_Modules::print_script_module_data @@ -3241,7 +3241,7 @@ static function ( $data ) { * * @return array }> */ - public static function data_unregistered_or_circular_dependencies(): array { + public static function data_print_script_module_translations_and_data_output_with_unregistered_or_circular_dependencies(): array { return array( 'a dependency that is not registered' => array( array( diff --git a/tests/phpunit/tests/secrets/wpSetSecretAndWpGetSecret.php b/tests/phpunit/tests/secrets/wpSetSecretAndWpGetSecret.php index 2c441dae96e65..e00ed7f0a231d 100644 --- a/tests/phpunit/tests/secrets/wpSetSecretAndWpGetSecret.php +++ b/tests/phpunit/tests/secrets/wpSetSecretAndWpGetSecret.php @@ -380,7 +380,7 @@ static function () { * * @requires PHP 8.2 * - * @dataProvider data_parameters_that_receive_a_secret_value + * @dataProvider data_parameters_that_receive_a_secret_value_are_sensitive * * @param callable-string|array{0: class-string, 1: string} $target The function or method. * @param string $parameter The parameter name. @@ -403,7 +403,7 @@ public function test_parameters_that_receive_a_secret_value_are_sensitive( $targ * * @return array */ - public static function data_parameters_that_receive_a_secret_value(): array { + public static function data_parameters_that_receive_a_secret_value_are_sensitive(): array { return array( 'wp_set_secret()' => array( 'wp_set_secret', 'value' ), 'wp_set_network_secret()' => array( 'wp_set_network_secret', 'value' ), diff --git a/tests/phpunit/tests/sitemaps/sitemaps.php b/tests/phpunit/tests/sitemaps/sitemaps.php index b55b3d1482878..66f5e27dc4a45 100644 --- a/tests/phpunit/tests/sitemaps/sitemaps.php +++ b/tests/phpunit/tests/sitemaps/sitemaps.php @@ -521,7 +521,7 @@ public function test_empty_url_list_for_subtype_should_return_404() { * * @ticket 65945 * - * @dataProvider data_unusable_sitemap_query_vars + * @dataProvider data_unusable_sitemap_query_var_should_return_404 * * @param non-falsy-string $query_string Query string to append to a nonexistent URL. */ @@ -545,7 +545,7 @@ public function test_unusable_sitemap_query_var_should_return_404( string $query * * @return array */ - public static function data_unusable_sitemap_query_vars(): array { + public static function data_unusable_sitemap_query_var_should_return_404(): array { return array( 'value stripped by sanitizing' => array( '?sitemap=<>' ), 'array sitemap value' => array( '?sitemap[]=index' ), diff --git a/tests/phpunit/tests/sitemaps/wpSitemapsPosts.php b/tests/phpunit/tests/sitemaps/wpSitemapsPosts.php index b75239cdd0352..317e0527aeca2 100644 --- a/tests/phpunit/tests/sitemaps/wpSitemapsPosts.php +++ b/tests/phpunit/tests/sitemaps/wpSitemapsPosts.php @@ -186,7 +186,7 @@ public function test_get_object_subtypes_returns_viewable_public_post_types() { * * @covers WP_Sitemaps_Posts::get_url_list * - * @dataProvider data_unsupported_post_types + * @dataProvider data_get_url_list_returns_empty_array_for_unsupported_post_type * * @param string $post_type Post type. */ @@ -215,7 +215,7 @@ public function test_get_url_list_returns_empty_array_for_unsupported_post_type( * * @return array[] */ - public static function data_unsupported_post_types() { + public static function data_get_url_list_returns_empty_array_for_unsupported_post_type() { return array( 'empty post type' => array( '' ), 'attachment' => array( 'attachment' ), @@ -561,7 +561,7 @@ public function test_get_max_num_pages_returns_zero_without_subtype() { * * @covers WP_Sitemaps_Posts::get_max_num_pages * - * @dataProvider data_show_on_front + * @dataProvider data_get_max_num_pages_without_posts_depends_on_show_on_front * * @param string $show_on_front Value of the show_on_front option. * @param string $post_type Post type. @@ -580,7 +580,7 @@ public function test_get_max_num_pages_without_posts_depends_on_show_on_front( $ * * @return array[] */ - public static function data_show_on_front() { + public static function data_get_max_num_pages_without_posts_depends_on_show_on_front() { return array( 'pages, homepage shows latest posts' => array( 'posts', 'page', 1 ), 'pages, homepage shows a page' => array( 'page', 'page', 0 ), diff --git a/tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php b/tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php index bade04e8dcb9c..cb9bbbaf57c5e 100644 --- a/tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php +++ b/tests/phpunit/tests/sitemaps/wpSitemapsRegistry.php @@ -96,7 +96,7 @@ static function () use ( $filtered_provider ) { * * @covers WP_Sitemaps_Registry::add_provider * - * @dataProvider data_invalid_sitemap_providers + * @dataProvider data_add_provider_filter_rejects_non_provider * * @param mixed $invalid_provider Invalid provider value. */ @@ -121,7 +121,7 @@ static function () use ( $invalid_provider ) { * * @return array */ - public static function data_invalid_sitemap_providers() { + public static function data_add_provider_filter_rejects_non_provider() { return array( 'false' => array( false ), 'stdClass' => array( new stdClass() ), diff --git a/tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php b/tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php index e778c73ca9401..b762266e8d8fc 100644 --- a/tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php +++ b/tests/phpunit/tests/sitemaps/wpSitemapsRenderer.php @@ -277,24 +277,6 @@ public function test_deprecated_stylesheet_filters( string $hook_name, string $m $this->assertStringNotContainsString( 'assertSame( '', $sitemap_renderer->get_sitemap_stylesheet_url(), 'The sitemap stylesheet URL should be empty.' ); - $this->assertSame( '', $sitemap_renderer->get_sitemap_index_stylesheet_url(), 'The sitemap index stylesheet URL should be empty.' ); - } - /** * Data provider for {@see self::test_deprecated_stylesheet_filters()}. * @@ -329,6 +311,24 @@ public static function data_deprecated_stylesheet_filters(): array { ); } + /** + * Tests that the stylesheet URL methods are deprecated and return an empty string. + * + * @ticket 65593 + * + * @covers WP_Sitemaps_Renderer::get_sitemap_stylesheet_url + * @covers WP_Sitemaps_Renderer::get_sitemap_index_stylesheet_url + * + * @expectedDeprecated WP_Sitemaps_Renderer::get_sitemap_stylesheet_url + * @expectedDeprecated WP_Sitemaps_Renderer::get_sitemap_index_stylesheet_url + */ + public function test_stylesheet_url_methods_are_deprecated(): void { + $sitemap_renderer = new WP_Sitemaps_Renderer(); + + $this->assertSame( '', $sitemap_renderer->get_sitemap_stylesheet_url(), 'The sitemap stylesheet URL should be empty.' ); + $this->assertSame( '', $sitemap_renderer->get_sitemap_index_stylesheet_url(), 'The sitemap index stylesheet URL should be empty.' ); + } + /** * Test XML output for empty sitemap page renderer. * diff --git a/tests/phpunit/tests/term/defaultTopicCountScale.php b/tests/phpunit/tests/term/defaultTopicCountScale.php index 6b3033b1f791b..4492d9cc60ac0 100644 --- a/tests/phpunit/tests/term/defaultTopicCountScale.php +++ b/tests/phpunit/tests/term/defaultTopicCountScale.php @@ -14,7 +14,7 @@ class Tests_Term_DefaultTopicCountScale extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_counts + * @dataProvider data_scales_count_logarithmically * * @param int|string $count Number of posts with the tag. * @param int $expected Expected scaled count. @@ -28,7 +28,7 @@ public function test_scales_count_logarithmically( $count, $expected ) { * * @return array */ - public static function data_counts() { + public static function data_scales_count_logarithmically() { return array( 'zero' => array( 0, 0 ), 'one' => array( 1, 30 ), diff --git a/tests/phpunit/tests/term/getTheTerms.php b/tests/phpunit/tests/term/getTheTerms.php index 0b7bbb8e68624..134d2bd604da8 100644 --- a/tests/phpunit/tests/term/getTheTerms.php +++ b/tests/phpunit/tests/term/getTheTerms.php @@ -222,7 +222,7 @@ public function test_uncached_terms_should_not_be_primed_with_a_single_query_by_ * @ticket 40306 * @ticket 49799 * - * @dataProvider data_term_cache_priming_functions + * @dataProvider data_term_cache_should_be_invalidated_on_set_object_terms * * @param string $priming_function Function used to prime the empty relationship cache. */ @@ -272,7 +272,7 @@ public function test_term_cache_should_be_invalidated_on_set_object_terms( $prim * * @return array[] */ - public static function data_term_cache_priming_functions() { + public static function data_term_cache_should_be_invalidated_on_set_object_terms() { return array( 'get_the_terms' => array( 'get_the_terms' ), 'update_object_term_cache' => array( 'update_object_term_cache' ), diff --git a/tests/phpunit/tests/theme/locateTemplate.php b/tests/phpunit/tests/theme/locateTemplate.php index a97e228ebc846..b6b198907d1c0 100644 --- a/tests/phpunit/tests/theme/locateTemplate.php +++ b/tests/phpunit/tests/theme/locateTemplate.php @@ -35,7 +35,7 @@ public function tear_down() { * * @ticket 65819 * - * @dataProvider data_template_names_with_parent_directory_segment + * @dataProvider data_should_restrict_template_names_with_parent_directory_segment * * @param string $stylesheet Stylesheet of the theme to switch to. * @param string|string[] $template_names Template file(s) to search for. @@ -52,7 +52,7 @@ public function test_should_restrict_template_names_with_parent_directory_segmen * * @return array[] */ - public static function data_template_names_with_parent_directory_segment() { + public static function data_should_restrict_template_names_with_parent_directory_segment() { $themes = DIR_TESTDATA . '/themedir1'; $theme_compat = ABSPATH . WPINC . '/theme-compat'; diff --git a/tests/phpunit/tests/theme/wpIsTemplatePathAllowed.php b/tests/phpunit/tests/theme/wpIsTemplatePathAllowed.php index edf07cfddd32a..2042d3c316ff7 100644 --- a/tests/phpunit/tests/theme/wpIsTemplatePathAllowed.php +++ b/tests/phpunit/tests/theme/wpIsTemplatePathAllowed.php @@ -14,7 +14,7 @@ class Tests_Theme_wpIsTemplatePathAllowed extends WP_UnitTestCase { * * @ticket 65819 * - * @dataProvider data_paths_without_parent_directory_segment + * @dataProvider data_should_allow_path_without_parent_directory_segment * * @param string $path Path to check. */ @@ -29,7 +29,7 @@ public function test_should_allow_path_without_parent_directory_segment( $path ) * * @return array[] */ - public static function data_paths_without_parent_directory_segment() { + public static function data_should_allow_path_without_parent_directory_segment() { return array( 'an empty string' => array( '' ), 'a string zero' => array( '0' ), @@ -48,7 +48,7 @@ public static function data_paths_without_parent_directory_segment() { * * @ticket 65819 * - * @dataProvider data_paths_with_parent_directory_segment + * @dataProvider data_should_resolve_path_with_parent_directory_segment * * @param string $stylesheet Stylesheet of the theme to switch to. * @param string $path Path to check. @@ -65,7 +65,7 @@ public function test_should_resolve_path_with_parent_directory_segment( $stylesh * * @return array[] */ - public static function data_paths_with_parent_directory_segment() { + public static function data_should_resolve_path_with_parent_directory_segment() { $themes = DIR_TESTDATA . '/themedir1'; $theme_compat = ABSPATH . WPINC . '/theme-compat'; @@ -148,7 +148,7 @@ public static function data_paths_with_parent_directory_segment() { * * @ticket 65819 * - * @dataProvider data_themes_in_subdirectory + * @dataProvider data_should_allow_parent_directory_of_theme_in_subdirectory * * @param string $stylesheet Stylesheet of the child theme. * @param string $template Stylesheet of the parent theme. @@ -168,7 +168,7 @@ public function test_should_allow_parent_directory_of_theme_in_subdirectory( $st * * @return array[] */ - public static function data_themes_in_subdirectory() { + public static function data_should_allow_parent_directory_of_theme_in_subdirectory() { $themes = DIR_TESTDATA . '/themedir1'; return array( diff --git a/tests/phpunit/tests/theme/wpThemeJson.php b/tests/phpunit/tests/theme/wpThemeJson.php index 12feba3b3ab4f..230bea50620e7 100644 --- a/tests/phpunit/tests/theme/wpThemeJson.php +++ b/tests/phpunit/tests/theme/wpThemeJson.php @@ -2902,7 +2902,7 @@ public function test_get_stylesheet_generates_layout_styles() { /** * @ticket 66263 * - * @dataProvider data_get_stylesheet_with_axial_block_gap + * @dataProvider data_get_stylesheet_generates_layout_styles_with_axial_block_gap * * @param array $block_gap Block gap value. * @param string $expected_row_gap Expected row gap value. @@ -2943,7 +2943,7 @@ public function test_get_stylesheet_generates_layout_styles_with_axial_block_gap * * @return array[] Test data. */ - public static function data_get_stylesheet_with_axial_block_gap() { + public static function data_get_stylesheet_generates_layout_styles_with_axial_block_gap() { return array( 'different row and column gaps' => array( array( diff --git a/tests/phpunit/tests/user/newUserEmailAdminNotice.php b/tests/phpunit/tests/user/newUserEmailAdminNotice.php index 6c358493579e4..742a0a7a421fc 100644 --- a/tests/phpunit/tests/user/newUserEmailAdminNotice.php +++ b/tests/phpunit/tests/user/newUserEmailAdminNotice.php @@ -150,7 +150,7 @@ public function test_should_not_display_notice_outside_profile_screen() { * * @group ms-required * - * @dataProvider data_multisite_admin_notice_actions + * @dataProvider data_should_not_be_hooked_to_multisite_admin_notice_actions * * @param string $hook_name Admin notice action name. */ @@ -165,7 +165,7 @@ public function test_should_not_be_hooked_to_multisite_admin_notice_actions( $ho * * @return array[] */ - public static function data_multisite_admin_notice_actions() { + public static function data_should_not_be_hooked_to_multisite_admin_notice_actions() { return array( 'user_admin_notices' => array( 'user_admin_notices' ), 'network_admin_notices' => array( 'network_admin_notices' ), diff --git a/tests/phpunit/tests/user/wpRoles.php b/tests/phpunit/tests/user/wpRoles.php index 27bb091efd769..7a1aa5182cd2a 100644 --- a/tests/phpunit/tests/user/wpRoles.php +++ b/tests/phpunit/tests/user/wpRoles.php @@ -61,7 +61,7 @@ public function test_should_return_existing_roles_instance() { * * @ticket 65819 * - * @dataProvider data_values_other_than_roles_instance + * @dataProvider data_should_replace_global_which_is_not_roles_instance * * @param mixed $value Value the global was overwritten with. */ @@ -79,7 +79,7 @@ public function test_should_replace_global_which_is_not_roles_instance( $value ) * * @return array[] */ - public static function data_values_other_than_roles_instance() { + public static function data_should_replace_global_which_is_not_roles_instance() { return array( 'a role name' => array( 'administrator' ), 'another object' => array( new stdClass() ), diff --git a/tests/phpunit/tests/view-config.php b/tests/phpunit/tests/view-config.php index 1d84c7e676113..05c6daad78fdd 100644 --- a/tests/phpunit/tests/view-config.php +++ b/tests/phpunit/tests/view-config.php @@ -231,7 +231,7 @@ public static function data_post_types_with_own_form() { * @covers ::_wp_get_default_posttype_form * @covers ::_wp_get_entity_view_config_posttype_wp_block * - * @dataProvider data_post_types_with_excerpt_in_form + * @dataProvider data_excerpt_layout_shows_placeholder_if_empty * * @param string $post_type The post type. */ @@ -257,7 +257,7 @@ public function test_excerpt_layout_shows_placeholder_if_empty( $post_type ) { * * @return array[] */ - public static function data_post_types_with_excerpt_in_form() { + public static function data_excerpt_layout_shows_placeholder_if_empty() { return array( 'page' => array( 'page' ), 'post' => array( 'post' ), @@ -296,7 +296,7 @@ public function test_wp_template_description_layout_shows_placeholder_if_empty() * @covers ::_wp_get_default_posttype_form * @covers ::_wp_get_entity_view_config_posttype_attachment * - * @dataProvider data_post_types_with_author_in_form + * @dataProvider data_author_layout_shows_placeholder_if_empty * * @param string $post_type The post type. */ @@ -321,7 +321,7 @@ public function test_author_layout_shows_placeholder_if_empty( $post_type ) { * * @return array[] */ - public static function data_post_types_with_author_in_form() { + public static function data_author_layout_shows_placeholder_if_empty() { return array( 'page' => array( 'page' ), 'post' => array( 'post' ), diff --git a/tests/phpunit/tests/widgets/wpConvertWidgetSettings.php b/tests/phpunit/tests/widgets/wpConvertWidgetSettings.php index 6b87fb78594bd..c9d0c7caaaf56 100644 --- a/tests/phpunit/tests/widgets/wpConvertWidgetSettings.php +++ b/tests/phpunit/tests/widgets/wpConvertWidgetSettings.php @@ -64,7 +64,7 @@ public function tear_down() { * * @ticket 65819 * - * @dataProvider data_multi_widget_settings + * @dataProvider data_keeps_multi_widget_settings * * @param array $settings Widget settings. */ @@ -79,7 +79,7 @@ public function test_keeps_multi_widget_settings( $settings ) { * * @return array[] */ - public static function data_multi_widget_settings() { + public static function data_keeps_multi_widget_settings() { return array( 'numbered instances' => array( array( @@ -106,7 +106,7 @@ public static function data_multi_widget_settings() { * * @ticket 65819 * - * @dataProvider data_single_widget_settings + * @dataProvider data_converts_single_widget_settings_on_front_end * * @param mixed $settings Widget settings. */ @@ -133,7 +133,7 @@ public function test_converts_single_widget_settings_on_front_end( $settings ) { * * @return array[] */ - public static function data_single_widget_settings() { + public static function data_converts_single_widget_settings_on_front_end() { return array( 'single widget settings' => array( array( 'title' => 'Search' ) ), 'mixed keys' => array( diff --git a/tests/phpunit/tests/widgets/wpNavMenuWidget.php b/tests/phpunit/tests/widgets/wpNavMenuWidget.php index e73ddfd38adc8..1e31ea9febe15 100644 --- a/tests/phpunit/tests/widgets/wpNavMenuWidget.php +++ b/tests/phpunit/tests/widgets/wpNavMenuWidget.php @@ -157,7 +157,7 @@ public function test_widget_outputs_navigation_menu() { * * @covers WP_Nav_Menu_Widget::widget * - * @dataProvider data_widget_invalid_nav_menu + * @dataProvider data_widget_outputs_nothing_without_valid_menu * * @param array $instance Widget instance. */ @@ -170,7 +170,7 @@ public function test_widget_outputs_nothing_without_valid_menu( $instance ) { * * @return array[] */ - public static function data_widget_invalid_nav_menu() { + public static function data_widget_outputs_nothing_without_valid_menu() { return array( 'missing nav_menu' => array( array() ), 'nonexistent nav_menu' => array( array( 'nav_menu' => 999999 ) ), @@ -324,7 +324,7 @@ public function test_widget_omits_navigation_wrapper_in_xhtml() { * * @covers WP_Nav_Menu_Widget::widget * - * @dataProvider data_widget_nav_menu_args + * @dataProvider data_widget_applies_widget_nav_menu_args_filter * * @param string $format Navigation widgets format. * @param string $title Widget title setting. @@ -362,7 +362,7 @@ public function test_widget_applies_widget_nav_menu_args_filter( $format, $title * * @return array[] */ - public static function data_widget_nav_menu_args() { + public static function data_widget_applies_widget_nav_menu_args_filter() { return array( 'html5 format' => array( 'html5', diff --git a/tests/phpunit/tests/widgets/wpWidgetBlock.php b/tests/phpunit/tests/widgets/wpWidgetBlock.php index 8cd5a627917c1..ad286dbe603c3 100644 --- a/tests/phpunit/tests/widgets/wpWidgetBlock.php +++ b/tests/phpunit/tests/widgets/wpWidgetBlock.php @@ -164,7 +164,7 @@ static function () { * @covers WP_Widget_Block::widget * @covers WP_Widget_Block::get_dynamic_classname * - * @dataProvider data_dynamic_classname + * @dataProvider data_widget_dynamic_classname * * @param string $content Block content. * @param string $expected_classname Expected class attribute value on the wrapper. @@ -191,7 +191,7 @@ public function test_widget_dynamic_classname( $content, $expected_classname, $e * * @return array[] */ - public static function data_dynamic_classname() { + public static function data_widget_dynamic_classname() { return array( 'core/paragraph' => array( '

Text

', diff --git a/tests/phpunit/tests/widgets/wpWidgetLinks.php b/tests/phpunit/tests/widgets/wpWidgetLinks.php index 7fb1b7c8168a5..9a0c90dd9104f 100644 --- a/tests/phpunit/tests/widgets/wpWidgetLinks.php +++ b/tests/phpunit/tests/widgets/wpWidgetLinks.php @@ -191,7 +191,7 @@ public function test_widget_filters_by_category() { * * @covers WP_Widget_Links::widget * - * @dataProvider data_widget_links_args + * @dataProvider data_widget_applies_widget_links_args_filter * * @param array $instance Widget instance settings. * @param array $expected_args Expected arguments passed to wp_list_bookmarks(). @@ -226,7 +226,7 @@ public function test_widget_applies_widget_links_args_filter( $instance, $expect * * @return array[] */ - public static function data_widget_links_args() { + public static function data_widget_applies_widget_links_args_filter() { return array( 'default instance' => array( array(), diff --git a/tests/phpunit/tests/widgets/wpWidgetMeta.php b/tests/phpunit/tests/widgets/wpWidgetMeta.php index 37bfce12dc36d..82d6598c44a6b 100644 --- a/tests/phpunit/tests/widgets/wpWidgetMeta.php +++ b/tests/phpunit/tests/widgets/wpWidgetMeta.php @@ -70,7 +70,7 @@ public function test_constructor_sets_widget_options() { * * @covers ::widget * - * @dataProvider data_widget_titles + * @dataProvider data_widget_displays_title * * @param array $instance Widget instance settings. * @param string $expected Expected title. @@ -93,7 +93,7 @@ public function test_widget_displays_title( $instance, $expected ) { * * @return array[] */ - public static function data_widget_titles() { + public static function data_widget_displays_title() { return array( 'custom title' => array( array( 'title' => 'Site links' ), 'Site links' ), 'no title' => array( array(), 'Meta' ), @@ -133,7 +133,7 @@ public function test_widget_applies_widget_title_filter() { * * @covers ::widget * - * @dataProvider data_navigation_formats + * @dataProvider data_widget_navigation_wrapper * * @param string $format Navigation widgets markup format. * @param array $instance Widget instance settings. @@ -158,7 +158,7 @@ public function test_widget_navigation_wrapper( $format, $instance, $aria_label * * @return array[] */ - public static function data_navigation_formats() { + public static function data_widget_navigation_wrapper() { return array( 'xhtml' => array( 'xhtml', array( 'title' => 'Site links' ), null ), 'html5 with a custom title' => array( 'html5', array( 'title' => 'Site links' ), 'Site links' ), @@ -173,7 +173,7 @@ public static function data_navigation_formats() { * * @covers ::widget * - * @dataProvider data_filtered_titles_with_markup + * @dataProvider data_widget_navigation_label_strips_markup * * @param string $filtered_title Title returned by the widget_title filter. * @param string $aria_label Expected label of the nav element. @@ -200,7 +200,7 @@ static function () use ( $filtered_title ) { * * @return array[] */ - public static function data_filtered_titles_with_markup() { + public static function data_widget_navigation_label_strips_markup() { return array( 'markup around the text' => array( ' Site links ', 'Site links' ), 'title with a quote' => array( 'Site "links"', 'Site "links"' ), diff --git a/tests/phpunit/tests/widgets/wpWidgetPages.php b/tests/phpunit/tests/widgets/wpWidgetPages.php index e6a4a31577a02..e69cb64879087 100644 --- a/tests/phpunit/tests/widgets/wpWidgetPages.php +++ b/tests/phpunit/tests/widgets/wpWidgetPages.php @@ -283,7 +283,7 @@ public function test_widget_omits_navigation_wrapper_in_xhtml() { * * @covers WP_Widget_Pages::widget * - * @dataProvider data_widget_pages_args + * @dataProvider data_widget_applies_widget_pages_args_filter * * @param array $instance Widget instance. * @param string $sort_column Expected sort_column argument. @@ -318,7 +318,7 @@ public function test_widget_applies_widget_pages_args_filter( $instance, $sort_c * * @return array[] */ - public static function data_widget_pages_args() { + public static function data_widget_applies_widget_pages_args_filter() { return array( 'defaults' => array( array(), 'menu_order, post_title', '' ), 'ID with exclusions' => array( diff --git a/tests/phpunit/tests/widgets/wpWidgetRecentComments.php b/tests/phpunit/tests/widgets/wpWidgetRecentComments.php index e42701f11e00b..0f8820c85c175 100644 --- a/tests/phpunit/tests/widgets/wpWidgetRecentComments.php +++ b/tests/phpunit/tests/widgets/wpWidgetRecentComments.php @@ -186,7 +186,7 @@ public function test_construct() { * * @covers WP_Widget_Recent_Comments::__construct * - * @dataProvider data_construct_style_hook + * @dataProvider data_construct_hooks_styles_only_for_active_widget * * @param array $sidebars_widgets The widgets in each sidebar. * @param int|bool $expected Expected priority of the style callback, or false if it is not hooked. @@ -209,7 +209,7 @@ static function () use ( $sidebars_widgets ) { * * @return array[] */ - public static function data_construct_style_hook() { + public static function data_construct_hooks_styles_only_for_active_widget() { return array( 'widget in a sidebar' => array( array( 'sidebar-1' => array( 'recent-comments-2' ) ), 10 ), 'widget in the inactive widgets' => array( array( 'wp_inactive_widgets' => array( 'recent-comments-2' ) ), false ), diff --git a/tests/phpunit/tests/widgets/wpWidgetTagCloud.php b/tests/phpunit/tests/widgets/wpWidgetTagCloud.php index 146ac52b1bfdc..051a74230a064 100644 --- a/tests/phpunit/tests/widgets/wpWidgetTagCloud.php +++ b/tests/phpunit/tests/widgets/wpWidgetTagCloud.php @@ -310,7 +310,7 @@ public function test_widget_omits_navigation_wrapper_in_xhtml() { * * @covers WP_Widget_Tag_Cloud::widget * - * @dataProvider data_widget_tag_cloud_args + * @dataProvider data_widget_applies_widget_tag_cloud_args_filter * * @param array $instance Widget instance. * @param string $taxonomy Expected taxonomy argument. @@ -342,7 +342,7 @@ public function test_widget_applies_widget_tag_cloud_args_filter( $instance, $ta * * @return array[] */ - public static function data_widget_tag_cloud_args() { + public static function data_widget_applies_widget_tag_cloud_args_filter() { return array( 'defaults' => array( array(), 'post_tag', false ), 'count' => array( array( 'count' => 1 ), 'post_tag', true ), diff --git a/tests/phpunit/tests/wp/handle404.php b/tests/phpunit/tests/wp/handle404.php index 8c9aaadae3c87..a9320ed14e3ba 100644 --- a/tests/phpunit/tests/wp/handle404.php +++ b/tests/phpunit/tests/wp/handle404.php @@ -28,7 +28,7 @@ public function set_up() { * * @ticket 65945 * - * @dataProvider data_sitemap_requests + * @dataProvider data_sitemap_requests_should_not_be_404ed_by_an_empty_main_query * * @param non-falsy-string $url Sitemap URL to request. */ @@ -44,7 +44,7 @@ public function test_sitemap_requests_should_not_be_404ed_by_an_empty_main_query * * @return array */ - public static function data_sitemap_requests(): array { + public static function data_sitemap_requests_should_not_be_404ed_by_an_empty_main_query(): array { return array( 'index' => array( '/?sitemap=index' ), 'posts provider' => array( '/?sitemap=posts&sitemap-subtype=post' ), diff --git a/tests/phpunit/tests/wp/handleRandom.php b/tests/phpunit/tests/wp/handleRandom.php index 714382d5cf53d..4cf52ff5f459e 100644 --- a/tests/phpunit/tests/wp/handleRandom.php +++ b/tests/phpunit/tests/wp/handleRandom.php @@ -90,7 +90,7 @@ protected function handle_random( array $query_vars ): ?bool { * * @ticket 64498 * - * @dataProvider data_requests_without_the_random_query_var + * @dataProvider data_requests_without_the_random_query_var_are_not_handled * * @param array $query_vars Query variables for the request. */ @@ -107,7 +107,7 @@ public function test_requests_without_the_random_query_var_are_not_handled( arra * * @return array }> */ - public static function data_requests_without_the_random_query_var(): array { + public static function data_requests_without_the_random_query_var_are_not_handled(): array { return array( 'no query vars' => array( array() ), 'other query vars' => array( array( 'post_type' => 'post' ) ), @@ -158,7 +158,7 @@ public function test_random_content_queries_are_not_cached(): void { * * @ticket 64498 * - * @dataProvider data_requests_that_are_not_random_content_requests + * @dataProvider data_main_query_runs_unchanged_for_requests_that_are_not_random_content_requests * * @param array $query_vars Query variables for the request. * @param string $request_method HTTP request method. @@ -182,7 +182,7 @@ public function test_main_query_runs_unchanged_for_requests_that_are_not_random_ * * @return array, 1: non-falsy-string }> */ - public static function data_requests_that_are_not_random_content_requests(): array { + public static function data_main_query_runs_unchanged_for_requests_that_are_not_random_content_requests(): array { return array( 'post request' => array( array( 'random' => '' ), 'POST' ), 'non-randomable without posts' => array( @@ -201,7 +201,7 @@ public static function data_requests_that_are_not_random_content_requests(): arr * @ticket 64498 * @ticket 66625 * - * @dataProvider data_permalinks + * @dataProvider data_request_is_redirected_to_the_permalink_of_the_selected_post * * @param string $permalink Permalink of the selected post. */ @@ -224,7 +224,7 @@ static function () use ( $permalink ): string { * * @return array */ - public static function data_permalinks(): array { + public static function data_request_is_redirected_to_the_permalink_of_the_selected_post(): array { return array( 'permalink on this site' => array( 'http://' . WP_TESTS_DOMAIN . '/post/' ), 'permalink on another site' => array( 'https://elsewhere.example/post/' ), diff --git a/tests/phpunit/tests/xmlrpc/wp/getUsersBlogs.php b/tests/phpunit/tests/xmlrpc/wp/getUsersBlogs.php index 033db3708fda7..c82323ad699fd 100644 --- a/tests/phpunit/tests/xmlrpc/wp/getUsersBlogs.php +++ b/tests/phpunit/tests/xmlrpc/wp/getUsersBlogs.php @@ -17,7 +17,7 @@ class Tests_XMLRPC_wp_getUsersBlogs extends WP_XMLRPC_UnitTestCase { * * @ticket 65600 * - * @dataProvider data_non_scalar_credentials + * @dataProvider data_non_scalar_credentials_should_return_error * * @param mixed $username Username argument. * @param mixed $password Password argument. @@ -35,7 +35,7 @@ public function test_non_scalar_credentials_should_return_error( $username, $pas * * @return array */ - public static function data_non_scalar_credentials(): array { + public static function data_non_scalar_credentials_should_return_error(): array { return array( 'an array as password' => array( 'subscriber', array() ), 'an array as username' => array( array(), 'subscriber' ),