diff --git a/tests/phpunit/tests/html-api/wpHtmlProcessor-bookmark.php b/tests/phpunit/tests/html-api/wpHtmlProcessor-bookmark.php
index 35a268c43af89..eafb03c0cbaec 100644
--- a/tests/phpunit/tests/html-api/wpHtmlProcessor-bookmark.php
+++ b/tests/phpunit/tests/html-api/wpHtmlProcessor-bookmark.php
@@ -13,77 +13,84 @@
*/
class Tests_HtmlApi_WpHtmlProcessor_Bookmark extends WP_UnitTestCase {
/**
+ * @dataProvider data_processor_constructors
+ *
* @ticket 62290
*/
- public function test_full_processor_seek_same_location() {
- $bookmark_name = 'the-bookmark';
- $processor = WP_HTML_Processor::create_full_parser( '
' );
- $this->assertTrue( $processor->next_tag( 'BODY' ) );
- $this->assertTrue( $processor->set_bookmark( $bookmark_name ), 'Failed to set bookmark.' );
- $this->assertTrue( $processor->has_bookmark( $bookmark_name ), 'Failed has_bookmark check.' );
+ public function test_processor_seek_same_location( callable $factory ) {
+ $processor = $factory( '
' );
+ $this->assertTrue( $processor->next_tag( 'DIV' ) );
+ $this->assertTrue( $processor->set_bookmark( 'mark' ), 'Failed to set bookmark.' );
+ $this->assertTrue( $processor->has_bookmark( 'mark' ), 'Failed has_bookmark check.' );
- // Confirm the bookmark works.
- $this->assertTrue( $processor->seek( $bookmark_name ), 'Failed to seek to bookmark.' );
- $this->assertSame( 'BODY', $processor->get_tag() );
- $this->assertTrue( $processor->next_tag() );
+ // Confirm the bookmark works and processing continues normally.
+ $this->assertTrue( $processor->seek( 'mark' ), 'Failed to seek to bookmark.' );
$this->assertSame( 'DIV', $processor->get_tag() );
$this->assertSame( array( 'HTML', 'BODY', 'DIV' ), $processor->get_breadcrumbs() );
+ $this->assertTrue( $processor->next_tag() );
+ $this->assertSame( 'SPAN', $processor->get_tag() );
+ $this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN' ), $processor->get_breadcrumbs() );
}
/**
+ * @dataProvider data_processor_constructors
+ *
* @ticket 62290
*/
- public function test_full_processor_seek_backward() {
- $bookmark_name = 'the-bookmark';
- $processor = WP_HTML_Processor::create_full_parser( '' );
- $this->assertTrue( $processor->next_tag( 'BODY' ) );
- $this->assertTrue( $processor->set_bookmark( $bookmark_name ), 'Failed to set bookmark.' );
- $this->assertTrue( $processor->has_bookmark( $bookmark_name ), 'Failed has_bookmark check.' );
+ public function test_processor_seek_backward( callable $factory ) {
+ $processor = $factory( '
' );
+ $this->assertTrue( $processor->next_tag( 'DIV' ) );
+ $this->assertTrue( $processor->set_bookmark( 'mark' ), 'Failed to set bookmark.' );
+ $this->assertTrue( $processor->has_bookmark( 'mark' ), 'Failed has_bookmark check.' );
// Move past the bookmark so it must scan backwards.
- $this->assertTrue( $processor->next_tag( 'DIV' ) );
+ $this->assertTrue( $processor->next_tag( 'SPAN' ) );
// Confirm the bookmark works.
- $this->assertTrue( $processor->seek( $bookmark_name ), 'Failed to seek to bookmark.' );
- $this->assertSame( 'BODY', $processor->get_tag() );
+ $this->assertTrue( $processor->seek( 'mark' ), 'Failed to seek to bookmark.' );
+ $this->assertSame( 'DIV', $processor->get_tag() );
}
/**
+ * @dataProvider data_processor_constructors
+ *
* @ticket 62290
*/
- public function test_full_processor_seek_forward() {
- $processor = WP_HTML_Processor::create_full_parser( '' );
- $this->assertTrue( $processor->next_tag( 'BODY' ) );
- $this->assertTrue( $processor->set_bookmark( 'body' ), 'Failed to set bookmark "body".' );
- $this->assertTrue( $processor->has_bookmark( 'body' ), 'Failed "body" has_bookmark check.' );
-
- // Move past the bookmark so it must scan backwards.
+ public function test_processor_seek_forward( callable $factory ) {
+ $processor = $factory( '
' );
$this->assertTrue( $processor->next_tag( 'DIV' ) );
- $this->assertTrue( $processor->get_attribute( 'one' ) );
$this->assertTrue( $processor->set_bookmark( 'one' ), 'Failed to set bookmark "one".' );
$this->assertTrue( $processor->has_bookmark( 'one' ), 'Failed "one" has_bookmark check.' );
- // Seek back.
- $this->assertTrue( $processor->seek( 'body' ), 'Failed to seek to bookmark "body".' );
- $this->assertSame( 'BODY', $processor->get_tag() );
+ // Move past the bookmark so it must scan backwards.
+ $this->assertTrue( $processor->next_tag( 'SPAN' ) );
+ $this->assertTrue( $processor->get_attribute( 'two' ) );
+ $this->assertTrue( $processor->set_bookmark( 'two' ), 'Failed to set bookmark "two".' );
+ $this->assertTrue( $processor->has_bookmark( 'two' ), 'Failed "two" has_bookmark check.' );
- // Seek forward and continue processing.
+ // Seek back.
$this->assertTrue( $processor->seek( 'one' ), 'Failed to seek to bookmark "one".' );
$this->assertSame( 'DIV', $processor->get_tag() );
- $this->assertTrue( $processor->get_attribute( 'one' ) );
- $this->assertTrue( $processor->next_tag() );
- $this->assertSame( 'DIV', $processor->get_tag() );
+ // Seek forward and continue processing.
+ $this->assertTrue( $processor->seek( 'two' ), 'Failed to seek to bookmark "two".' );
+ $this->assertSame( 'SPAN', $processor->get_tag() );
$this->assertTrue( $processor->get_attribute( 'two' ) );
+
+ $this->assertTrue( $processor->next_tag() );
+ $this->assertSame( 'A', $processor->get_tag() );
+ $this->assertTrue( $processor->get_attribute( 'three' ) );
}
/**
- * Seeking into and out of foreign content requires updating the parsing namespace correctly.
+ * Ensure the parsing namespace is handled when seeking from foreign content.
+ *
+ * @dataProvider data_processor_constructors
*
* @ticket 62290
*/
- public function test_full_processor_seek_back_from_foreign_content() {
- $processor = WP_HTML_Processor::create_full_parser( '