Changes from branches/4.0/tests/phpunit/tests/formatting/WPTexturize.php at r30450 to trunk/tests/phpunit/tests/formatting/WPTexturize.php at r28971
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/WPTexturize.php
r30450 r28971 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]')); 14 15 $this->assertEquals('<pre><code></code>--</pre>', wptexturize('<pre><code></code>--</pre>')); 15 16 … … 1193 1194 ), 1194 1195 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(1231 1196 '[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a> ]', 1232 1197 '[ photos by <a href="http://example.com/?a[]=1&a[]=2"> this guy </a> ]', … … 1246 1211 array( 1247 1212 '[/...]', // This would actually be ignored by the shortcode system. The decision to not texturize it is intentional, if not correct. 1248 '[/ …]',1213 '[/...]', 1249 1214 ), 1250 1215 array( 1251 1216 '[...]...[/...]', // These are potentially usable shortcodes. 1252 '[ …]…[/…]',1217 '[...]…[/...]', 1253 1218 ), 1254 1219 array( 1255 1220 '[[...]]...[[/...]]', // Shortcode parsing will ignore the inner ]...[ part and treat this as a single escaped shortcode. 1256 '[[ …]]…[[/…]]',1221 '[[...]]…[[/...]]', 1257 1222 ), 1258 1223 array( 1259 1224 '[[[...]]]...[[[/...]]]', // Again, shortcode parsing matches, but only the [[...] and [/...]] parts. 1260 '[[[ …]]]…[[[/…]]]',1225 '[[[...]]]…[[[/...]]]', 1261 1226 ), 1262 1227 array( … … 1266 1231 array( 1267 1232 '[code]...[/code]]...', // These are potentially usable shortcodes. Unfortunately, the meaning of [/code]] is ambiguous unless we run the entire shortcode regexp. 1268 '[code] …[/code]]…', // This test would not pass in 3.9 because the extra brace was always ignored by texturize.1233 '[code]...[/code]]...', // This test would not pass in 3.9 because the extra brace was always ignored by texturize. 1269 1234 ), 1270 1235 array( … … 1381 1346 ), 1382 1347 array( 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]',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]', 1385 1350 ), 1386 1351 ); … … 1751 1716 array( 1752 1717 '<span>hello[code]---</span>', 1753 '<span>hello[code] —</span>',1718 '<span>hello[code]---</span>', 1754 1719 ), 1755 1720 array( 1756 1721 '[code]hello<span>---</span>', 1757 '[code]hello<span> —</span>',1722 '[code]hello<span>---</span>', 1758 1723 ), 1759 1724 array( 1760 1725 '[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>', 1726 '[code]hello</span>---</span>', 1851 1727 ), 1852 1728 );
Note: See TracChangeset
for help on using the changeset viewer.