From 8f43d6e3a57ed4519e632d89b8a6177a5e21f5b9 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Wed, 22 Feb 2023 17:51:04 +0100 Subject: [PATCH] Add unit tests --- .../html-api/wpHtmlTagProcessor-bookmark.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php b/tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php index 04a6ae590cd7d..caa631dffa698 100644 --- a/tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php +++ b/tests/phpunit/tests/html-api/wpHtmlTagProcessor-bookmark.php @@ -40,6 +40,41 @@ public function test_release_bookmark() { $this->assertTrue( $p->release_bookmark( 'first li' ), 'Could not release a bookmark' ); } + /** + * @ticket 57788 + * + * @covers WP_HTML_Tag_Processor::has_bookmark + */ + public function test_has_bookmark_returns_false_if_bookmark_does_not_exist() { + $p = new WP_HTML_Tag_Processor( '
Test
' ); + $this->assertFalse( $p->has_bookmark( 'my-bookmark' ) ); + } + + /** + * @ticket 57788 + * + * @covers WP_HTML_Tag_Processor::has_bookmark + */ + public function test_has_bookmark_returns_true_if_bookmark_exists() { + $p = new WP_HTML_Tag_Processor( '
Test
' ); + $p->next_tag(); + $p->set_bookmark( 'my-bookmark' ); + $this->assertTrue( $p->has_bookmark( 'my-bookmark' ) ); + } + + /** + * @ticket 57788 + * + * @covers WP_HTML_Tag_Processor::has_bookmark + */ + public function test_has_bookmark_returns_false_if_bookmark_has_been_released() { + $p = new WP_HTML_Tag_Processor( '
Test
' ); + $p->next_tag(); + $p->set_bookmark( 'my-bookmark' ); + $p->release_bookmark( 'my-bookmark' ); + $this->assertFalse( $p->has_bookmark( 'my-bookmark' ) ); + } + /** * @ticket 56299 *