Make WordPress Core


Ignore:
Timestamp:
03/19/2023 12:03:30 PM (16 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/formatting/sanitizeTextField.php

    r55062 r55562  
    88 */
    99class Tests_Formatting_SanitizeTextField extends WP_UnitTestCase {
     10
     11    /**
     12     * @ticket 32257
     13     * @dataProvider data_sanitize_text_field
     14     */
     15    public function test_sanitize_text_field( $str, $expected ) {
     16        if ( is_array( $expected ) ) {
     17            $expected_oneline   = $expected['oneline'];
     18            $expected_multiline = $expected['multiline'];
     19        } else {
     20            $expected_oneline   = $expected;
     21            $expected_multiline = $expected;
     22        }
     23        $this->assertSame( $expected_oneline, sanitize_text_field( $str ) );
     24        $this->assertSameIgnoreEOL( $expected_multiline, sanitize_textarea_field( $str ) );
     25
     26    }
     27
    1028    public function data_sanitize_text_field() {
    1129        return array(
     
    127145        );
    128146    }
    129 
    130     /**
    131      * @ticket 32257
    132      * @dataProvider data_sanitize_text_field
    133      */
    134     public function test_sanitize_text_field( $str, $expected ) {
    135         if ( is_array( $expected ) ) {
    136             $expected_oneline   = $expected['oneline'];
    137             $expected_multiline = $expected['multiline'];
    138         } else {
    139             $expected_oneline   = $expected;
    140             $expected_multiline = $expected;
    141         }
    142         $this->assertSame( $expected_oneline, sanitize_text_field( $str ) );
    143         $this->assertSameIgnoreEOL( $expected_multiline, sanitize_textarea_field( $str ) );
    144 
    145     }
    146147}
Note: See TracChangeset for help on using the changeset viewer.