From 882f41cb64a444ec4b96051188172b94d34d6f50 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Tue, 24 Jun 2014 00:54:22 +0000 Subject: [PATCH] Add unit tests for [28817]. git-svn-id: https://develop.svn.wordpress.org/trunk@28818 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/formatting/Autop.php | 122 +++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/tests/phpunit/tests/formatting/Autop.php b/tests/phpunit/tests/formatting/Autop.php index 50c10c7974..81181a86e9 100644 --- a/tests/phpunit/tests/formatting/Autop.php +++ b/tests/phpunit/tests/formatting/Autop.php @@ -273,4 +273,126 @@ Paragraph two.'; $str = 'Country: '; $this->assertEquals( "

$str

", trim( wpautop( $str ) ) ); } + + /** + * wpautop() should treat block level HTML elements as blocks. + */ + function test_that_wpautop_treats_block_level_elements_as_blocks() { + $blocks = array( + 'table', + 'thead', + 'tfoot', + 'caption', + 'col', + 'colgroup', + 'tbody', + 'tr', + 'td', + 'th', + 'div', + 'dl', + 'dd', + 'dt', + 'ul', + 'ol', + 'li', + 'pre', + 'select', + 'option', + 'form', + 'map', + 'area', + 'address', + 'math', + 'style', + 'p', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'hr', + 'fieldset', + 'legend', + 'section', + 'article', + 'aside', + 'hgroup', + 'header', + 'footer', + 'nav', + 'figure', + 'figcaption', + 'details', + 'menu', + 'summary', + ); + + $content = array(); + + foreach ( $blocks as $block ) { + $content[] = "<$block>foo"; + } + + $expected = join( "\n", $content ); + $content = join( "\n\n", $content ); // WS difference + + $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + } + + /** + * wpautop() should autop a blockquote's contents but not the blockquote itself + */ + function test_that_wpautop_does_not_wrap_blockquotes_but_does_autop_their_contents() { + $content = "
foo
"; + $expected = "

foo

"; + + $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + } + + /** + * wpautop() should treat inline HTML elements as inline. + */ + function test_that_wpautop_treats_inline_elements_as_inline() { + $inlines = array( + 'a', + 'em', + 'strong', + 'small', + 's', + 'cite', + 'q', + 'dfn', + 'abbr', + 'data', + 'time', + 'code', + 'var', + 'samp', + 'kbd', + 'sub', + 'sup', + 'i', + 'b', + 'u', + 'mark', + 'span', + 'del', + 'ins', + 'noscript', + ); + + $content = $expected = array(); + + foreach ( $inlines as $inline ) { + $content[] = "<$inline>foo"; + $expected[] = "

<$inline>foo

"; + } + + $content = join( "\n\n", $content ); + $expected = join( "\n", $expected ); + + $this->assertEquals( $expected, trim( wpautop( $content ) ) ); + } }