From b5767157345e68bd53b84351b81ef9f4c558688e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 13:12:41 +0000 Subject: [PATCH 1/3] Initial plan From ba4c9bdb1eafe492a6a1711b5c1b8d9aba31d4b0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 13:22:11 +0000 Subject: [PATCH 2/3] Refactor TEXTAREA tests to use data provider Co-authored-by: sirreal <841763+sirreal@users.noreply.github.com> --- .../wpHtmlProcessorModifiableText.php | 77 ++++++++----------- 1 file changed, 32 insertions(+), 45 deletions(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php b/tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php index 4d7eab0f90867..69860e3d2502d 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php @@ -11,69 +11,56 @@ class Tests_HtmlApi_WpHtmlProcessorModifiableText extends WP_UnitTestCase { /** * TEXTAREA elements ignore the first newline in their content. - * Setting the modifiable text with a leading newline should ensure that the leading newline - * is present in the resulting TEXTAREA. + * Setting the modifiable text with a leading newline (or carriage return variants) + * should ensure that the leading newline is present in the resulting TEXTAREA. * * @ticket 64609 - */ - public function test_modifiable_text_special_textarea() { - $processor = WP_HTML_Processor::create_fragment( '' ); - $processor->next_token(); - $processor->set_modifiable_text( "\nAFTER NEWLINE" ); - $this->assertSame( - "\nAFTER NEWLINE", - $processor->get_modifiable_text(), - 'Should have preserved the leading newline in the TEXTAREA content.' - ); - } - - /** - * TEXTAREA elements ignore the first newline in their content. - * Setting the modifiable text with a leading carriage return should be normalized - * and ensure the leading newline is present in the resulting TEXTAREA. * - * @ticket 64609 + * @dataProvider data_modifiable_text_special_textarea + * + * @param string $set_text Text to set. + * @param string $expected_text Expected text after normalization. + * @param string $expected_html Expected HTML output. */ - public function test_modifiable_text_special_textarea_carriage_return() { + public function test_modifiable_text_special_textarea( string $set_text, string $expected_text, string $expected_html ) { $processor = WP_HTML_Processor::create_fragment( '' ); $processor->next_token(); - $processor->set_modifiable_text( "\rCR" ); - // Newline normalization transforms \r into \n, and special handling should preserve it. + $processor->set_modifiable_text( $set_text ); $this->assertSame( - "\nCR", + $expected_text, $processor->get_modifiable_text(), - 'Should have normalized carriage return and preserved the leading newline in the TEXTAREA content.' + 'Should have preserved or normalized the leading newline in the TEXTAREA content.' ); $this->assertEqualHTML( - "", + $expected_html, $processor->get_updated_html(), '
', - 'Should have doubled the newline in the output HTML to preserve the leading newline.' + 'Should have correctly output the TEXTAREA HTML.' ); } /** - * TEXTAREA elements ignore the first newline in their content. - * Setting the modifiable text with a leading carriage return + newline should be normalized - * and ensure the leading newline is present in the resulting TEXTAREA. + * Data provider. * - * @ticket 64609 + * @return array[] */ - public function test_modifiable_text_special_textarea_carriage_return_newline() { - $processor = WP_HTML_Processor::create_fragment( '' ); - $processor->next_token(); - $processor->set_modifiable_text( "\r\nCR-N" ); - // Newline normalization transforms \r\n into \n, and special handling should preserve it. - $this->assertSame( - "\nCR-N", - $processor->get_modifiable_text(), - 'Should have normalized carriage return + newline and preserved the leading newline in the TEXTAREA content.' - ); - $this->assertEqualHTML( - "", - $processor->get_updated_html(), - '', - 'Should have doubled the newline in the output HTML to preserve the leading newline.' + public static function data_modifiable_text_special_textarea() { + return array( + 'Leading newline' => array( + "\nAFTER NEWLINE", + "\nAFTER NEWLINE", + "", + ), + 'Leading carriage return' => array( + "\rCR", + "\nCR", + "", + ), + 'Leading carriage return + newline' => array( + "\r\nCR-N", + "\nCR-N", + "", + ), ); } From 574452df3842e896a6018679d7c5e3b6892c703d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Feb 2026 13:22:53 +0000 Subject: [PATCH 3/3] Improve data provider documentation Co-authored-by: sirreal <841763+sirreal@users.noreply.github.com> --- tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php b/tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php index 69860e3d2502d..bc256ed72c7e5 100644 --- a/tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php +++ b/tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php @@ -40,7 +40,7 @@ public function test_modifiable_text_special_textarea( string $set_text, string } /** - * Data provider. + * Data provider for test_modifiable_text_special_textarea(). * * @return array[] */