Make WordPress Core

Ticket #16226: 16226-tests.patch

File 16226-tests.patch, 1.5 KB (added by mordauk, 9 years ago)
  • tests/phpunit/tests/formatting/SanitizeFileName.php

     
    1111        }
    1212
    1313        function test_removes_special_chars() {
    14                 $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
     14                $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", "%", "+", chr(0));
    1515                $string = 'test';
    1616                foreach ( $special_chars as $char )
    1717                        $string .= $char;
     
    2626         */
    2727        function test_replace_spaces() {
    2828                $urls = array(
    29                         'unencoded space.png'   => 'unencoded-space.png',
    30                         'encoded%20space.jpg'  => 'encoded-space.jpg',
    31                         'plus+space.jpg'        => 'plus-space.jpg',
    32                         'multi %20 +space.png'   => 'multi-space.png',
     29                        'unencoded space.png' => 'unencoded-space.png',
     30                        'encoded-space.jpg' => 'encoded-space.jpg',
     31                        'plus+space.jpg' => 'plusspace.jpg',
     32                        'multi %20 +space.png' => 'multi-20-space.png',
    3333                );
    3434
    3535                foreach( $urls as $test => $expected ) {
     
    4949                $this->assertEquals("a-t", sanitize_file_name("a          t"));
    5050                $this->assertEquals("a-t", sanitize_file_name("a    \n\n\nt"));
    5151        }
     52
     53        function test_replaces_percent_sign() {
     54                $this->assertEquals("a22b.jpg", sanitize_file_name("a%22b.jpg"));
     55        }
    5256}