Make WordPress Core


Ignore:
Timestamp:
11/04/2021 03:22:47 PM (3 years ago)
Author:
hellofromTonya
Message:

Coding Standards: Add visibility to methods in tests/phpunit/tests/.

Adds a public visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a private visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a _ prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api.php

    r51964 r52010  
    3131     * Checks that the main classes are loaded.
    3232     */
    33     function test_rest_api_active() {
     33    public function test_rest_api_active() {
    3434        $this->assertTrue( class_exists( 'WP_REST_Server' ) );
    3535        $this->assertTrue( class_exists( 'WP_REST_Request' ) );
     
    4242     * have a default priority of 10.
    4343     */
    44     function test_init_action_added() {
     44    public function test_init_action_added() {
    4545        $this->assertSame( 10, has_action( 'init', 'rest_api_init' ) );
    4646    }
     
    264264     * The rest_route query variable should be registered.
    265265     */
    266     function test_rest_route_query_var() {
     266    public function test_rest_route_query_var() {
    267267        rest_api_init();
    268268        $this->assertContains( 'rest_route', $GLOBALS['wp']->public_query_vars );
     
    934934    }
    935935
    936     function test_rest_preload_api_request_with_method() {
     936    public function test_rest_preload_api_request_with_method() {
    937937        $rest_server               = $GLOBALS['wp_rest_server'];
    938938        $GLOBALS['wp_rest_server'] = null;
     
    958958     * @ticket 51636
    959959     */
    960     function test_rest_preload_api_request_removes_trailing_slashes() {
     960    public function test_rest_preload_api_request_removes_trailing_slashes() {
    961961        $rest_server               = $GLOBALS['wp_rest_server'];
    962962        $GLOBALS['wp_rest_server'] = null;
     
    983983     * @ticket 40614
    984984     */
    985     function test_rest_ensure_request_accepts_path_string() {
     985    public function test_rest_ensure_request_accepts_path_string() {
    986986        $request = rest_ensure_request( '/wp/v2/posts' );
    987987        $this->assertInstanceOf( 'WP_REST_Request', $request );
     
    991991
    992992    /**
    993      * @dataProvider _dp_rest_parse_embed_param
     993     * @dataProvider data_rest_parse_embed_param
    994994     */
    995995    public function test_rest_parse_embed_param( $expected, $embed ) {
     
    997997    }
    998998
    999     public function _dp_rest_parse_embed_param() {
     999    public function data_rest_parse_embed_param() {
    10001000        return array(
    10011001            array( true, '' ),
     
    10201020     * @ticket 48819
    10211021     *
    1022      * @dataProvider _dp_rest_filter_response_by_context
     1022     * @dataProvider data_rest_filter_response_by_context
    10231023     */
    10241024    public function test_rest_filter_response_by_context( $schema, $data, $expected ) {
     
    11071107    }
    11081108
    1109     public function _dp_rest_filter_response_by_context() {
     1109    public function data_rest_filter_response_by_context() {
    11101110        return array(
    11111111            'default'                                      => array(
     
    17781778    }
    17791779
    1780     function test_rest_ensure_response_accepts_wp_error_and_returns_wp_error() {
     1780    public function test_rest_ensure_response_accepts_wp_error_and_returns_wp_error() {
    17811781        $response = rest_ensure_response( new WP_Error() );
    17821782        $this->assertInstanceOf( 'WP_Error', $response );
     
    17891789     * @param mixed $expected_data The expected data a response should include.
    17901790     */
    1791     function test_rest_ensure_response_returns_instance_of_wp_rest_response( $response, $expected_data ) {
     1791    public function test_rest_ensure_response_returns_instance_of_wp_rest_response( $response, $expected_data ) {
    17921792        $response_object = rest_ensure_response( $response );
    17931793        $this->assertInstanceOf( 'WP_REST_Response', $response_object );
     
    18001800     * @return array
    18011801     */
    1802     function rest_ensure_response_data_provider() {
     1802    public function rest_ensure_response_data_provider() {
    18031803        return array(
    18041804            array( null, null ),
     
    20102010     * @ticket 50300
    20112011     *
    2012      * @dataProvider _dp_rest_is_object
     2012     * @dataProvider data_rest_is_object
    20132013     *
    20142014     * @param bool  $expected Expected result of the check.
     
    20252025    }
    20262026
    2027     public function _dp_rest_is_object() {
     2027    public function data_rest_is_object() {
    20282028        return array(
    20292029            array(
     
    20732073     * @ticket 50300
    20742074     *
    2075      * @dataProvider _dp_rest_sanitize_object
     2075     * @dataProvider data_rest_sanitize_object
    20762076     *
    20772077     * @param array $expected Expected sanitized version.
     
    20832083    }
    20842084
    2085     public function _dp_rest_sanitize_object() {
     2085    public function data_rest_sanitize_object() {
    20862086        return array(
    20872087            array(
     
    21312131     * @ticket 50300
    21322132     *
    2133      * @dataProvider _dp_rest_is_array
     2133     * @dataProvider data_rest_is_array
    21342134     *
    21352135     * @param bool  $expected Expected result of the check.
     
    21462146    }
    21472147
    2148     public function _dp_rest_is_array() {
     2148    public function data_rest_is_array() {
    21492149        return array(
    21502150            array(
     
    22022202     * @ticket 50300
    22032203     *
    2204      * @dataProvider _dp_rest_sanitize_array
     2204     * @dataProvider data_rest_sanitize_array
    22052205     *
    22062206     * @param array $expected Expected sanitized version.
     
    22122212    }
    22132213
    2214     public function _dp_rest_sanitize_array() {
     2214    public function data_rest_sanitize_array() {
    22152215        return array(
    22162216            array(
     
    22722272     * @ticket 51146
    22732273     *
    2274      * @dataProvider _dp_rest_is_integer
     2274     * @dataProvider data_rest_is_integer
    22752275     *
    22762276     * @param bool  $expected Expected result of the check.
     
    22872287    }
    22882288
    2289     public function _dp_rest_is_integer() {
     2289    public function data_rest_is_integer() {
    22902290        return array(
    22912291            array(
     
    23352335     * @ticket 50300
    23362336     *
    2337      * @dataProvider _dp_get_best_type_for_value
     2337     * @dataProvider data_get_best_type_for_value
    23382338     *
    23392339     * @param string $expected The expected best type.
     
    23452345    }
    23462346
    2347     public function _dp_get_best_type_for_value() {
     2347    public function data_get_best_type_for_value() {
    23482348        return array(
    23492349            array(
Note: See TracChangeset for help on using the changeset viewer.