Skip to content

Commit 0b56751

Browse files
Tests: Verify if it strips newlines from the nodes
1 parent eb3d608 commit 0b56751

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/phpunit/tests/formatting/stripHtmlNewlines.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,14 @@
88
* @covers ::strip_html_newlines
99
*/
1010
class Tests_Formatting_StripHtmlNewlines extends WP_UnitTestCase {
11+
public function test_strips_newlines_from_text_nodes() {
12+
$this->assertSame( '', strip_html_newlines( '' ), 'Empty string should be returned as-is.' );
13+
$this->assertSame( '<p>No newlines here.</p>', strip_html_newlines( '<p>No newlines here.</p>' ), 'Text without newlines should be returned as-is.' );
14+
$this->assertSame( '<p>Line one Line two Line three</p>', strip_html_newlines( "<p>Line one\n\nLine two\r\nLine three</p>" ), 'Multiple newlines and carriage returns should be collapsed to a single space.' );
15+
$this->assertSame(
16+
'<p>This is a paragraph in which the wpautop() <a href="#elsewhere">wrapping will happen in the middle</a> of an anchor, which is an inline element.</p>',
17+
strip_html_newlines( "<p>This is a paragraph in which the\nwpautop() <a href=\"#elsewhere\">wrapping will\nhappen in the middle</a> of an\nanchor, which is an inline element.</p>" ),
18+
'Newlines within and around inline elements should be stripped.'
19+
);
20+
}
1121
}

0 commit comments

Comments
 (0)