| 266 | |
| 267 | /** |
| 268 | * wpautop() should treat block level HTML elements as blocks. |
| 269 | */ |
| 270 | function test_that_wpautop_treats_block_level_elements_as_blocks() { |
| 271 | $blocks = array( |
| 272 | 'table', |
| 273 | 'thead', |
| 274 | 'tfoot', |
| 275 | 'caption', |
| 276 | 'col', |
| 277 | 'colgroup', |
| 278 | 'tbody', |
| 279 | 'tr', |
| 280 | 'td', |
| 281 | 'th', |
| 282 | 'div', |
| 283 | 'dl', |
| 284 | 'dd', |
| 285 | 'dt', |
| 286 | 'ul', |
| 287 | 'ol', |
| 288 | 'li', |
| 289 | 'pre', |
| 290 | 'select', |
| 291 | 'option', |
| 292 | 'form', |
| 293 | 'map', |
| 294 | 'area', |
| 295 | 'address', |
| 296 | 'math', |
| 297 | 'style', |
| 298 | 'p', |
| 299 | 'h1', |
| 300 | 'h2', |
| 301 | 'h3', |
| 302 | 'h4', |
| 303 | 'h5', |
| 304 | 'h6', |
| 305 | 'hr', |
| 306 | 'fieldset', |
| 307 | 'legend', |
| 308 | 'section', |
| 309 | 'article', |
| 310 | 'aside', |
| 311 | 'hgroup', |
| 312 | 'header', |
| 313 | 'footer', |
| 314 | 'nav', |
| 315 | 'figure', |
| 316 | 'figcaption', |
| 317 | 'details', |
| 318 | 'menu', |
| 319 | 'summary', |
| 320 | ); |
| 321 | |
| 322 | $content = array(); |
| 323 | |
| 324 | foreach ( $blocks as $block ) { |
| 325 | $content[] = "<$block>foo</$block>"; |
| 326 | } |
| 327 | |
| 328 | $expected = join( "\n", $content ); |
| 329 | $content = join( "\n\n", $content ); // WS difference |
| 330 | |
| 331 | $this->assertEquals( $expected, trim( wpautop( $content ) ) ); |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * wpautop() should autop a blockquote's contents but not the blockquote itself |
| 336 | */ |
| 337 | function test_that_wpautop_does_not_wrap_blockquotes_but_does_autop_their_contents() { |
| 338 | $content = "<blockquote>foo</blockquote>"; |
| 339 | $expected = "<blockquote><p>foo</p></blockquote>"; |
| 340 | |
| 341 | $this->assertEquals( $expected, trim( wpautop( $content ) ) ); |
| 342 | } |
| 343 | |
| 344 | /** |
| 345 | * wpautop() should treat inline HTML elements as inline. |
| 346 | */ |
| 347 | function test_that_wpautop_treats_inline_elements_as_inline() { |
| 348 | $inlines = array( |
| 349 | 'a', |
| 350 | 'em', |
| 351 | 'strong', |
| 352 | 'small', |
| 353 | 's', |
| 354 | 'cite', |
| 355 | 'q', |
| 356 | 'dfn', |
| 357 | 'abbr', |
| 358 | 'data', |
| 359 | 'time', |
| 360 | 'code', |
| 361 | 'var', |
| 362 | 'samp', |
| 363 | 'kbd', |
| 364 | 'sub', |
| 365 | 'sup', |
| 366 | 'i', |
| 367 | 'b', |
| 368 | 'u', |
| 369 | 'mark', |
| 370 | 'span', |
| 371 | 'del', |
| 372 | 'ins', |
| 373 | 'noscript', |
| 374 | ); |
| 375 | |
| 376 | $content = $expected = array(); |
| 377 | |
| 378 | foreach ( $inlines as $inline ) { |
| 379 | $content[] = "<$inline>foo</$inline>"; |
| 380 | $expected[] = "<p><$inline>foo</$inline></p>"; |
| 381 | } |
| 382 | |
| 383 | $content = join( "\n\n", $content ); |
| 384 | $expected = join( "\n", $expected ); |
| 385 | |
| 386 | $this->assertEquals( $expected, trim( wpautop( $content ) ) ); |
| 387 | } |