Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

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

    r46586 r47122  
    3333        }
    3434
    35         //WP Ticket #1418
     35        /**
     36         * @ticket 1418
     37         */
    3638        function test_bracketed_quotes_1418() {
    3739                $this->assertEquals( '(“test”)', wptexturize( '("test")' ) );
     
    4042        }
    4143
    42         //WP Ticket #3810
     44        /**
     45         * @ticket 3810
     46         */
    4347        function test_bracketed_quotes_3810() {
    4448                $this->assertEquals( 'A dog (“Hubertus”) was sent out.', wptexturize( 'A dog ("Hubertus") was sent out.' ) );
    4549        }
    4650
    47         //WP Ticket #4539
     51        /**
     52         * @ticket 4539
     53         */
    4854        function test_basic_quotes() {
    4955                $this->assertEquals( 'test’s', wptexturize( 'test\'s' ) );
     
    8187        function test_quotes() {
    8288                $this->assertEquals( '“Quoted String”', wptexturize( '"Quoted String"' ) );
    83                 //$this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"'));
    84                 //$this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link and a period</a>&#8221;.', wptexturize('Here is "<a href="http://example.com">a test with a link and a period</a>".'));
     89                // $this->assertEquals( 'Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"' ) );
     90                // $this->assertEquals( 'Here is &#8220;<a href="http://example.com">a test with a link and a period</a>&#8221;.', wptexturize( 'Here is "<a href="http://example.com">a test with a link and a period</a>".' ) );
    8591                $this->assertEquals( 'Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221; and a space.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>" and a space.' ) );
    8692                $this->assertEquals( 'Here is &#8220;<a href="http://example.com">a test with a link</a> and some text quoted&#8221;', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a> and some text quoted"' ) );
    87                 //$this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;, and a comma.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>", and a comma.'));
    88                 //$this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;; and a semi-colon.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"; and a semi-colon.'));
    89                 //$this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;- and a dash.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"- and a dash.'));
    90                 //$this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;&#8230; and ellipses.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.'));
    91                 //$this->assertEquals('Here is &#8220;a test <a href="http://example.com">with a link</a>&#8221;.', wptexturize('Here is "a test <a href="http://example.com">with a link</a>".'));
    92                 //$this->assertEquals('Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;and a work stuck to the end.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"and a work stuck to the end.'));
     93                // $this->assertEquals( 'Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;, and a comma.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>", and a comma.' ) );
     94                // $this->assertEquals( 'Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;; and a semi-colon.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"; and a semi-colon.' ) );
     95                // $this->assertEquals( 'Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;- and a dash.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"- and a dash.' ) );
     96                // $this->assertEquals( 'Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;&#8230; and ellipses.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.' ) );
     97                // $this->assertEquals( 'Here is &#8220;a test <a href="http://example.com">with a link</a>&#8221;.', wptexturize( 'Here is "a test <a href="http://example.com">with a link</a>".' ) );
     98                // $this->assertEquals( 'Here is &#8220;<a href="http://example.com">a test with a link</a>&#8221;and a work stuck to the end.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"and a work stuck to the end.' ) );
    9399                $this->assertEquals( 'A test with a finishing number, &#8220;like 23&#8221;.', wptexturize( 'A test with a finishing number, "like 23".' ) );
    94100                $this->assertEquals( 'A test with a number, &#8220;like 62&#8221;, is nice to have.', wptexturize( 'A test with a number, "like 62", is nice to have.' ) );
     
    132138                $this->assertEquals( ' &#8220;Class of &#8217;99&#8221;!', wptexturize( " \"Class of '99\"!" ) );
    133139                $this->assertEquals( ' &#8220;Class of &#8217;99&#8221;?', wptexturize( " \"Class of '99\"?" ) );
    134                 $this->assertEquals( '}&#8221;Class of &#8217;99&#8243;{', wptexturize( "}\"Class of '99\"{" ) ); // Not a quotation, may be between two other quotations.
     140                // Not a quotation, may be between two other quotations.
     141                $this->assertEquals( '}&#8221;Class of &#8217;99&#8243;{', wptexturize( "}\"Class of '99\"{" ) );
    135142        }
    136143
     
    145152        function test_other_html() {
    146153                $this->assertEquals( '&#8216;<strong>', wptexturize( "'<strong>" ) );
    147                 //$this->assertEquals('&#8216;<strong>Quoted Text</strong>&#8217;,', wptexturize("'<strong>Quoted Text</strong>',"));
    148                 //$this->assertEquals('&#8220;<strong>Quoted Text</strong>&#8221;,', wptexturize('"<strong>Quoted Text</strong>",'));
     154                // $this->assertEquals( '&#8216;<strong>Quoted Text</strong>&#8217;,', wptexturize( "'<strong>Quoted Text</strong>'," ) );
     155                // $this->assertEquals( '&#8220;<strong>Quoted Text</strong>&#8221;,', wptexturize( '"<strong>Quoted Text</strong>",' ) );
    149156        }
    150157
     
    189196        function test_entity_quote_cuddling() {
    190197                $this->assertEquals( '&nbsp;&#8220;Testing&#8221;', wptexturize( '&nbsp;"Testing"' ) );
    191                 //$this->assertEquals('&#38;&#8220;Testing&#8221;', wptexturize('&#38;"Testing"'));
     198                // $this->assertEquals( '&#38;&#8220;Testing&#8221;', wptexturize( '&#38;"Testing"' ) );
    192199        }
    193200
     
    342349                        ),
    343350                        array(
    344                                 "according to our source, '33 students scored less than 50' on the test.", // Apostrophes and primes have priority over quotes
     351                                "according to our source, '33 students scored less than 50' on the test.", // Apostrophes and primes have priority over quotes.
    345352                                'according to our source, &#8217;33 students scored less than 50&#8242; on the test.',
    346353                        ),
     
    375382                        ),
    376383                        array(
    377                                 "word <'word word", // Invalid HTML
     384                                "word <'word word",    // Invalid HTML.
    378385                                "word <'word word",
    379386                        ),
     
    388395                        array(
    389396                                "word \"'word word",
    390                                 'word &#8220;&#8216;word word', // Two opening quotes
     397                                'word &#8220;&#8216;word word', // Two opening quotes.
    391398                        ),
    392399                        array(
     
    416423                        array(
    417424                                "word\"'word word",
    418                                 'word&#8221;&#8216;word word', // Closing quote, then opening quote
     425                                'word&#8221;&#8216;word word', // Closing quote, then opening quote.
    419426                        ),
    420427                        array(
     
    444451                        array(
    445452                                "word \"' word word",
    446                                 'word &#8220;&#8216; word word', // Two opening quotes
     453                                'word &#8220;&#8216; word word', // Two opening quotes.
    447454                        ),
    448455                        array(
     
    472479                        array(
    473480                                "word\"' word word",
    474                                 'word&#8221;&#8216; word word', // Closing quote, then opening quote
     481                                'word&#8221;&#8216; word word', // Closing quote, then opening quote.
    475482                        ),
    476483                );
     
    537544                        ),
    538545                        array(
    539                                 "word99'word", // Not a prime anymore.
     546                                "word99'word",  // Not a prime anymore.
    540547                                'word99&#8217;word',
    541548                        ),
     
    611618                        ),
    612619                        array(
    613                                 'word <"word word', // Invalid HTML
     620                                'word <"word word', // Invalid HTML.
    614621                                'word <"word word',
    615622                        ),
     
    692699                        ),
    693700                        array(
    694                                 'word word"> word', // Invalid HTML input?
     701                                'word word"> word',    // Invalid HTML input?
    695702                                'word word&#8221;> word',
    696703                        ),
    697704                        array(
    698                                 'word word"&gt; word', // Valid HTML should work
     705                                'word word"&gt; word', // Valid HTML should work.
    699706                                'word word&#8221;&gt; word',
    700707                        ),
     
    845852         *
    846853         * @ticket 22692
     854         * @ticket 30445
    847855         * @dataProvider data_multiplication
    848856         */
     
    12921300                        ),
    12931301                        array(
    1294                                 '[/gallery ...]', // This would actually be ignored by the shortcode system.  The decision to not texturize it is intentional, if not correct.
    1295                                 '[/gallery ...]',
    1296                         ),
    1297                         array(
    1298                                 '[[gallery]]...[[/gallery]]', // Shortcode parsing will ignore the inner ]...[ part and treat this as a single escaped shortcode.
     1302                                '[/gallery ...]', // This would actually be ignored by the shortcode system.
     1303                                '[/gallery ...]', // The decision to not texturize it is intentional, if not correct.
     1304                        ),
     1305                        array(
     1306                                '[[gallery]]...[[/gallery]]', // Shortcode parsing will ignore the inner ']...[' part and treat this as a single escaped shortcode.
    12991307                                '[[gallery]]&#8230;[[/gallery]]',
    13001308                        ),
    13011309                        array(
    1302                                 '[[[gallery]]]...[[[/gallery]]]', // Again, shortcode parsing matches, but only the [[gallery] and [/gallery]] parts.
     1310                                '[[[gallery]]]...[[[/gallery]]]', // Again, shortcode parsing matches, but only the '[[gallery]' and '[/gallery]]' parts.
    13031311                                '[[[gallery]]]&#8230;[[[/gallery]]]',
    13041312                        ),
     
    13081316                        ),
    13091317                        array(
    1310                                 '[gallery <br ... /> ...]', // This tag is still valid. Shortcode 'attributes' are not considered in the initial parsing of shortcodes, and HTML is allowed.
    1311                                 '[gallery <br ... /> ...]',
     1318                                '[gallery <br ... /> ...]', // This tag is still valid. Shortcode 'attributes' are not considered
     1319                                '[gallery <br ... /> ...]', // in the initial parsing of shortcodes, and HTML is allowed.
    13121320                        ),
    13131321                        array(
     
    13481356                        ),
    13491357                        array(
    1350                                 '[[gallery <br ... /> ...]]', // This gets parsed as an escaped shortcode with embedded HTML.  Brains may explode.
     1358                                '[[gallery <br ... /> ...]]', // This gets parsed as an escaped shortcode with embedded HTML. Brains may explode.
    13511359                                '[[gallery <br ... /> ...]]',
    13521360                        ),
     
    14441452                        ),
    14451453                        array(
    1446                                 '[Let\'s get crazy<input>[caption code="<a href=\'?a[]=100\'>hello</a>"]</input>world]', // caption shortcode is invalid here because it contains [] chars.
     1454                                '[Let\'s get crazy<input>[caption code="<a href=\'?a[]=100\'>hello</a>"]</input>world]', // [caption] shortcode is invalid here because it contains '[]' chars.
    14471455                                '[Let&#8217;s get crazy<input>[caption code=&#8221;<a href=\'?a[]=100\'>hello</a>&#8220;]</input>world]',
    14481456                        ),
     
    14911499                        ),
    14921500                        array(
    1493                                 "word '99' word", // For this pattern, prime doesn't make sense.  Should get apos and a closing quote.
     1501                                "word '99' word", // For this pattern, prime doesn't make sense. Should get apos and a closing quote.
    14941502                                'word &#8217;99&#8217; word',
    14951503                        ),
     
    18561864                        ),
    18571865                        array(
    1858                                 '[code ...]...[/code]', // code is not a registered shortcode.
     1866                                '[code ...]...[/code]',   // '[code]' is not a registered shortcode.
    18591867                                '[code &#8230;]&#8230;[/code]',
    18601868                        ),
    18611869                        array(
    1862                                 '[hello ...]...[/hello]', // hello is not a registered shortcode.
     1870                                '[hello ...]...[/hello]', // '[hello]' is not a registered shortcode.
    18631871                                '[hello &#8230;]&#8230;[/hello]',
    18641872                        ),
    18651873                        array(
    1866                                 '[...]...[/...]', // These are potentially usable shortcodes.
     1874                                '[...]...[/...]',         // These are potentially usable shortcodes.
    18671875                                '[&#8230;]&#8230;[/&#8230;]',
    18681876                        ),
     
    18761884                        ),
    18771885                        array(
    1878                                 '[[audio]...[/audio]...', // These are potentially usable shortcodes.  Unfortunately, the meaning of [[audio] is ambiguous unless we run the entire shortcode regexp.
    1879                                 '[[audio]&#8230;[/audio]&#8230;',
    1880                         ),
    1881                         array(
    1882                                 '[audio]...[/audio]]...', // These are potentially usable shortcodes.  Unfortunately, the meaning of [/audio]] is ambiguous unless we run the entire shortcode regexp.
    1883                                 '[audio]...[/audio]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize.
    1884                         ),
     1886                                '[[audio]...[/audio]...',         // These are potentially usable shortcodes.
     1887                                '[[audio]&#8230;[/audio]&#8230;', // Unfortunately, the meaning of [[audio] is ambiguous unless we run the entire shortcode regexp.
     1888                        ),
     1889                        array(
     1890                                '[audio]...[/audio]]...', // These are potentially usable shortcodes.
     1891                                '[audio]...[/audio]]...', // Unfortunately, the meaning of [/audio]] is ambiguous unless we run the entire shortcode regexp.
     1892                        ),                            // This test would not pass in 3.9 because the extra brace was always ignored by texturize.
    18851893                        array(
    18861894                                '<span>hello[/audio]---</span>',
     
    19351943                        ),
    19361944                        array(
    1937                                 "I need 4 x 20' = 80' of trim.", // Works only with a space before the = char.
     1945                                "I need 4 x 20' = 80' of trim.", // Works only with a space before the '=' char.
    19381946                                'I need 4 x 20&#8242; = 80&#8242; of trim.',
    19391947                        ),
     
    20312039                        ),
    20322040                        array(
    2033                                 "I need 4 x 20' = 80' of trim.", // Works only with a space before the = char.
     2041                                "I need 4 x 20' = 80' of trim.", // Works only with a space before the '=' char.
    20342042                                'I need 4 x 20!prime1! = 80!prime1! of trim.',
    20352043                        ),
     
    20782086                global $shortcode_tags;
    20792087
    2080                 // With Shortcodes Disabled
     2088                // With shortcodes disabled.
    20812089                $regex  = _get_wptexturize_split_regex();
    20822090                $result = benchmark_pcre_backtracking( $regex, $input, 'split' );
    20832091                $this->assertLessThan( 200, $result );
    20842092
    2085                 // With Shortcodes Enabled
     2093                // With shortcodes enabled.
    20862094                $shortcode_regex = _get_wptexturize_shortcode_regex( array_keys( $shortcode_tags ) );
    20872095                $regex           = _get_wptexturize_split_regex( $shortcode_regex );
Note: See TracChangeset for help on using the changeset viewer.