- Timestamp:
- 11/20/2014 02:29:03 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0/tests/phpunit/tests/formatting/WPTexturize.php
r28971 r30450 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 … … 1194 1193 ), 1195 1194 array( 1195 '[is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', 1196 '[is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', 1197 ), 1198 array( 1199 '[caption - is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', 1200 '[caption – is it wise to <a title="allow user content ] here? hmm"> maybe </a> ]', 1201 ), 1202 array( 1203 '[caption - is it wise to <a title="allow user content here? hmm"> ] maybe </a> ]', 1204 '[caption - is it wise to <a title="allow user content here? hmm"> ] maybe </a> ]', 1205 ), 1206 array( 1207 '[caption - is it wise to <a title="allow user content here? hmm"> maybe </a> ]', 1208 '[caption - is it wise to <a title="allow user content here? hmm"> maybe </a> ]', 1209 ), 1210 array( 1211 '[caption compare=">"]', 1212 '[caption compare=”>”]', 1213 ), 1214 array( 1215 '[caption compare="<>"]', 1216 '[caption compare="<>"]', 1217 ), 1218 array( 1219 '[caption compare="<" attr2="value" <!-->/]', 1220 '[caption compare="<" attr2="value" <!-->/]', 1221 ), 1222 array( 1223 '[caption compare="<"]', 1224 '[caption compare=”<”]', 1225 ), 1226 array( 1227 '[caption compare="<"]<br />', 1228 '[caption compare=”<"]<br />', 1229 ), 1230 array( 1196 1231 '[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a> ]', 1197 1232 '[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a> ]', … … 1211 1246 array( 1212 1247 '[/...]', // This would actually be ignored by the shortcode system. The decision to not texturize it is intentional, if not correct. 1213 '[/ ...]',1248 '[/…]', 1214 1249 ), 1215 1250 array( 1216 1251 '[...]...[/...]', // These are potentially usable shortcodes. 1217 '[ ...]…[/...]',1252 '[…]…[/…]', 1218 1253 ), 1219 1254 array( 1220 1255 '[[...]]...[[/...]]', // Shortcode parsing will ignore the inner ]...[ part and treat this as a single escaped shortcode. 1221 '[[ ...]]…[[/...]]',1256 '[[…]]…[[/…]]', 1222 1257 ), 1223 1258 array( 1224 1259 '[[[...]]]...[[[/...]]]', // Again, shortcode parsing matches, but only the [[...] and [/...]] parts. 1225 '[[[ ...]]]…[[[/...]]]',1260 '[[[…]]]…[[[/…]]]', 1226 1261 ), 1227 1262 array( … … 1231 1266 array( 1232 1267 '[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.1268 '[code]…[/code]]…', // This test would not pass in 3.9 because the extra brace was always ignored by texturize. 1234 1269 ), 1235 1270 array( … … 1346 1381 ), 1347 1382 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]',1383 '[Let\'s get crazy<input>[caption code="<a href=\'?a[]=100\'>hello</a>"]</input>world]', // caption shortcode is invalid here because it contains [] chars. 1384 '[Let’s get crazy<input>[caption code=”<a href=\'?a[]=100\'>hello</a>“]</input>world]', 1350 1385 ), 1351 1386 ); … … 1716 1751 array( 1717 1752 '<span>hello[code]---</span>', 1718 '<span>hello[code] ---</span>',1753 '<span>hello[code]—</span>', 1719 1754 ), 1720 1755 array( 1721 1756 '[code]hello<span>---</span>', 1722 '[code]hello<span> ---</span>',1757 '[code]hello<span>—</span>', 1723 1758 ), 1724 1759 array( 1725 1760 '[code]hello</span>---</span>', 1726 '[code]hello</span>---</span>', 1761 '[code]hello</span>—</span>', 1762 ), 1763 ); 1764 } 1765 1766 /** 1767 * Test disabling shortcode texturization. 1768 * 1769 * @ticket 29557 1770 * @dataProvider data_unregistered_shortcodes 1771 */ 1772 function test_unregistered_shortcodes( $input, $output ) { 1773 add_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); 1774 1775 $output = $this->assertEquals( $output, wptexturize( $input ) ); 1776 1777 remove_filter( 'no_texturize_shortcodes', array( $this, 'filter_shortcodes' ), 10, 1 ); 1778 return $output; 1779 } 1780 1781 function filter_shortcodes( $disabled ) { 1782 $disabled[] = 'audio'; 1783 return $disabled; 1784 } 1785 1786 function data_unregistered_shortcodes() { 1787 return array( 1788 array( 1789 '[a]a--b[code]---[/code]a--b[/a]', // code is not a registered shortcode. 1790 '[a]a–b[code]—[/code]a–b[/a]', 1791 ), 1792 array( 1793 '[a]a--b[audio]---[/audio]a--b[/a]', 1794 '[a]a–b[audio]---[/audio]a–b[/a]', 1795 ), 1796 array( 1797 '[code ...]...[/code]', // code is not a registered shortcode. 1798 '[code …]…[/code]', 1799 ), 1800 array( 1801 '[hello ...]...[/hello]', // hello is not a registered shortcode. 1802 '[hello …]…[/hello]', 1803 ), 1804 array( 1805 '[...]...[/...]', // These are potentially usable shortcodes. 1806 '[…]…[/…]', 1807 ), 1808 array( 1809 '[gal>ery ...]', 1810 '[gal>ery …]', 1811 ), 1812 array( 1813 '[randomthing param="test"]', 1814 '[randomthing param=”test”]', 1815 ), 1816 array( 1817 '[[audio]...[/audio]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [[audio] is ambiguous unless we run the entire shortcode regexp. 1818 '[[audio]…[/audio]…', 1819 ), 1820 array( 1821 '[audio]...[/audio]]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [/audio]] is ambiguous unless we run the entire shortcode regexp. 1822 '[audio]...[/audio]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize. 1823 ), 1824 array( 1825 '<span>hello[/audio]---</span>', 1826 '<span>hello[/audio]—</span>', 1827 ), 1828 array( 1829 '[/audio]hello<span>---</span>', 1830 '[/audio]hello<span>—</span>', 1831 ), 1832 array( 1833 '[audio]hello[/audio]---</span>', 1834 '[audio]hello[/audio]—</span>', 1835 ), 1836 array( 1837 '<span>hello</span>---[audio]', 1838 '<span>hello</span>—[audio]', 1839 ), 1840 array( 1841 '<span>hello[audio]---</span>', 1842 '<span>hello[audio]---</span>', 1843 ), 1844 array( 1845 '[audio]hello<span>---</span>', 1846 '[audio]hello<span>---</span>', 1847 ), 1848 array( 1849 '[audio]hello</span>---</span>', 1850 '[audio]hello</span>---</span>', 1727 1851 ), 1728 1852 );
Note: See TracChangeset
for help on using the changeset viewer.