Ticket #20418: 20418-unit-tests.diff
File 20418-unit-tests.diff, 4.6 KB (added by , 13 years ago) |
---|
-
wp-testcase/test_includes_formatting.php
217 217 } 218 218 } 219 219 220 function test_wrapped_in_angles() { 221 $before = array( 222 'URL wrapped in angle brackets <http://example.com/>', 223 'URL wrapped in angle brackets with padding < http://example.com/ >', 224 'mailto wrapped in angle brackets <foo@example.com>', 225 ); 226 $expected = array( 227 'URL wrapped in angle brackets <<a href="http://example.com/" rel="nofollow">http://example.com/</a>>', 228 'URL wrapped in angle brackets with padding < <a href="http://example.com/" rel="nofollow">http://example.com/</a> >', 229 'mailto wrapped in angle brackets <foo@example.com>', 230 ); 231 foreach ($before as $key => $url) { 232 $this->assertEquals($expected[$key], make_clickable($url)); 233 } 234 } 235 220 236 function test_preceded_by_punctuation() { 221 237 $before = array( 222 238 'Comma then URL,http://example.com/', … … 225 241 'Colon then URL:http://example.com/', 226 242 'Exclamation mark then URL!http://example.com/', 227 243 'Question mark then URL?http://example.com/', 228 'URL wrapped in angle brackets <http://example.com/>',229 244 ); 230 245 $expected = array( 231 246 'Comma then URL,<a href="http://example.com/" rel="nofollow">http://example.com/</a>', … … 234 249 'Colon then URL:<a href="http://example.com/" rel="nofollow">http://example.com/</a>', 235 250 'Exclamation mark then URL!<a href="http://example.com/" rel="nofollow">http://example.com/</a>', 236 251 'Question mark then URL?<a href="http://example.com/" rel="nofollow">http://example.com/</a>', 237 'URL wrapped in angle brackets <<a href="http://example.com/" rel="nofollow">http://example.com/</a>>',238 252 ); 239 253 foreach ($before as $key => $url) { 240 254 $this->assertEquals($expected[$key], make_clickable($url)); … … 249 263 "http://trunk.domain/testing#something 250 264 (<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>)", 251 265 "<span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' /> <param name='allowfullscreen' value='true' /> <param name='wmode' value='opaque' /> <embed src='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='opaque'></embed> </object></span>", 266 '<a href="http://example.com/example.gif" title="Image from http://example.com">Look at this image!</a>', 252 267 ); 253 268 $urls_expected = array( 254 269 "<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>", … … 257 272 "<a href=\"http://trunk.domain/testing#something\" rel=\"nofollow\">http://trunk.domain/testing#something</a> 258 273 (<img src='http://trunk.domain/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley'>)", 259 274 "<span style='text-align:center; display: block;'><object width='425' height='350'><param name='movie' value='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' /> <param name='allowfullscreen' value='true' /> <param name='wmode' value='opaque' /> <embed src='http://www.youtube.com/v/nd_BdvG43rE&rel=1&fs=1&showsearch=0&showinfo=1&iv_load_policy=1' type='application/x-shockwave-flash' allowfullscreen='true' width='425' height='350' wmode='opaque'></embed> </object></span>", 275 '<a href="http://example.com/example.gif" title="Image from http://example.com">Look at this image!</a>', 260 276 ); 261 277 foreach ($urls_before as $key => $url) { 262 278 $this->assertEquals($urls_expected[$key], make_clickable($url)); … … 277 293 $this->assertEquals( $urls_expected[$key], make_clickable( $url ) ); 278 294 } 279 295 } 296 297 function test_no_links_within_links() { 298 $in = array( 299 'Some text with a link <a href="http://example.com">http://example.com</a>', 300 //'<a href="http://wordpress.org">This is already a link www.wordpress.org</a>', // fails in 3.3.1 too 301 ); 302 foreach ( $in as $text ) { 303 $this->assertEquals( $text, make_clickable( $text ) ); 304 } 305 } 306 307 /** 308 * @ticket 16892 309 */ 310 function test_no_segfault() { 311 if ( version_compare( $GLOBALS['wp_version'], '3.1.1', '<' ) ) 312 $this->markTestSkipped(); 313 314 $in = str_repeat( 'http://example.com/2011/03/18/post-title/', 256 ); 315 $out = make_clickable( $in ); 316 if ( version_compare( $GLOBALS['wp_version'], '3.4-alpha', '>=' ) ) 317 $this->assertEquals( $in, $out ); 318 } 280 319 } 281 320 282 321 class TestJSEscape extends WPTestCase {