' );
$processor->next_tag( 'P' );
$this->assertSame( 'P', $processor->get_tag(), "Expected to start test on P element but found {$processor->get_tag()} instead." );
$this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN', 'P' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting.' );
$this->assertTrue( $processor->next_tag(), 'Failed to advance past P tag to expected DIV opener.' );
$this->assertSame( 'DIV', $processor->get_tag(), "Expected to find DIV element, but found {$processor->get_tag()} instead." );
$this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN', 'DIV' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting: SPAN should still be open and DIV should be its child.' );
}
/**
* Verifies that when "in body" and encountering "any other end tag"
* that the HTML processor closes appropriate elements on the stack of
* open elements up to the matching opening.
*
* @covers WP_HTML_Processor::step_in_body
*
* @ticket 58907
*
* @since 6.4.0
*/
public function test_in_body_any_other_end_tag_with_unclosed_non_special_element() {
$processor = WP_HTML_Processor::create_fragment( '
' );
$processor->next_tag( 'CODE' );
$this->assertSame( 'CODE', $processor->get_tag(), "Expected to start test on CODE element but found {$processor->get_tag()} instead." );
$this->assertSame( array( 'HTML', 'BODY', 'DIV', 'SPAN', 'CODE' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting.' );
$this->assertTrue( $processor->step(), 'Failed to advance past CODE tag to expected SPAN closer.' );
$this->assertTrue( $processor->is_tag_closer(), 'Expected to find closing SPAN, but found opener instead.' );
$this->assertSame( array( 'HTML', 'BODY', 'DIV' ), $processor->get_breadcrumbs(), 'Failed to advance past CODE tag to expected DIV opener.' );
$this->assertTrue( $processor->next_tag(), 'Failed to advance past SPAN closer to expected DIV opener.' );
$this->assertSame( 'DIV', $processor->get_tag(), "Expected to find DIV element, but found {$processor->get_tag()} instead." );
$this->assertSame( array( 'HTML', 'BODY', 'DIV', 'DIV' ), $processor->get_breadcrumbs(), 'Failed to produce expected DOM nesting: SPAN should be closed and DIV should be its sibling.' );
}
/**
* Ensures that support isn't accidentally partially added for the closing BR tag ``.
*
* This tag closer has special rules and support shouldn't be added without implementing full support.
*
* > An end tag whose tag name is "br"
* > Parse error. Drop the attributes from the token, and act as described in the next entry;
* > i.e. act as if this was a "br" start tag token with no attributes, rather than the end
* > tag token that it actually is.
*
* When this handling is implemented, this test should be removed. It's not incorporated
* into the existing unsupported tag behavior test because the opening tag is supported;
* only the closing tag isn't.
*
* @covers WP_HTML_Processor::step_in_body
*
* @ticket 60283
*/
public function test_br_end_tag_unsupported() {
$processor = WP_HTML_Processor::create_fragment( '' );
$this->assertFalse( $processor->next_tag(), 'Found a BR tag that should not be handled.' );
$this->assertSame( WP_HTML_Processor::ERROR_UNSUPPORTED, $processor->get_last_error() );
}
}