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/rest-attachments-controller.php

    r55457 r55562  
    136136    }
    137137
    138     public static function disposition_provider() {
     138    /**
     139     * @dataProvider data_parse_disposition
     140     */
     141    public function test_parse_disposition( $header, $expected ) {
     142        $header_list = array( $header );
     143        $parsed      = WP_REST_Attachments_Controller::get_filename_from_disposition( $header_list );
     144        $this->assertSame( $expected, $parsed );
     145    }
     146
     147    public static function data_parse_disposition() {
    139148        return array(
    140149            // Types.
     
    166175            array( 'unknown; notfilename="foo.jpg"', null ),
    167176        );
    168     }
    169 
    170     /**
    171      * @dataProvider disposition_provider
    172      */
    173     public function test_parse_disposition( $header, $expected ) {
    174         $header_list = array( $header );
    175         $parsed      = WP_REST_Attachments_Controller::get_filename_from_disposition( $header_list );
    176         $this->assertSame( $expected, $parsed );
    177177    }
    178178
     
    12581258    }
    12591259
    1260     public static function attachment_roundtrip_provider() {
     1260    /**
     1261     * @dataProvider data_attachment_roundtrip_as_author
     1262     * @requires function imagejpeg
     1263     */
     1264    public function test_attachment_roundtrip_as_author( $raw, $expected ) {
     1265        wp_set_current_user( self::$author_id );
     1266        $this->assertFalse( current_user_can( 'unfiltered_html' ) );
     1267        $this->verify_attachment_roundtrip( $raw, $expected );
     1268    }
     1269
     1270    public static function data_attachment_roundtrip_as_author() {
    12611271        return array(
    12621272            array(
     
    13531363            ),
    13541364        );
    1355     }
    1356 
    1357     /**
    1358      * @dataProvider attachment_roundtrip_provider
    1359      * @requires function imagejpeg
    1360      */
    1361     public function test_post_roundtrip_as_author( $raw, $expected ) {
    1362         wp_set_current_user( self::$author_id );
    1363         $this->assertFalse( current_user_can( 'unfiltered_html' ) );
    1364         $this->verify_attachment_roundtrip( $raw, $expected );
    13651365    }
    13661366
Note: See TracChangeset for help on using the changeset viewer.