Changeset 47122 for trunk/tests/phpunit/tests/formatting/WPTexturize.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/WPTexturize.php
r46586 r47122 33 33 } 34 34 35 //WP Ticket #1418 35 /** 36 * @ticket 1418 37 */ 36 38 function test_bracketed_quotes_1418() { 37 39 $this->assertEquals( '(“test”)', wptexturize( '("test")' ) ); … … 40 42 } 41 43 42 //WP Ticket #3810 44 /** 45 * @ticket 3810 46 */ 43 47 function test_bracketed_quotes_3810() { 44 48 $this->assertEquals( 'A dog (“Hubertus”) was sent out.', wptexturize( 'A dog ("Hubertus") was sent out.' ) ); 45 49 } 46 50 47 //WP Ticket #4539 51 /** 52 * @ticket 4539 53 */ 48 54 function test_basic_quotes() { 49 55 $this->assertEquals( 'test’s', wptexturize( 'test\'s' ) ); … … 81 87 function test_quotes() { 82 88 $this->assertEquals( '“Quoted String”', wptexturize( '"Quoted String"' ) ); 83 // $this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"'));84 // $this->assertEquals('Here is “<a href="http://example.com">a test with a link and a period</a>”.', wptexturize('Here is "<a href="http://example.com">a test with a link and a period</a>".'));89 // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>”', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"' ) ); 90 // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link and a period</a>”.', wptexturize( 'Here is "<a href="http://example.com">a test with a link and a period</a>".' ) ); 85 91 $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>” and a space.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>" and a space.' ) ); 86 92 $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a> and some text quoted”', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a> and some text quoted"' ) ); 87 // $this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”, 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 “<a href="http://example.com">a test with a link</a>”; 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 “<a href="http://example.com">a test with a link</a>”- 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 “<a href="http://example.com">a test with a link</a>”… and ellipses.', wptexturize('Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.'));91 // $this->assertEquals('Here is “a test <a href="http://example.com">with a link</a>”.', wptexturize('Here is "a test <a href="http://example.com">with a link</a>".'));92 // $this->assertEquals('Here is “<a href="http://example.com">a test with a link</a>”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 “<a href="http://example.com">a test with a link</a>”, 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 “<a href="http://example.com">a test with a link</a>”; 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 “<a href="http://example.com">a test with a link</a>”- 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 “<a href="http://example.com">a test with a link</a>”… and ellipses.', wptexturize( 'Here is "<a href="http://example.com">a test with a link</a>"... and ellipses.' ) ); 97 // $this->assertEquals( 'Here is “a test <a href="http://example.com">with a link</a>”.', wptexturize( 'Here is "a test <a href="http://example.com">with a link</a>".' ) ); 98 // $this->assertEquals( 'Here is “<a href="http://example.com">a test with a link</a>”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 99 $this->assertEquals( 'A test with a finishing number, “like 23”.', wptexturize( 'A test with a finishing number, "like 23".' ) ); 94 100 $this->assertEquals( 'A test with a number, “like 62”, is nice to have.', wptexturize( 'A test with a number, "like 62", is nice to have.' ) ); … … 132 138 $this->assertEquals( ' “Class of ’99”!', wptexturize( " \"Class of '99\"!" ) ); 133 139 $this->assertEquals( ' “Class of ’99”?', wptexturize( " \"Class of '99\"?" ) ); 134 $this->assertEquals( '}”Class of ’99″{', 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( '}”Class of ’99″{', wptexturize( "}\"Class of '99\"{" ) ); 135 142 } 136 143 … … 145 152 function test_other_html() { 146 153 $this->assertEquals( '‘<strong>', wptexturize( "'<strong>" ) ); 147 // $this->assertEquals('‘<strong>Quoted Text</strong>’,', wptexturize("'<strong>Quoted Text</strong>',"));148 // $this->assertEquals('“<strong>Quoted Text</strong>”,', wptexturize('"<strong>Quoted Text</strong>",'));154 // $this->assertEquals( '‘<strong>Quoted Text</strong>’,', wptexturize( "'<strong>Quoted Text</strong>'," ) ); 155 // $this->assertEquals( '“<strong>Quoted Text</strong>”,', wptexturize( '"<strong>Quoted Text</strong>",' ) ); 149 156 } 150 157 … … 189 196 function test_entity_quote_cuddling() { 190 197 $this->assertEquals( ' “Testing”', wptexturize( ' "Testing"' ) ); 191 // $this->assertEquals('&“Testing”', wptexturize('&"Testing"'));198 // $this->assertEquals( '&“Testing”', wptexturize( '&"Testing"' ) ); 192 199 } 193 200 … … 342 349 ), 343 350 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. 345 352 'according to our source, ’33 students scored less than 50′ on the test.', 346 353 ), … … 375 382 ), 376 383 array( 377 "word <'word word", // Invalid HTML384 "word <'word word", // Invalid HTML. 378 385 "word <'word word", 379 386 ), … … 388 395 array( 389 396 "word \"'word word", 390 'word “‘word word', // Two opening quotes 397 'word “‘word word', // Two opening quotes. 391 398 ), 392 399 array( … … 416 423 array( 417 424 "word\"'word word", 418 'word”‘word word', // Closing quote, then opening quote 425 'word”‘word word', // Closing quote, then opening quote. 419 426 ), 420 427 array( … … 444 451 array( 445 452 "word \"' word word", 446 'word “‘ word word', // Two opening quotes 453 'word “‘ word word', // Two opening quotes. 447 454 ), 448 455 array( … … 472 479 array( 473 480 "word\"' word word", 474 'word”‘ word word', // Closing quote, then opening quote 481 'word”‘ word word', // Closing quote, then opening quote. 475 482 ), 476 483 ); … … 537 544 ), 538 545 array( 539 "word99'word", // Not a prime anymore.546 "word99'word", // Not a prime anymore. 540 547 'word99’word', 541 548 ), … … 611 618 ), 612 619 array( 613 'word <"word word', // Invalid HTML 620 'word <"word word', // Invalid HTML. 614 621 'word <"word word', 615 622 ), … … 692 699 ), 693 700 array( 694 'word word"> word', // Invalid HTML input?701 'word word"> word', // Invalid HTML input? 695 702 'word word”> word', 696 703 ), 697 704 array( 698 'word word"> word', // Valid HTML should work 705 'word word"> word', // Valid HTML should work. 699 706 'word word”> word', 700 707 ), … … 845 852 * 846 853 * @ticket 22692 854 * @ticket 30445 847 855 * @dataProvider data_multiplication 848 856 */ … … 1292 1300 ), 1293 1301 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. 1299 1307 '[[gallery]]…[[/gallery]]', 1300 1308 ), 1301 1309 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. 1303 1311 '[[[gallery]]]…[[[/gallery]]]', 1304 1312 ), … … 1308 1316 ), 1309 1317 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. 1312 1320 ), 1313 1321 array( … … 1348 1356 ), 1349 1357 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. 1351 1359 '[[gallery <br ... /> ...]]', 1352 1360 ), … … 1444 1452 ), 1445 1453 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. 1447 1455 '[Let’s get crazy<input>[caption code=”<a href=\'?a[]=100\'>hello</a>“]</input>world]', 1448 1456 ), … … 1491 1499 ), 1492 1500 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. 1494 1502 'word ’99’ word', 1495 1503 ), … … 1856 1864 ), 1857 1865 array( 1858 '[code ...]...[/code]', // codeis not a registered shortcode.1866 '[code ...]...[/code]', // '[code]' is not a registered shortcode. 1859 1867 '[code …]…[/code]', 1860 1868 ), 1861 1869 array( 1862 '[hello ...]...[/hello]', // hellois not a registered shortcode.1870 '[hello ...]...[/hello]', // '[hello]' is not a registered shortcode. 1863 1871 '[hello …]…[/hello]', 1864 1872 ), 1865 1873 array( 1866 '[...]...[/...]', // These are potentially usable shortcodes.1874 '[...]...[/...]', // These are potentially usable shortcodes. 1867 1875 '[…]…[/…]', 1868 1876 ), … … 1876 1884 ), 1877 1885 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]…[/audio]…', 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]…[/audio]…', // 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. 1885 1893 array( 1886 1894 '<span>hello[/audio]---</span>', … … 1935 1943 ), 1936 1944 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. 1938 1946 'I need 4 x 20′ = 80′ of trim.', 1939 1947 ), … … 2031 2039 ), 2032 2040 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. 2034 2042 'I need 4 x 20!prime1! = 80!prime1! of trim.', 2035 2043 ), … … 2078 2086 global $shortcode_tags; 2079 2087 2080 // With Shortcodes Disabled2088 // With shortcodes disabled. 2081 2089 $regex = _get_wptexturize_split_regex(); 2082 2090 $result = benchmark_pcre_backtracking( $regex, $input, 'split' ); 2083 2091 $this->assertLessThan( 200, $result ); 2084 2092 2085 // With Shortcodes Enabled2093 // With shortcodes enabled. 2086 2094 $shortcode_regex = _get_wptexturize_shortcode_regex( array_keys( $shortcode_tags ) ); 2087 2095 $regex = _get_wptexturize_split_regex( $shortcode_regex );
Note: See TracChangeset
for help on using the changeset viewer.