From 9e38e4245b85ebfaa5f50404cc0085f4bfbe52a7 Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Thu, 22 Dec 2022 10:58:00 -0700 Subject: [PATCH] Add failing test for reading attribute update before flushing updates --- phpunit/html/wp-html-tag-processor-test.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/phpunit/html/wp-html-tag-processor-test.php b/phpunit/html/wp-html-tag-processor-test.php index fbf629088ce03..6fe040f0af6d2 100644 --- a/phpunit/html/wp-html-tag-processor-test.php +++ b/phpunit/html/wp-html-tag-processor-test.php @@ -388,6 +388,21 @@ public function test_set_attribute_with_a_non_existing_attribute_adds_a_new_attr $this->assertSame( 'test-value', $p->get_attribute( 'test-attribute' ) ); } + /** + * @ticket 56299 + * + * @covers set_attribute + * @covers get_updated_html + * @covers get_attribute + */ + public function test_get_attribute_returns_updated_values_before_they_are_updated() { + $p = new WP_HTML_Tag_Processor( self::HTML_SIMPLE ); + $p->next_tag(); + $p->set_attribute( 'test-attribute', 'test-value' ); + $this->assertSame( 'test-value', $p->get_attribute( 'test-attribute' ) ); + $this->assertSame( '
Text
', $p->get_updated_html() ); + } + /** * According to HTML spec, only the first instance of an attribute counts. * The other ones are ignored.