Skip to content

Commit fd94649

Browse files
committed
Add tests for newline handling of PRE,TEXTAREA
1 parent 5930f08 commit fd94649

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/phpunit/tests/html-api/wpHtmlProcessor-serialize.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,39 @@ public static function data_provider_serialize_doctype() {
321321
'Double quotes in system ID' => array( '<!DOCTYPE html SYSTEM \'"quoted"\'\>', '<!DOCTYPE html SYSTEM \'"quoted"\'>' ),
322322
);
323323
}
324+
325+
/**
326+
* @ticket TBD
327+
*
328+
* @dataProvider data_provider_special_leading_newline_cases
329+
*/
330+
public function test_special_leading_newline_handling( string $input, string $expected ) {
331+
$normalized = WP_HTML_Processor::normalize( $input );
332+
$this->assertEqualHTML( $expected, $normalized );
333+
$normalized_twice = WP_HTML_Processor::normalize( $normalized );
334+
$this->assertEqualHTML( $expected, $normalized_twice );
335+
}
336+
337+
/**
338+
*/
339+
public static function data_provider_special_leading_newline_cases() {
340+
return array(
341+
'Leading newline in PRE' => array(
342+
"<pre>\nline 1\nline 2</pre>",
343+
"<pre>line 1\nline 2</pre>",
344+
),
345+
'Double leading newline in PRE' => array(
346+
"<pre>\n\nline 2\nline 3</pre>",
347+
"<pre>\n\nline 2\nline 3</pre>",
348+
),
349+
'Leading newline in TEXTAREA' => array(
350+
"<textarea>\nline 1\nline 2</textarea>",
351+
"<textarea>line 1\nline 2</textarea>",
352+
),
353+
'Double leading newline in TEXTAREA' => array(
354+
"<textarea>\n\nline 2\nline 3</textarea>",
355+
"<textarea>\n\nline 2\nline 3</textarea>",
356+
),
357+
);
358+
}
324359
}

0 commit comments

Comments
 (0)