- Timestamp:
- 10/21/2025 11:30:43 AM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI.php
r60953 r61019 27 27 $this->interactivity = new WP_Interactivity_API(); 28 28 wp_default_script_modules(); 29 $this->interactivity->add_hooks(); 30 } 31 32 /** 33 * Tear down. 34 */ 35 public function tear_down() { 36 global $wp_script_modules; 37 parent::tear_down(); 38 $wp_script_modules = null; 29 39 } 30 40 … … 237 247 */ 238 248 private function get_script_data_filter_result( ?Closure $callback = null ): MockAction { 239 $this->interactivity->add_hooks();240 249 wp_enqueue_script_module( '@wordpress/interactivity' ); 241 250 $filter = new MockAction(); … … 1724 1733 $this->assertStringNotContainsString( 'class="[disallowed]"', $processed_html ); 1725 1734 } 1735 1736 /** 1737 * Tests that add_client_navigation_support_to_script_module marks a 1738 * script module for client navigation. 1739 * 1740 * @ticket 64122 1741 * 1742 * @covers WP_Interactivity_API::add_client_navigation_support_to_script_module 1743 * @covers WP_Interactivity_API::add_load_on_client_navigation_attribute_to_script_modules 1744 */ 1745 public function test_add_client_navigation_support_to_script_module() { 1746 $this->interactivity->add_client_navigation_support_to_script_module( 'marked-module' ); 1747 1748 wp_register_script_module( 'marked-module', '/marked.js' ); 1749 wp_register_script_module( 'unmarked-module', '/unmarked.js' ); 1750 wp_enqueue_script_module( 'marked-module' ); 1751 wp_enqueue_script_module( 'unmarked-module' ); 1752 1753 $output = get_echo( array( wp_script_modules(), 'print_enqueued_script_modules' ) ); 1754 1755 $p = new WP_HTML_Tag_Processor( $output ); 1756 1757 // First module: marked-module should have the attribute. 1758 $p->next_tag( array( 'tag_name' => 'SCRIPT' ) ); 1759 $this->assertSame( 'marked-module-js-module', $p->get_attribute( 'id' ) ); 1760 $this->assertSame( 1761 '{"loadOnClientNavigation":true}', 1762 $p->get_attribute( 'data-wp-router-options' ) 1763 ); 1764 1765 // Second module: unmarked-module should NOT have the attribute. 1766 $p->next_tag( array( 'tag_name' => 'SCRIPT' ) ); 1767 $this->assertSame( 'unmarked-module-js-module', $p->get_attribute( 'id' ) ); 1768 $this->assertNull( $p->get_attribute( 'data-wp-router-options' ) ); 1769 } 1726 1770 }
Note: See TracChangeset
for help on using the changeset viewer.