Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/SanitizeFileName.php

    r37756 r42343  
    1212
    1313    function test_removes_special_chars() {
    14         $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", "%", "+", chr(0));
    15         $string = 'test';
    16         foreach ( $special_chars as $char )
     14        $special_chars = array( '?', '[', ']', '/', '\\', '=', '<', '>', ':', ';', ',', "'", '"', '&', '$', '#', '*', '(', ')', '|', '~', '`', '!', '{', '}', '%', '+', chr( 0 ) );
     15        $string        = 'test';
     16        foreach ( $special_chars as $char ) {
    1717            $string .= $char;
     18        }
    1819        $string .= 'test';
    1920        $this->assertEquals( 'testtest', sanitize_file_name( $string ) );
     
    2728    function test_replace_spaces() {
    2829        $urls = array(
    29             'unencoded space.png' => 'unencoded-space.png',
    30             'encoded-space.jpg' => 'encoded-space.jpg',
    31             'plus+space.jpg' => 'plusspace.jpg',
     30            'unencoded space.png'  => 'unencoded-space.png',
     31            'encoded-space.jpg'    => 'encoded-space.jpg',
     32            'plus+space.jpg'       => 'plusspace.jpg',
    3233            'multi %20 +space.png' => 'multi-20-space.png',
    3334        );
    3435
    35         foreach( $urls as $test => $expected ) {
     36        foreach ( $urls as $test => $expected ) {
    3637            $this->assertEquals( $expected, sanitize_file_name( $test ) );
    3738        }
     
    3940
    4041    function test_replaces_any_number_of_hyphens_with_one_hyphen() {
    41         $this->assertEquals("a-t-t", sanitize_file_name("a----t----t"));
     42        $this->assertEquals( 'a-t-t', sanitize_file_name( 'a----t----t' ) );
    4243    }
    4344
    4445    function test_trims_trailing_hyphens() {
    45         $this->assertEquals("a-t-t", sanitize_file_name("a----t----t----"));
     46        $this->assertEquals( 'a-t-t', sanitize_file_name( 'a----t----t----' ) );
    4647    }
    4748
    4849    function test_replaces_any_amount_of_whitespace_with_one_hyphen() {
    49         $this->assertEquals("a-t", sanitize_file_name("a          t"));
    50         $this->assertEquals("a-t", sanitize_file_name("a    \n\n\nt"));
     50        $this->assertEquals( 'a-t', sanitize_file_name( 'a          t' ) );
     51        $this->assertEquals( 'a-t', sanitize_file_name( "a    \n\n\nt" ) );
    5152    }
    5253
Note: See TracChangeset for help on using the changeset viewer.