Changeset 47122 for trunk/tests/phpunit/tests/formatting/Autop.php
- Timestamp:
- 01/29/2020 12:43:23 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/formatting/Autop.php
r46612 r47122 5 5 */ 6 6 class Tests_Formatting_Autop extends WP_UnitTestCase { 7 //From ticket https://core.trac.wordpress.org/ticket/11008 7 8 /** 9 * @ticket 11008 10 */ 8 11 function test_first_post() { 9 12 $expected = '<p>Welcome to WordPress! This post contains important information. After you read it, you can make it private to hide it from visitors but still have the information handy for future reference.</p> … … 57 60 '; 58 61 59 // On windows environments, the EOL-style is \r\n62 // On Windows environments, the EOL-style is \r\n. 60 63 $expected = str_replace( "\r\n", "\n", $expected ); 61 64 … … 73 76 $code = htmlentities( $code ); 74 77 75 // Not wrapped in <p> tags 78 // Not wrapped in <p> tags. 76 79 $str = "<pre>$code</pre>"; 77 80 $this->assertEquals( $str, trim( wpautop( $str ) ) ); 78 81 79 // Text before/after is wrapped in <p> tags 82 // Text before/after is wrapped in <p> tags. 80 83 $str = "Look at this code\n\n<pre>$code</pre>\n\nIsn't that cool?"; 81 84 82 // Expected text after wpautop 85 // Expected text after wpautop(). 83 86 $expected = '<p>Look at this code</p>' . "\n<pre>" . $code . "</pre>\n" . '<p>Isn\'t that cool?</p>'; 84 87 $this->assertEquals( $expected, trim( wpautop( $str ) ) ); 85 88 86 // Make sure HTML breaks are maintained if manually inserted 89 // Make sure HTML breaks are maintained if manually inserted. 87 90 $str = "Look at this code\n\n<pre>Line1<br />Line2<br>Line3<br/>Line4\nActual Line 2\nActual Line 3</pre>\n\nCool, huh?"; 88 91 $expected = "<p>Look at this code</p>\n<pre>Line1<br />Line2<br>Line3<br/>Line4\nActual Line 2\nActual Line 3</pre>\n<p>Cool, huh?</p>"; … … 143 146 "\n\nParagraph two."; 144 147 145 $expected = "<p>Paragraph one.</p>\n" . // line breaks only after <p>148 $expected = "<p>Paragraph one.</p>\n" . // Line breaks only after <p>. 146 149 '<p><video class="wp-video-shortcode" id="video-0-1" width="640" height="360" preload="metadata" controls="controls">' . 147 150 '<source type="video/mp4" src="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4" />' . … … 158 161 '<p>Paragraph two.</p>'; 159 162 160 // When running the content through wpautop() from wp_richedit_pre() 163 // When running the content through wpautop() from wp_richedit_pre(). 161 164 $shortcode_content = "Paragraph one.\n\n" . 162 165 '[video width="720" height="480" mp4="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4"] … … 172 175 "\n\nParagraph two."; 173 176 174 $shortcode_expected = "<p>Paragraph one.</p>\n" . // line breaks only after <p>177 $shortcode_expected = "<p>Paragraph one.</p>\n" . // Line breaks only after <p>. 175 178 '<p>[video width="720" height="480" mp4="http://domain.tld/wp-content/uploads/2013/12/xyz.mp4"]' . 176 179 '<!-- WebM/VP8 for Firefox4, Opera, and Chrome --><source type="video/webm" src="myvideo.webm" />' . … … 207 210 Paragraph two.'; 208 211 209 $expected1 = "<p>Paragraph one.</p>\n" . // line breaks only after <p>212 $expected1 = "<p>Paragraph one.</p>\n" . // Line breaks only after <p>. 210 213 '<p><object width="400" height="224" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">' . 211 214 '<param name="src" value="http://domain.tld/wp-content/uploads/2013/12/xyz.swf" />' . … … 243 246 Paragraph two.'; 244 247 245 $expected2 = "<p>Paragraph one.</p>\n" . // line breaks only after block tags248 $expected2 = "<p>Paragraph one.</p>\n" . // Line breaks only after block tags. 246 249 '<div class="video-player" id="x-video-0">' . "\n" . 247 250 '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="640" height="360" id="video-0" standby="Standby text">' . … … 336 339 337 340 $expected = join( "\n", $content ); 338 $input = join( "\n\n", $content ); // W S difference341 $input = join( "\n\n", $content ); // Whitespace difference. 339 342 340 343 $this->assertEquals( $expected, trim( wpautop( $input ) ) ); 341 344 342 $input = join( '', $content ); // W S difference345 $input = join( '', $content ); // Whitespace difference. 343 346 344 347 $this->assertEquals( $expected, trim( wpautop( $input ) ) );
Note: See TracChangeset
for help on using the changeset viewer.