Skip to content

Commit

Permalink
Copy failing WP_HTML_Tag_Processor_Bookmark_Test tests from Core
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Feb 3, 2023
1 parent 127e3d3 commit ee45b79
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions phpunit/html/wp-html-tag-processor-bookmark-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,12 @@ public function test_limits_the_number_of_bookmarks() {
$p = new WP_HTML_Tag_Processor( '<ul><li>One</li><li>Two</li><li>Three</li></ul>' );
$p->next_tag( 'li' );

$this->expectException( Exception::class );

for ( $i = 0;$i < WP_HTML_Tag_Processor::MAX_BOOKMARKS;$i++ ) {
for ( $i = 0; $i < WP_HTML_Tag_Processor::MAX_BOOKMARKS; $i++ ) {
$this->assertTrue( $p->set_bookmark( "bookmark $i" ), "Could not allocate the bookmark #$i" );
}

$this->assertFalse( $p->set_bookmark( 'final bookmark' ), "Allocated $i bookmarks, which is one above the limit." );
$this->setExpectedIncorrectUsage( 'WP_HTML_Tag_Processor::set_bookmark' );
$this->assertFalse( $p->set_bookmark( 'final bookmark' ), "Allocated $i bookmarks, which is one above the limit" );
}

/**
Expand All @@ -360,11 +359,11 @@ public function test_limits_the_number_of_seek_calls() {
$p->next_tag( 'li' );
$p->set_bookmark( 'bookmark' );

$this->expectException( Exception::class );

for ( $i = 0; $i < WP_HTML_Tag_Processor::MAX_SEEK_OPS; $i++ ) {
$this->assertTrue( $p->seek( 'bookmark' ), 'Could not seek to the "bookmark"' );
}
$this->assertFalse( $p->seek( 'bookmark' ), "$i-th seek() to the bookmark succeeded, even though it should exceed the allowed limit." );

$this->setExpectedIncorrectUsage( 'WP_HTML_Tag_Processor::seek' );
$this->assertFalse( $p->seek( 'bookmark' ), "$i-th seek() to the bookmark succeeded, even though it should exceed the allowed limit" );
}
}

0 comments on commit ee45b79

Please sign in to comment.