WordPress.org

Make WordPress Core

Changeset 471 in tests


Ignore:
Timestamp:
11/02/2011 05:43:36 PM (7 years ago)
Author:
ryan
Message:

remove_accents() tests. Props ampt. see #WP9591

Files:
16 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/jacob/TestFormatting.php

    r405 r471  
    8282
    8383/*
    84 Removes accents from characters and decomposes ligatures.
    85 */
    86 class Test_Remove_Accents extends _WPFormattingTest {
    87    
    88     /*
    89     http://www.alanwood.net/unicode/latin_1_supplement.html
    90 
    91     unicode-latin-1-supplement is identical to iso-8859-1, so these
    92     tests on their own will never take the unicode codepath
    93     */   
    94     function test_removes_accents_from_decomposable_latin1_supplement() {
    95         $this->file_test("removes_accents_from_decomposable_latin1_supplement",
    96             "remove_accents");
    97     }
    98    
    99     /*
    100     Several characters, such as eth and thorn, do not have a unicode
    101     decomposition, but should be replaced. The eth, for example, should become
    102     "d" or "dh", and the thorn "th". They require special rules.
    103     */
    104     function test_removes_accents_from_undecomposable_latin1_supplement() {
    105         $this->file_test("removes_accents_from_undecomposable_latin1_supplement",
    106             "remove_accents");
    107     }   
    108     function test_removes_accents_from_latin1_supplement() {
    109         $this->file_test("removes_accents_from_latin1_supplement",
    110             "remove_accents");
    111     }
    112 
    113     function test_removes_accents_from_decomposable_latin_extended_a() {
    114         $this->file_test("removes_accents_from_decomposable_latin_extended_a",
    115             "remove_accents");
    116     }   
    117     function test_removes_accents_from_undecomposable_latin_extended_a() {
    118         $this->file_test("removes_accents_from_undecomposable_latin_extended_a",
    119             "remove_accents");
    120     }   
    121     function test_removes_accents_from_latin_extended_a() {
    122         $this->file_test("removes_accents_from_latin_extended_a",
    123             "remove_accents");
    124     }
    125 
    126     // Currently this test fails because the unicode codepath (seems_utf8 == true)
    127     // can't handle non-decomposable characters (eth and friends).
    128     function test_removes_accents_from_latin1_supplement_and_latin_extended_a() {
    129         $this->file_test("removes_accents_from_latin1_supplement_and_latin_extended_a",
    130             "remove_accents");
    131     }
    132 }
    133 
    134 /*
    13584Decodes text in RFC2047 "Q"-encoding, e.g.
    13685
  • wp-testcase/test_includes_formatting.php

    r442 r471  
    11651165}
    11661166
     1167class TestRemoveAccents extends WPTestCase {
     1168    public function test_remove_accents_simple() {
     1169        $this->assertEquals( 'abcdefghijkl', remove_accents( 'abcdefghijkl' ) );
     1170    }
     1171
     1172    public function test_remove_accents_latin1_supplement() {
     1173        $this->knownWPBug(9591);
     1174
     1175        $input = 'ªºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ';
     1176        $output = 'aoAAAAAAAECEEEEIIIIDNOOOOOOUUUUYTHsaaaaaaaeceeeeiiiidnoooooouuuuythy';
     1177
     1178        $this->assertEquals( $output, remove_accents( $input ), 'remove_accents replaces Latin-1 Supplement' );
     1179    }
     1180
     1181    public function test_remove_accents_latin_extended_a() {
     1182        $input = 'ĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſ';
     1183        $output = 'AaAaAaCcCcCcCcDdDdEeEeEeEeEeGgGgGgGgHhHhIiIiIiIiIiIJijJjKkkLlLlLlLlLlNnNnNnNnNOoOoOoOEoeRrRrRrSsSsSsSsTtTtTtUuUuUuUuUuUuWwYyYZzZzZzs';
     1184
     1185        $this->assertEquals( $output, remove_accents( $input ), 'remove_accents replaces Latin Extended A' );
     1186    }
     1187
     1188    public function test_remove_accents_latin_extended_b() {
     1189        $this->assertEquals( 'SsTt', remove_accents( 'ȘșȚț' ), 'remove_accents replaces Latin Extended B' );
     1190    }
     1191
     1192    public function test_remove_accents_euro_pound_signs() {
     1193        $this->assertEquals( 'E', remove_accents( '€' ), 'remove_accents replaces euro sign' );
     1194        $this->assertEquals( '', remove_accents( '£' ), 'remove_accents replaces pound sign' );
     1195    }
     1196
     1197    public function test_remove_accents_iso8859() {
     1198        // File is Latin1 encoded
     1199        $file = DIR_TESTDATA . DIRECTORY_SEPARATOR . 'formatting' . DIRECTORY_SEPARATOR . 'remove_accents.01.input.txt';
     1200        $input = file_get_contents( $file );
     1201        $input = trim( $input );
     1202        $output = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyyOEoeAEDHTHssaedhth";
     1203
     1204        $this->assertEquals( $output, remove_accents( $input ), 'remove_accents from ISO-8859-1 text' );
     1205    }
     1206}
     1207
    11671208?>
  • wp-testdata/jacob/removes_accents_from_decomposable_latin1_supplement.input.txt

    r121 r471  
    1 
  • wp-testdata/jacob/removes_accents_from_decomposable_latin1_supplement.output.txt

    r121 r471  
    1 AAAAAACEEEEIIIINOOOOOUUUUYaaaaaaceeeeiiiinooooouuuuyy
  • wp-testdata/jacob/removes_accents_from_decomposable_latin_extended_a.input.txt

    r121 r471  
    1 AaAaAaCcCcCcCcDdEeEeEeEeEeGgGgGgGgHhIiIiIiIiIJjKkLlLlLlNnNnNnOoOoOoRrRrRrSsSsSsŠšTtTtUuUuUuUuUuUuWwYyŸZzZzŽž
  • wp-testdata/jacob/removes_accents_from_decomposable_latin_extended_a.output.txt

    r121 r471  
    1 AaAaAaCcCcCcCcDdEeEeEeEeEeGgGgGgGgHhIiIiIiIiIJjKkLlLlLlNnNnNnOoOoOoRrRrRrSsSsSsSsTtTtUuUuUuUuUuUuWwYyYZzZzZz
  • wp-testdata/jacob/removes_accents_from_latin1_supplement.input.txt

    r121 r471  
    1 
  • wp-testdata/jacob/removes_accents_from_latin1_supplement.output.txt

    r121 r471  
    1 AAAAAACEEEEIIIINOOOOOUUUUYaaaaaaceeeeiiiinooooouuuuyyAEDHOTHssaedhoth
  • wp-testdata/jacob/removes_accents_from_latin1_supplement_and_latin_extended_a.input.txt

    r121 r471  
    1 ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïñòóôõöùúûüýÿÆÐØÞßæðøþAaAaAaCcCcCcCcDdEeEeEeEeEeGgGgGgGgHhIiIiIiIiIJjKkLlLlLlNnNnNnOoOoOoRrRrRrSsSsSsŠšTtTtUuUuUuUuUuUuWwYyŸZzZzŽž??????
  • wp-testdata/jacob/removes_accents_from_latin1_supplement_and_latin_extended_a.output.txt

    r121 r471  
    1 AAAAAACEEEEIIIINOOOOOUUUUYaaaaaaceeeeiiiinooooouuuuyyAEDHOTHssaedhothAaAaAaCcCcCcCcDdEeEeEeEeEeGgGgGgGgHhIiIiIiIiIJjKkLlLlLlNnNnNnOoOoOoRrRrRrSsSsSsSsTtTtUuUuUuUuUuUuWwYyYZzZzZzIJijLlNs
  • wp-testdata/jacob/removes_accents_from_latin_extended_a.input.txt

    r121 r471  
    1 AaAaAaCcCcCcCcDdEeEeEeEeEeGgGgGgGgHhIiIiIiIiIJjKkLlLlLlNnNnNnOoOoOoRrRrRrSsSsSsŠšTtTtUuUuUuUuUuUuWwYyŸZzZzŽž??????
  • wp-testdata/jacob/removes_accents_from_latin_extended_a.output.txt

    r121 r471  
    1 AaAaAaCcCcCcCcDdEeEeEeEeEeGgGgGgGgHhIiIiIiIiIJjKkLlLlLlNnNnNnOoOoOoRrRrRrSsSsSsSsTtTtUuUuUuUuUuUuWwYyYZzZzZzIJijLlNs
  • wp-testdata/jacob/removes_accents_from_undecomposable_latin1_supplement.input.txt

    r121 r471  
    1 
  • wp-testdata/jacob/removes_accents_from_undecomposable_latin1_supplement.output.txt

    r121 r471  
    1 AEDHOTHssaedhoth
  • wp-testdata/jacob/removes_accents_from_undecomposable_latin_extended_a.input.txt

    r121 r471  
    1 ??????
  • wp-testdata/jacob/removes_accents_from_undecomposable_latin_extended_a.output.txt

    r121 r471  
    1 IJijLlNs
Note: See TracChangeset for help on using the changeset viewer.