From 7d48ce7d8606faba48207d2f4e522343e328416f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 28 Jun 2024 15:29:18 +0200 Subject: [PATCH] Add tests for leading/trailing whitespace in modified class attributes --- .../tests/html-api/wpHtmlTagProcessor.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php index fad1000dd763c..b9f696bcfed5c 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php @@ -2875,4 +2875,35 @@ public function insert_after( $new_html ) { 'Should have properly applied the update from in front of the cursor.' ); } + + /** + * @ticket TBD + * + * @covers ::remove_class + */ + public function test_remove_class_removes_leading_white_space() { + $processor = new WP_HTML_Tag_Processor( '
' ); + $processor->next_tag(); + $processor->remove_class( 'remove' ); + $this->assertSame( + '
', + $processor->get_updated_html(), + '::remove_class did not correctly clean whitespace from removed class.' + ); + } + /** + * @ticket TBD + * + * @covers ::remove_class + */ + public function test_remove_class_maintains_trailing_white_space() { + $processor = new WP_HTML_Tag_Processor( '
' ); + $processor->next_tag(); + $processor->remove_class( 'remove' ); + $this->assertSame( + '
', + $processor->get_updated_html(), + '::remove_class did not correctly clean whitespace from removed class.' + ); + } }