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/formatting/sanitizeFileName.php

    r51623 r52010  
    55 */
    66class Tests_Formatting_SanitizeFileName extends WP_UnitTestCase {
    7     function test_munges_extensions() {
     7    public function test_munges_extensions() {
    88        // r17990
    99        $file_name = sanitize_file_name( 'test.phtml.txt' );
     
    1111    }
    1212
    13     function test_removes_special_chars() {
     13    public function test_removes_special_chars() {
    1414        $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', '’', '«', '»', '”', '“', chr( 0 ) );
    1515        $string        = 'test';
     
    2424     * @ticket 22363
    2525     */
    26     function test_removes_accents() {
     26    public function test_removes_accents() {
    2727        $in  = 'àáâãäåæçèéêëìíîïñòóôõöøùúûüýÿ';
    2828        $out = 'aaaaaaaeceeeeiiiinoooooouuuuyy';
     
    3535     * @ticket 16330
    3636     */
    37     function test_replaces_spaces() {
     37    public function test_replaces_spaces() {
    3838        $urls = array(
    3939            'unencoded space.png'  => 'unencoded-space.png',
     
    4848    }
    4949
    50     function test_replaces_any_number_of_hyphens_with_one_hyphen() {
     50    public function test_replaces_any_number_of_hyphens_with_one_hyphen() {
    5151        $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t' ) );
    5252    }
    5353
    54     function test_trims_trailing_hyphens() {
     54    public function test_trims_trailing_hyphens() {
    5555        $this->assertSame( 'a-t-t', sanitize_file_name( 'a----t----t----' ) );
    5656    }
    5757
    58     function test_replaces_any_amount_of_whitespace_with_one_hyphen() {
     58    public function test_replaces_any_amount_of_whitespace_with_one_hyphen() {
    5959        $this->assertSame( 'a-t', sanitize_file_name( 'a          t' ) );
    6060        $this->assertSame( 'a-t', sanitize_file_name( "a    \n\n\nt" ) );
     
    6464     * @ticket 16226
    6565     */
    66     function test_replaces_percent_sign() {
     66    public function test_replaces_percent_sign() {
    6767        $this->assertSame( 'a22b.jpg', sanitize_file_name( 'a%22b.jpg' ) );
    6868    }
    6969
    70     function test_replaces_unnamed_file_extensions() {
     70    public function test_replaces_unnamed_file_extensions() {
    7171        // Test filenames with both supported and unsupported extensions.
    7272        $this->assertSame( 'unnamed-file.exe', sanitize_file_name( '_.exe' ) );
     
    7474    }
    7575
    76     function test_replaces_unnamed_file_extensionless() {
     76    public function test_replaces_unnamed_file_extensionless() {
    7777        // Test a filenames that becomes extensionless.
    7878        $this->assertSame( 'no-extension', sanitize_file_name( '_.no-extension' ) );
     
    8282     * @dataProvider data_wp_filenames
    8383     */
    84     function test_replaces_invalid_utf8_characters( $input, $expected ) {
     84    public function test_replaces_invalid_utf8_characters( $input, $expected ) {
    8585        $this->assertSame( $expected, sanitize_file_name( $input ) );
    8686    }
    8787
    88     function data_wp_filenames() {
     88    public function data_wp_filenames() {
    8989        return array(
    9090            array( urldecode( '%B1myfile.png' ), 'myfile.png' ),
Note: See TracChangeset for help on using the changeset viewer.