Changeset 29748 for trunk/tests/phpunit/tests/formatting/WPTexturize.php
- Timestamp:
- 09/17/2014 03:13:24 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/WPTexturize.php
r28971 r29748 12 12 function test_disable() { 13 13 $this->assertEquals('<pre>---</pre>', wptexturize('<pre>---</pre>')); 14 $this->assertEquals('[a]a–b[code]---[/code]a–b[/a]', wptexturize('[a]a--b[code]---[/code]a--b[/a]'));15 14 $this->assertEquals('<pre><code></code>--</pre>', wptexturize('<pre><code></code>--</pre>')); 16 15 … … 1210 1209 ), 1211 1210 array( 1212 '[/ ...]', // This would actually be ignored by the shortcode system. The decision to not texturize it is intentional, if not correct.1213 '[/ ...]',1211 '[/gallery ...]', // This would actually be ignored by the shortcode system. The decision to not texturize it is intentional, if not correct. 1212 '[/gallery ...]', 1214 1213 ), 1215 1214 array( 1216 1215 '[...]...[/...]', // These are potentially usable shortcodes. 1217 '[...]…[/...]', 1218 ), 1219 array( 1220 '[[...]]...[[/...]]', // Shortcode parsing will ignore the inner ]...[ part and treat this as a single escaped shortcode. 1221 '[[...]]…[[/...]]', 1222 ), 1223 array( 1224 '[[[...]]]...[[[/...]]]', // Again, shortcode parsing matches, but only the [[...] and [/...]] parts. 1225 '[[[...]]]…[[[/...]]]', 1226 ), 1227 array( 1228 '[[code]...[/code]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [[code] is ambiguous unless we run the entire shortcode regexp. 1229 '[[code]…[/code]…', 1230 ), 1231 array( 1232 '[code]...[/code]]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [/code]] is ambiguous unless we run the entire shortcode regexp. 1233 '[code]...[/code]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize. 1216 '[…]…[/…]', 1217 ), 1218 array( 1219 '[[gallery]]...[[/gallery]]', // Shortcode parsing will ignore the inner ]...[ part and treat this as a single escaped shortcode. 1220 '[[gallery]]…[[/gallery]]', 1221 ), 1222 array( 1223 '[[[gallery]]]...[[[/gallery]]]', // Again, shortcode parsing matches, but only the [[gallery] and [/gallery]] parts. 1224 '[[[gallery]]]…[[[/gallery]]]', 1234 1225 ), 1235 1226 array( … … 1346 1337 ), 1347 1338 array( 1348 '[Let\'s get crazy<input>[ plugin code="<a href=\'?a[]=100\'>hello</a>"]</input>world]',1349 '[Let’s get crazy<input>[ plugin code="<a href=\'?a[]=100\'>hello</a>"]</input>world]',1339 '[Let\'s get crazy<input>[caption code="<a href=\'?a[]=100\'>hello</a>"]</input>world]', // caption shortcode is invalid here because it contains [] chars. 1340 '[Let’s get crazy<input>[caption code=”<a href=\'?a[]=100\'>hello</a>“]</input>world]', 1350 1341 ), 1351 1342 ); … … 1699 1690 ), 1700 1691 array( 1701 '<span>hello[/code]---</span>', 1702 '<span>hello[/code]—</span>', 1703 ), 1704 array( 1705 '[/code]hello<span>---</span>', 1706 '[/code]hello<span>—</span>', 1707 ), 1708 array( 1709 '[code]hello[/code]---</span>', 1710 '[code]hello[/code]—</span>', 1711 ), 1712 array( 1713 '<span>hello</span>---[code]', 1714 '<span>hello</span>—[code]', 1715 ), 1716 array( 1717 '<span>hello[code]---</span>', 1718 '<span>hello[code]---</span>', 1719 ), 1720 array( 1721 '[code]hello<span>---</span>', 1722 '[code]hello<span>---</span>', 1723 ), 1724 array( 1725 '[code]hello</span>---</span>', 1726 '[code]hello</span>---</span>', 1692 '<span><code>hello</code>---</span>', 1693 '<span><code>hello</code>—</span>', 1694 ), 1695 array( 1696 '<code>hello</code>world<span>---</span>', 1697 '<code>hello</code>world<span>—</span>', 1698 ), 1699 ); 1700 } 1701 1702 /** 1703 * Test disabling shortcode texturization. 1704 * 1705 * @ticket 29557 1706 * @dataProvider data_unregistered_shortcodes 1707 */ 1708 function test_unregistered_shortcodes( $input, $output ) { 1709 add_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); 1710 1711 $output = $this->assertEquals( $output, wptexturize( $input ) ); 1712 1713 remove_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); 1714 return $output; 1715 } 1716 1717 function filter_shortcodes( $disabled ) { 1718 $disabled[] = 'audio'; 1719 return $disabled; 1720 } 1721 1722 function data_unregistered_shortcodes() { 1723 return array( 1724 array( 1725 '[a]a--b[audio]---[/audio]a--b[/a]', 1726 '[a]a–b[audio]---[/audio]a–b[/a]', 1727 ), 1728 array( 1729 '[code ...]...[/code]', // code is not a registered shortcode. 1730 '[code …]…[/code]', 1731 ), 1732 array( 1733 '[hello ...]...[/hello]', // hello is not a registered shortcode. 1734 '[hello …]…[/hello]', 1735 ), 1736 array( 1737 '[[audio]...[/audio]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [[audio] is ambiguous unless we run the entire shortcode regexp. 1738 '[[audio]…[/audio]…', 1739 ), 1740 array( 1741 '[audio]...[/audio]]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [/audio]] is ambiguous unless we run the entire shortcode regexp. 1742 '[audio]...[/audio]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize. 1743 ), 1744 array( 1745 '<span>hello[/audio]---</span>', 1746 '<span>hello[/audio]—</span>', 1747 ), 1748 array( 1749 '[/audio]hello<span>---</span>', 1750 '[/audio]hello<span>—</span>', 1751 ), 1752 array( 1753 '[audio]hello[/audio]---</span>', 1754 '[audio]hello[/audio]—</span>', 1755 ), 1756 array( 1757 '<span>hello</span>---[audio]', 1758 '<span>hello</span>—[audio]', 1759 ), 1760 array( 1761 '<span>hello[audio]---</span>', 1762 '<span>hello[audio]---</span>', 1763 ), 1764 array( 1765 '[audio]hello<span>---</span>', 1766 '[audio]hello<span>---</span>', 1767 ), 1768 array( 1769 '[audio]hello</span>---</span>', 1770 '[audio]hello</span>---</span>', 1727 1771 ), 1728 1772 );
Note: See TracChangeset
for help on using the changeset viewer.