Skip to content

Commit 2b443a8

Browse files
committed
search for target tag directly
1 parent dc65bb3 commit 2b443a8

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,15 @@ public static function data_modifiable_text_special_textarea(): array {
8181
public function test_set_modifiable_fails_non_atomic_tags(
8282
string $html,
8383
string $expected_namespace,
84-
string $expected_tag
84+
string $target_tag
8585
): void {
8686
$processor = WP_HTML_Processor::create_fragment( $html );
8787
$this->assertInstanceOf( WP_HTML_Tag_Processor::class, $processor );
88-
while ( $processor->next_tag() && $expected_tag !== $processor->get_tag() ) {
89-
continue;
90-
}
91-
$this->assertSame( $expected_tag, $processor->get_tag(), 'Failed to find target tag.' );
88+
$this->assertTrue( $processor->next_tag( $target_tag ), 'Failed to find target tag.' );
9289
$this->assertSame( $expected_namespace, $processor->get_namespace(), 'Unexpected namespace.' );
9390
$this->assertFalse(
9491
$processor->set_modifiable_text( 'test' ),
95-
"set_modifiable_text() should return false for {$expected_namespace}:{$expected_tag}."
92+
"set_modifiable_text() should return false for {$expected_namespace}:{$target_tag}."
9693
);
9794
$this->assertSame(
9895
$html,

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,15 +677,14 @@ public function test_modifiable_text_special_textarea(): void {
677677
public function test_set_modifiable_fails_non_atomic_tags(
678678
string $html,
679679
string $parsing_namespace,
680-
string $expected_tag
680+
string $target_tag
681681
): void {
682682
$processor = new WP_HTML_Tag_Processor( $html );
683683
$processor->change_parsing_namespace( $parsing_namespace );
684-
$processor->next_token();
685-
$this->assertSame( $expected_tag, $processor->get_tag(), 'Failed to find target tag.' );
684+
$this->assertTrue( $processor->next_tag( $target_tag ), 'Failed to find target tag.' );
686685
$this->assertFalse(
687686
$processor->set_modifiable_text( 'test' ),
688-
"set_modifiable_text() should return false for {$parsing_namespace}:{$expected_tag}."
687+
"set_modifiable_text() should return false for {$parsing_namespace}:{$target_tag}."
689688
);
690689
$this->assertSame(
691690
$html,

0 commit comments

Comments
 (0)