- Timestamp:
- 04/24/2024 07:43:02 AM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php
r57987 r58040 589 589 * 590 590 * @covers ::process_directives 591 */ 592 public function test_process_directives_doesnt_change_html_if_contains_unbalanced_tags() { 591 * 592 * @dataProvider data_html_with_unbalanced_tags 593 * 594 * @param string $html HTML containing unbalanced tags and also a directive. 595 */ 596 public function test_process_directives_doesnt_change_html_if_contains_unbalanced_tags( $html ) { 593 597 $this->interactivity->state( 'myPlugin', array( 'id' => 'some-id' ) ); 594 598 595 $html_samples = array( 596 '<div data-wp-bind--id="myPlugin::state.id">Inner content</div></div>', 597 '<div data-wp-bind--id="myPlugin::state.id">Inner content</div><div>', 598 '<div><div data-wp-bind--id="myPlugin::state.id">Inner content</div>', 599 '</div><div data-wp-bind--id="myPlugin::state.id">Inner content</div>', 600 '<div data-wp-bind--id="myPlugin::state.id">Inner<div>content</div>', 601 '<div data-wp-bind--id="myPlugin::state.id">Inner</div>content</div>', 602 '<div data-wp-bind--id="myPlugin::state.id"><span>Inner content</div>', 603 '<div data-wp-bind--id="myPlugin::state.id">Inner content</div></span>', 604 '<div data-wp-bind--id="myPlugin::state.id"><span>Inner content</div></span>', 605 '<div data-wp-bind--id="myPlugin::state.id">Inner conntent</ ></div>', 606 ); 607 608 foreach ( $html_samples as $html ) { 609 $processed_html = $this->interactivity->process_directives( $html ); 610 $p = new WP_HTML_Tag_Processor( $processed_html ); 611 $p->next_tag(); 612 $this->assertNull( $p->get_attribute( 'id' ) ); 613 } 599 $processed_html = $this->interactivity->process_directives( $html ); 600 $p = new WP_HTML_Tag_Processor( $processed_html ); 601 $p->next_tag(); 602 $this->assertNull( $p->get_attribute( 'id' ) ); 603 } 604 605 /** 606 * Data provider. 607 * 608 * @return array[]. 609 */ 610 public static function data_html_with_unbalanced_tags() { 611 return array( 612 'DIV closer after' => array( '<div data-wp-bind--id="myPlugin::state.id">Inner content</div></div>' ), 613 'DIV opener after' => array( '<div data-wp-bind--id="myPlugin::state.id">Inner content</div><div>' ), 614 'DIV opener before' => array( '<div><div data-wp-bind--id="myPlugin::state.id">Inner content</div>' ), 615 'DIV closer before' => array( '</div><div data-wp-bind--id="myPlugin::state.id">Inner content</div>' ), 616 'DIV opener inside' => array( '<div data-wp-bind--id="myPlugin::state.id">Inner<div>content</div>' ), 617 'DIV closer inside' => array( '<div data-wp-bind--id="myPlugin::state.id">Inner</div>content</div>' ), 618 'SPAN opener inside' => array( '<div data-wp-bind--id="myPlugin::state.id"><span>Inner content</div>' ), 619 'SPAN closer after' => array( '<div data-wp-bind--id="myPlugin::state.id">Inner content</div></span>' ), 620 'SPAN overlapping' => array( '<div data-wp-bind--id="myPlugin::state.id"><span>Inner content</div></span>' ), 621 ); 614 622 } 615 623
Note: See TracChangeset
for help on using the changeset viewer.