Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Increase test coverage
  • Loading branch information
ockham committed Aug 20, 2025
commit 3b9eac6fec835ad85623697a32ce227e27c48377
32 changes: 32 additions & 0 deletions tests/phpunit/tests/block-bindings/wpBlockBindingsProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,36 @@ public function test_set_attribute_and_replace_rich_text() {
$processor->build()
);
}

/**
* @ticket 63840
*/
public function test_replace_rich_text_and_seek() {
$figure_opener = '<figure class="wp-block-image">';
$img = '<img src="breakfast.jpg" alt="" class="wp-image-1"/>';
$figure_closer = '</figure>';
$processor = WP_Block_Bindings_Processor::create_fragment(
$figure_opener .
$img .
'<figcaption class="wp-element-caption">Breakfast at a <em>café</em> in Berlin</figcaption>' .
$figure_closer
);

$processor->next_tag( array( 'tag_name' => 'img' ) );
$processor->set_bookmark( 'image' );

$processor->next_tag( array( 'tag_name' => 'figcaption' ) );

$this->assertTrue( $processor->replace_rich_text( '<strong>New</strong> image caption' ) );

$processor->seek( 'image' );

$this->assertEquals(
$figure_opener .
$img .
'<figcaption class="wp-element-caption"><strong>New</strong> image caption</figcaption>' .
$figure_closer,
$processor->build()
);
}
}