Skip to content

Commit 097f4eb

Browse files
committed
Add set_inner_html happy path tests
1 parent 57279ff commit 097f4eb

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,4 +863,30 @@ public function test_adjusts_for_mathml_integration_points() {
863863
'Found the wrong namespace for the transformed "IMAGE"/"IMG" element.'
864864
);
865865
}
866+
867+
/**
868+
* @ticket TBD
869+
*
870+
* @dataProvider data_set_inner_html
871+
*/
872+
public function test_set_inner_html( string $html, string $replacement, string $expected ) {
873+
$processor = WP_HTML_Processor::create_fragment( $html );
874+
while ( $processor->next_tag() ) {
875+
if ( $processor->get_attribute( 'target' ) ) {
876+
break;
877+
}
878+
}
879+
$processor->set_inner_html( $replacement );
880+
$this->assertSame( $expected, $processor->get_updated_html() );
881+
}
882+
883+
public static function data_set_inner_html() {
884+
return array(
885+
'image in mathml' => array(
886+
'<div target>replace me</div>',
887+
'with me!',
888+
'<div target>with me!</div>',
889+
),
890+
);
891+
}
866892
}

0 commit comments

Comments
 (0)