Make WordPress Core


Ignore:
Timestamp:
03/19/2023 12:03:30 PM (21 months ago)
Author:
SergeyBiryukov
Message:

Tests: Use the data_ prefix for various data provider methods.

This aims to bring more consistency to the test suite, as the vast majority of data providers already use that prefix.

Includes moving some data providers next to the tests they are used in.

Follow-up to [55464].

See #57841.

File:
1 edited

Legend:

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

    r55116 r55562  
    2626        remove_filter( 'wp_rest_server_class', array( $this, 'filter_wp_rest_server_class' ) );
    2727        parent::tear_down();
     28    }
     29
     30    public function filter_wp_rest_server_class( $class_name ) {
     31        return 'Spy_REST_Server';
    2832    }
    2933
     
    823827    }
    824828
    825     public function jsonp_callback_provider() {
     829    /**
     830     * @dataProvider data_jsonp_callback_check
     831     */
     832    public function test_jsonp_callback_check( $callback, $expected ) {
     833        $this->assertSame( $expected, wp_check_jsonp_callback( $callback ) );
     834    }
     835
     836    public function data_jsonp_callback_check() {
    826837        return array(
    827838            // Standard names.
     
    842853
    843854    /**
    844      * @dataProvider jsonp_callback_provider
    845      */
    846     public function test_jsonp_callback_check( $callback, $expected ) {
    847         $this->assertSame( $expected, wp_check_jsonp_callback( $callback ) );
    848     }
    849 
    850     public function rest_date_provider() {
     855     * @dataProvider data_rest_parse_date
     856     */
     857    public function test_rest_parse_date( $date, $expected ) {
     858        $this->assertEquals( $expected, rest_parse_date( $date ) );
     859    }
     860
     861    public function data_rest_parse_date() {
    851862        return array(
    852863            // Valid dates with timezones.
     
    874885
    875886    /**
    876      * @dataProvider rest_date_provider
    877      */
    878     public function test_rest_parse_date( $date, $expected ) {
    879         $this->assertEquals( $expected, rest_parse_date( $date ) );
    880     }
    881 
    882     public function rest_date_force_utc_provider() {
     887     * @dataProvider data_rest_parse_date_force_utc
     888     */
     889    public function test_rest_parse_date_force_utc( $date, $expected ) {
     890        $this->assertSame( $expected, rest_parse_date( $date, true ) );
     891    }
     892
     893    public function data_rest_parse_date_force_utc() {
    883894        return array(
    884895            // Valid dates with timezones.
     
    903914            array( '2017', false ),
    904915        );
    905     }
    906 
    907     /**
    908      * @dataProvider rest_date_force_utc_provider
    909      */
    910     public function test_rest_parse_date_force_utc( $date, $expected ) {
    911         $this->assertSame( $expected, rest_parse_date( $date, true ) );
    912     }
    913 
    914     public function filter_wp_rest_server_class( $class_name ) {
    915         return 'Spy_REST_Server';
    916916    }
    917917
     
    17841784
    17851785    /**
    1786      * @dataProvider rest_ensure_response_data_provider
     1786     * @dataProvider data_rest_ensure_response_returns_instance_of_wp_rest_response
    17871787     *
    17881788     * @param mixed $response      The response passed to rest_ensure_response().
     
    18001800     * @return array
    18011801     */
    1802     public function rest_ensure_response_data_provider() {
     1802    public function data_rest_ensure_response_returns_instance_of_wp_rest_response() {
    18031803        return array(
    18041804            array( null, null ),
Note: See TracChangeset for help on using the changeset viewer.