- Timestamp:
- 05/03/2023 12:09:22 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.2/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php
r55707 r55708 520 520 $p = new WP_HTML_Tag_Processor( 'abc</title>' ); 521 521 $this->assertTrue( $p->next_tag( array( 'tag_closers' => 'visit' ) ), 'Did not find the </title> tag closer when there was no tag opener' ); 522 } 523 524 /** 525 * Verifies that updates to a document before calls to `get_updated_html()` don't 526 * lead to the Tag Processor jumping to the wrong tag after the updates. 527 * 528 * @ticket 58179 529 * 530 * @covers WP_HTML_Tag_Processor::get_updated_html 531 */ 532 public function test_internal_pointer_returns_to_original_spot_after_inserting_content_before_cursor() { 533 $tags = new WP_HTML_Tag_Processor( '<div>outside</div><section><div><img>inside</div></section>' ); 534 535 $tags->next_tag(); 536 $tags->add_class( 'foo' ); 537 $tags->next_tag( 'section' ); 538 539 // Return to this spot after moving ahead. 540 $tags->set_bookmark( 'here' ); 541 542 // Move ahead. 543 $tags->next_tag( 'img' ); 544 $tags->seek( 'here' ); 545 $this->assertSame( '<div class="foo">outside</div><section><div><img>inside</div></section>', $tags->get_updated_html() ); 546 $this->assertSame( 'SECTION', $tags->get_tag() ); 547 $this->assertFalse( $tags->is_tag_closer() ); 522 548 } 523 549 … … 1473 1499 1474 1500 $p = new WP_HTML_Tag_Processor( $input ); 1475 $this->assertTrue( $p->next_tag( 'div' ), ' Querying an existing tag did not return true' );1501 $this->assertTrue( $p->next_tag( 'div' ), 'Did not find first DIV tag in input.' ); 1476 1502 $p->set_attribute( 'data-details', '{ "key": "value" }' ); 1477 1503 $p->add_class( 'is-processed' ); … … 1483 1509 ) 1484 1510 ), 1485 ' Querying an existing tag did not return true'1511 'Did not find the first BtnGroup DIV tag' 1486 1512 ); 1487 1513 $p->remove_class( 'BtnGroup' ); … … 1495 1521 ) 1496 1522 ), 1497 ' Querying an existing tag did not return true'1523 'Did not find the second BtnGroup DIV tag' 1498 1524 ); 1499 1525 $p->remove_class( 'BtnGroup' ); … … 1508 1534 ) 1509 1535 ), 1510 ' Querying an existing tag did not return true'1536 'Did not find third BUTTON tag with "btn" CSS class' 1511 1537 ); 1512 1538 $p->remove_attribute( 'class' ); 1513 $this->assertFalse( $p->next_tag( 'non-existent' ), 'Querying a non-existing tag did not return false');1539 $this->assertFalse( $p->next_tag( 'non-existent' ), "Found a {$p->get_tag()} tag when none should have been found." ); 1514 1540 $p->set_attribute( 'class', 'test' ); 1515 1541 $this->assertSame( $expected_output, $p->get_updated_html(), 'Calling get_updated_html after updating the attributes did not return the expected HTML' );
Note: See TracChangeset
for help on using the changeset viewer.