- Timestamp:
- 02/17/2024 03:26:43 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php
r57563 r57649 12 12 * @coversDefaultClass WP_Interactivity_API 13 13 */ 14 class Tests_ WP_Interactivity_API extends WP_UnitTestCase {14 class Tests_Interactivity_API_WpInteractivityAPI extends WP_UnitTestCase { 15 15 /** 16 16 * Instance of WP_Interactivity_API. … … 509 509 510 510 /** 511 * Tests that the `process_directives` returns the same HTML if it finds an 512 * SVG tag. 513 * 514 * @ticket 60356 515 * 516 * @covers ::process_directives 517 */ 518 public function test_process_directives_doesnt_change_html_if_contains_svgs() { 519 $this->interactivity->state( 'myPlugin', array( 'id' => 'some-id' ) ); 511 * Tests that the `process_directives` process the HTML outside a SVG tag. 512 * 513 * @ticket 60517 514 * 515 * @covers ::process_directives 516 */ 517 public function test_process_directives_changes_html_if_contains_svgs() { 518 $this->interactivity->state( 519 'myPlugin', 520 array( 521 'id' => 'some-id', 522 'width' => '100', 523 ) 524 ); 520 525 $html = ' 521 <div data-wp-bind--id="myPlugin::state.id"> 522 <svg height="100" width="100"> 526 <header> 527 <svg height="100" data-wp-bind--width="myPlugin::state.width"> 528 <title>Red Circle</title> 523 529 <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /> 524 </svg> 525 </div> 530 </svg> 531 <div data-wp-bind--id="myPlugin::state.id"></div> 532 <div data-wp-bind--id="myPlugin::state.width"></div> 533 </header> 526 534 '; 527 535 $processed_html = $this->interactivity->process_directives( $html ); 528 536 $p = new WP_HTML_Tag_Processor( $processed_html ); 529 $p->next_tag(); 537 $p->next_tag( 'svg' ); 538 $this->assertNull( $p->get_attribute( 'width' ) ); 539 $p->next_tag( 'div' ); 540 $this->assertEquals( 'some-id', $p->get_attribute( 'id' ) ); 541 $p->next_tag( 'div' ); 542 $this->assertEquals( '100', $p->get_attribute( 'id' ) ); 543 } 544 545 /** 546 * Tests that the `process_directives` does not process the HTML 547 * inside SVG tags. 548 * 549 * @ticket 60517 550 * 551 * @covers ::process_directives 552 */ 553 public function test_process_directives_does_not_change_inner_html_in_svgs() { 554 $this->interactivity->state( 555 'myPlugin', 556 array( 557 'id' => 'some-id', 558 ) 559 ); 560 $html = ' 561 <header> 562 <svg height="100"> 563 <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" /> 564 <g data-wp-bind--id="myPlugin::state.id" /> 565 </svg> 566 </header> 567 '; 568 $processed_html = $this->interactivity->process_directives( $html ); 569 $p = new WP_HTML_Tag_Processor( $processed_html ); 570 $p->next_tag( 'div' ); 530 571 $this->assertNull( $p->get_attribute( 'id' ) ); 531 572 } 532 573 533 574 /** 534 * Tests that the `process_directives` returns the same HTML if it finds an575 * Tests that the `process_directives` process the HTML outside the 535 576 * MathML tag. 536 577 * 537 * @ticket 60356 538 * 539 * @covers ::process_directives 540 */ 541 public function test_process_directives_doesnt_change_html_if_contains_math() { 542 $this->interactivity->state( 'myPlugin', array( 'id' => 'some-id' ) ); 578 * @ticket 60517 579 * 580 * @covers ::process_directives 581 */ 582 public function test_process_directives_change_html_if_contains_math() { 583 $this->interactivity->state( 584 'myPlugin', 585 array( 586 'id' => 'some-id', 587 'math' => 'ml-id', 588 ) 589 ); 543 590 $html = ' 544 < div data-wp-bind--id="myPlugin::state.id">545 <math >591 <header> 592 <math data-wp-bind--id="myPlugin::state.math"> 546 593 <mi>x</mi> 547 594 <mo>=</mo> 548 595 <mi>1</mi> 549 596 </math> 550 </div> 597 <div data-wp-bind--id="myPlugin::state.id"></div> 598 </header> 551 599 '; 552 600 $processed_html = $this->interactivity->process_directives( $html ); 553 601 $p = new WP_HTML_Tag_Processor( $processed_html ); 554 $p->next_tag(); 602 $p->next_tag( 'math' ); 603 $this->assertNull( $p->get_attribute( 'id' ) ); 604 $p->next_tag( 'div' ); 605 $this->assertEquals( 'some-id', $p->get_attribute( 'id' ) ); 606 } 607 608 /** 609 * Tests that the `process_directives` does not process the HTML 610 * inside MathML tags. 611 * 612 * @ticket 60517 613 * 614 * @covers ::process_directives 615 */ 616 public function test_process_directives_does_not_change_inner_html_in_math() { 617 $this->interactivity->state( 618 'myPlugin', 619 array( 620 'id' => 'some-id', 621 ) 622 ); 623 $html = ' 624 <header> 625 <math data-wp-bind--id="myPlugin::state.math"> 626 <mrow data-wp-bind--id="myPlugin::state.id" /> 627 <mi>x</mi> 628 <mo>=</mo> 629 <mi>1</mi> 630 </math> 631 </header> 632 '; 633 $processed_html = $this->interactivity->process_directives( $html ); 634 $p = new WP_HTML_Tag_Processor( $processed_html ); 635 $p->next_tag( 'div' ); 555 636 $this->assertNull( $p->get_attribute( 'id' ) ); 556 637 }
Note: See TracChangeset
for help on using the changeset viewer.