- Timestamp:
- 03/14/2024 01:32:56 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPIFunctions.php
r57826 r57832 451 451 $this->assertEquals( '1', $processor->get_attribute( 'src' ) ); 452 452 } 453 454 /** 455 * Tests that context from void tags is not propagated to next tags. 456 * 457 * @ticket 60768 458 * 459 * @covers wp_interactivity_process_directives_of_interactive_blocks 460 */ 461 public function test_process_context_directive_in_void_tags() { 462 register_block_type( 463 'test/custom-directive-block', 464 array( 465 'render_callback' => function () { 466 return '<div data-wp-interactive="nameSpace" data-wp-context=\'{"text": "outer"}\'><input id="first-input" data-wp-context=\'{"text": "inner"}\' data-wp-bind--value="context.text" /><input id="second-input" data-wp-bind--value="context.text" /></div>'; 467 }, 468 'supports' => array( 469 'interactivity' => true, 470 ), 471 ) 472 ); 473 $post_content = '<!-- wp:test/custom-directive-block /-->'; 474 $processed_content = do_blocks( $post_content ); 475 $processor = new WP_HTML_Tag_Processor( $processed_content ); 476 $processor->next_tag( 477 array( 478 'tag_name' => 'input', 479 'id' => 'first-input', 480 ) 481 ); 482 $first_input_value = $processor->get_attribute( 'value' ); 483 $processor->next_tag( 484 array( 485 'tag_name' => 'input', 486 'id' => 'second-input', 487 ) 488 ); 489 $second_input_value = $processor->get_attribute( 'value' ); 490 unregister_block_type( 'test/custom-directive-block' ); 491 $this->assertEquals( 'inner', $first_input_value ); 492 $this->assertEquals( 'outer', $second_input_value ); 493 } 494 495 /** 496 * Tests that namespace from void tags is not propagated to next tags. 497 * 498 * @ticket 60768 499 * 500 * @covers wp_interactivity_process_directives_of_interactive_blocks 501 */ 502 public function test_process_interactive_directive_in_void_tags() { 503 wp_interactivity_state( 504 'void', 505 array( 506 'text' => 'void', 507 ) 508 ); 509 register_block_type( 510 'test/custom-directive-block', 511 array( 512 'render_callback' => function () { 513 return '<div data-wp-interactive="parent"><img data-wp-interactive="void" /><input data-wp-bind--value="state.text" /></div>'; 514 }, 515 'supports' => array( 516 'interactivity' => true, 517 ), 518 ) 519 ); 520 $post_content = '<!-- wp:test/custom-directive-block /-->'; 521 $processed_content = do_blocks( $post_content ); 522 $processor = new WP_HTML_Tag_Processor( $processed_content ); 523 $processor->next_tag( array( 'tag_name' => 'input' ) ); 524 $input_value = $processor->get_attribute( 'value' ); 525 unregister_block_type( 'test/custom-directive-block' ); 526 $this->assertNull( $input_value ); 527 } 453 528 }
Note: See TracChangeset
for help on using the changeset viewer.