WordPress.org

Make WordPress Core

Ticket #22692: miqro-22692-tests.2.diff

File miqro-22692-tests.2.diff, 1.7 KB (added by miqrogroove, 7 years ago)
  • tests/formatting/WPTexturize.php

     
    194194                $this->assertEquals( ' — ', wptexturize( ' -- ' ) );
    195195                $this->assertEquals( ' — ', wptexturize( ' -- ') );
    196196        }
     197
     198        /**
     199         * @ticket 22692
     200         */
     201        function test_spaces_around_quotes() {
     202                $nbsp = "\xC2\xA0";
     203                $pi   = "\xCE\xA0";
     204
     205                // This should never happen, even if the desired output changes some day.
     206
     207                $problem_input = "$nbsp\"A";
     208                $problem_output = "$nbsp”A";
     209
     210                $this->assertNotEquals( $problem_output, wptexturize( $problem_input ) );
     211
     212                // These are desirable outputs for the current design.
     213
     214                $input1 = "A sentence. $nbsp\"A quote after 2 spaces.\"";
     215                $input2 = "A sentence.$nbsp$nbsp\"A quote after 2 spaces.\"";
     216                $input3 = "A sentence. $nbsp'A quote after 2 spaces.'";
     217                $input4 = "A sentence.$nbsp$nbsp'A quote after 2 spaces.'";
     218                $input5 = "Contraction: $pi's";
     219
     220                $output1 = "A sentence. $nbsp“A quote after 2 spaces.”";
     221                $output2 = "A sentence.$nbsp$nbsp“A quote after 2 spaces.”";
     222                $output3 = "A sentence. $nbsp‘A quote after 2 spaces.’";
     223                $output4 = "A sentence.$nbsp$nbsp‘A quote after 2 spaces.’";
     224                $output5 = "Contraction: $pi’s";
     225
     226                $this->assertEquals( $output1, wptexturize( $input1 ) );
     227                $this->assertEquals( $output2, wptexturize( $input2 ) );
     228                $this->assertEquals( $output3, wptexturize( $input3 ) );
     229                $this->assertEquals( $output4, wptexturize( $input4 ) );
     230                $this->assertEquals( $output5, wptexturize( $input5 ) );
     231        }
    197232}