Changeset 61019 for trunk/tests/phpunit/tests/blocks/register.php
- Timestamp:
- 10/21/2025 11:30:43 AM (13 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/blocks/register.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/blocks/register.php
r61008 r61019 428 428 ) === 0 429 429 ); 430 } 431 432 /** 433 * Tests that blocks with supports.interactivity have the 434 * `data-wp-router-options` directive. 435 * 436 * @ticket 64122 437 * 438 * @covers ::register_block_script_module_id 439 */ 440 public function test_register_block_script_module_id_with_interactivity_true() { 441 $metadata = array( 442 'file' => DIR_TESTDATA . '/blocks/notice/block.json', 443 'viewScriptModule' => 'file:./block.js', 444 ); 445 446 $interactivity_true = array_merge( 447 $metadata, 448 array( 449 'name' => 'tests/interactivity-true', 450 'supports' => array( 'interactivity' => true ), 451 ) 452 ); 453 $interactive_and_client_navigation = array_merge( 454 $metadata, 455 array( 456 'name' => 'tests/interactive-and-client-navigation', 457 'supports' => array( 458 'interactivity' => array( 459 'interactive' => true, 460 'clientNavigation' => true, 461 ), 462 ), 463 ) 464 ); 465 $interactive_and_not_client_navigation = array_merge( 466 $metadata, 467 array( 468 'name' => 'tests/interactive-and-not-client-navigation', 469 'supports' => array( 470 'interactivity' => array( 471 'interactive' => true, 472 'clientNavigation' => false, 473 ), 474 ), 475 ) 476 ); 477 $not_interactive_and_client_navigation = array_merge( 478 $metadata, 479 array( 480 'name' => 'tests/not-interactive-and-client-navigation', 481 'supports' => array( 482 'interactivity' => array( 483 'interactive' => false, 484 'clientNavigation' => true, 485 ), 486 ), 487 ) 488 ); 489 $no_interactivity = array_merge( 490 $metadata, 491 array( 492 'name' => 'tests/no-interactivity', 493 'supports' => array(), 494 ) 495 ); 496 497 $interactivity_true_module_id = register_block_script_module_id( $interactivity_true, 'viewScriptModule' ); 498 $interactive_and_client_navigation_module_id = register_block_script_module_id( $interactive_and_client_navigation, 'viewScriptModule' ); 499 $interactive_and_not_client_navigation_module_id = register_block_script_module_id( $interactive_and_not_client_navigation, 'viewScriptModule' ); 500 $not_interactive_and_client_navigation_module_id = register_block_script_module_id( $not_interactive_and_client_navigation, 'viewScriptModule' ); 501 $no_interactivity_module_id = register_block_script_module_id( $no_interactivity, 'viewScriptModule' ); 502 wp_enqueue_script_module( $interactivity_true_module_id ); 503 wp_enqueue_script_module( $interactive_and_client_navigation_module_id ); 504 wp_enqueue_script_module( $interactive_and_not_client_navigation_module_id ); 505 wp_enqueue_script_module( $not_interactive_and_client_navigation_module_id ); 506 wp_enqueue_script_module( $no_interactivity_module_id ); 507 508 $output = get_echo( array( wp_script_modules(), 'print_enqueued_script_modules' ) ); 509 510 $p = new WP_HTML_Tag_Processor( $output ); 511 512 $this->assertTrue( $p->next_tag( array( 'tag_name' => 'SCRIPT' ) ), 'Expected there to be another SCRIPT.' ); 513 $this->assertSame( 'tests-interactivity-true-view-script-module-js-module', $p->get_attribute( 'id' ) ); 514 $this->assertSame( '{"loadOnClientNavigation":true}', $p->get_attribute( 'data-wp-router-options' ) ); 515 516 $this->assertTrue( $p->next_tag( array( 'tag_name' => 'SCRIPT' ) ), 'Expected there to be another SCRIPT.' ); 517 $this->assertSame( 'tests-interactive-and-client-navigation-view-script-module-js-module', $p->get_attribute( 'id' ) ); 518 $this->assertSame( '{"loadOnClientNavigation":true}', $p->get_attribute( 'data-wp-router-options' ) ); 519 520 $this->assertTrue( $p->next_tag( array( 'tag_name' => 'SCRIPT' ) ), 'Expected there to be another SCRIPT.' ); 521 $this->assertSame( 'tests-interactive-and-not-client-navigation-view-script-module-js-module', $p->get_attribute( 'id' ) ); 522 $this->assertNull( $p->get_attribute( 'data-wp-router-options' ) ); 523 524 $this->assertTrue( $p->next_tag( array( 'tag_name' => 'SCRIPT' ) ), 'Expected there to be another SCRIPT.' ); 525 $this->assertSame( 'tests-not-interactive-and-client-navigation-view-script-module-js-module', $p->get_attribute( 'id' ) ); 526 $this->assertNull( $p->get_attribute( 'data-wp-router-options' ) ); 527 528 $this->assertTrue( $p->next_tag( array( 'tag_name' => 'SCRIPT' ) ), 'Expected there to be another SCRIPT.' ); 529 $this->assertSame( 'tests-no-interactivity-view-script-module-js-module', $p->get_attribute( 'id' ) ); 530 $this->assertNull( $p->get_attribute( 'data-wp-router-options' ) ); 430 531 } 431 532
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)