Changeset 60728 for trunk/tests/phpunit/tests/dependencies/scripts.php
- Timestamp:
- 09/11/2025 10:11:40 AM (9 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/dependencies/scripts.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/scripts.php
r60719 r60728 2629 2629 ); 2630 2630 $expected .= "<script type='text/javascript' src='/wp-includes/js/script.js' id='test-example-js'></script>\n"; 2631 2632 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); 2633 } 2634 2635 /** 2636 * @ticket 63944 2637 */ 2638 public function test_wp_set_script_translations_uses_registered_domainpath_for_plugin() { 2639 global $wp_textdomain_registry; 2640 2641 wp_register_script( 'wp-i18n', '/wp-includes/js/dist/wp-i18n.js', array(), null ); 2642 wp_enqueue_script( 'domain-path-plugin', '/wp-content/plugins/my-plugin/js/script.js', array(), null ); 2643 2644 // Simulate a plugin declaring DomainPath: /languages by registering a custom path. 2645 $wp_textdomain_registry->set_custom_path( 'internationalized-plugin', DIR_TESTDATA . '/languages/plugins' ); 2646 wp_set_script_translations( 'domain-path-plugin', 'internationalized-plugin' ); 2647 2648 $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n"; 2649 $expected .= str_replace( 2650 array( 2651 '__DOMAIN__', 2652 '__HANDLE__', 2653 '__JSON_TRANSLATIONS__', 2654 ), 2655 array( 2656 'internationalized-plugin', 2657 'domain-path-plugin', 2658 file_get_contents( DIR_TESTDATA . '/languages/plugins/internationalized-plugin-en_US-2f86cb96a0233e7cb3b6f03ad573be0b.json' ), 2659 ), 2660 $this->wp_scripts_print_translations_output 2661 ); 2662 $expected .= "<script type='text/javascript' src='/wp-content/plugins/my-plugin/js/script.js' id='domain-path-plugin-js'></script>\n"; 2663 2664 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) ); 2665 } 2666 2667 /** 2668 * @ticket 63944 2669 * 2670 * Ensure human-readable script translation filenames are found when a 2671 * textdomain has a custom DomainPath registered and no explicit $path is passed. 2672 */ 2673 public function test_wp_set_script_translations_prefers_human_readable_filename_in_registered_domainpath() { 2674 global $wp_textdomain_registry; 2675 2676 wp_register_script( 'wp-i18n', '/wp-includes/js/dist/wp-i18n.js', array(), null ); 2677 wp_enqueue_script( 'script-handle', '/wp-admin/js/script.js', array(), null ); 2678 2679 // Register the admin textdomain path and use the admin translations file for this script-handle test. 2680 $wp_textdomain_registry->set_custom_path( 'admin', DIR_TESTDATA . '/languages' ); 2681 wp_set_script_translations( 'script-handle', 'admin' ); 2682 2683 $expected = "<script type='text/javascript' src='/wp-includes/js/dist/wp-i18n.js' id='wp-i18n-js'></script>\n"; 2684 $expected .= str_replace( 2685 array( 2686 '__DOMAIN__', 2687 '__HANDLE__', 2688 '__JSON_TRANSLATIONS__', 2689 ), 2690 array( 2691 'admin', 2692 'script-handle', 2693 file_get_contents( DIR_TESTDATA . '/languages/admin-en_US-script-handle.json' ), 2694 ), 2695 $this->wp_scripts_print_translations_output 2696 ); 2697 $expected .= "<script type='text/javascript' src='/wp-admin/js/script.js' id='script-handle-js'></script>\n"; 2631 2698 2632 2699 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );
Note: See TracChangeset
for help on using the changeset viewer.