Skip to content

Commit e98fa1c

Browse files
committed
Tests: Compare HTML semantically in the serialize_token() attribute test.
Use `assertEqualHTML()` instead of `assertSame()` when checking that `WP_HTML_Processor::serialize_token()` reflects enqueued attribute updates, so the test no longer depends on the order of serialized attributes. Developed in: WordPress#15373 Props motylanogha, dmsnell. See #64567. git-svn-id: https://develop.svn.wordpress.org/trunk@65245 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 457a26f commit e98fa1c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,20 +872,22 @@ public function test_serialize_token_reflects_enqueued_attribute_updates() {
872872
$processor->next_tag();
873873
$processor->remove_attribute( 'onclick' );
874874

875-
$this->assertSame(
875+
$this->assertEqualHTML(
876876
'<div class="x">',
877877
$processor->serialize_token(),
878+
'<body>',
878879
'An attribute enqueued for removal was serialized as a value-less attribute.'
879880
);
880881

881882
$processor = WP_HTML_Processor::create_fragment( '<div class="x">Text</div>' );
882883
$processor->next_tag();
883884
$processor->set_attribute( 'id', 'new' );
884885

885-
$this->assertSame(
886+
$this->assertEqualHTML(
886887
'<div id="new" class="x">',
887888
$processor->serialize_token(),
888-
'An attribute enqueued via set_attribute() was not serialized. A newly added attribute is emitted before the existing ones.'
889+
'<body>',
890+
'An attribute enqueued via set_attribute() was not serialized.'
889891
);
890892
}
891893
}

0 commit comments

Comments
 (0)