Changeset 46180
- Timestamp:
- 09/19/2019 11:14:38 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/scripts.php
r46169 r46180 713 713 714 714 $ver = get_bloginfo( 'version' ); 715 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate ,wp-sanitize,wp-a11y&ver={$ver}'></script>\n";715 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate&ver={$ver}'></script>\n"; 716 716 $expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n"; 717 717 $expected .= "<script type='text/javascript' src='http://example.com'></script>\n"; 718 $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/vendor/wp-polyfill.min.js'></script>\n"; 719 $expected .= "<script type='text/javascript'>\n"; 720 $expected .= "( 'fetch' in window ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-fetch.min.js\"></scr' + 'ipt>' );( document.contains ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-node-contains.min.js\"></scr' + 'ipt>' );( window.FormData && window.FormData.prototype.keys ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js\"></scr' + 'ipt>' );( Element.prototype.matches && Element.prototype.closest ) || document.write( '<script src=\"http://example.org/wp-includes/js/dist/vendor/wp-polyfill-element-closest.min.js\"></scr' + 'ipt>' );\n"; 721 $expected .= "</script>\n"; 722 $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/dom-ready.min.js'></script>\n"; 723 $expected .= "<script type='text/javascript' src='/wp-includes/js/dist/a11y.min.js'></script>\n"; 718 724 $expected .= "<script type='text/javascript' src='http://example2.com'></script>\n"; 719 725 $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n"; … … 724 730 wp_add_inline_script( 'test-example2', 'console.log("after");', 'after' ); 725 731 726 wp_print_scripts(); 727 $print_scripts = get_echo( '_print_scripts' ); 732 $print_scripts = get_echo( 'wp_print_scripts' ); 733 $print_scripts .= get_echo( '_print_scripts' ); 734 735 // We've replaced wp-a11y.js with @wordpress/a11y package (see #45066), 736 // and `wp-polyfill` is now a dependency of the packaged wp-a11y. 737 // The packaged scripts contain various version numbers, which are 738 // not exposed, so we will remove all version args from the output. 739 $print_scripts = preg_replace( 740 '~js\?ver=([^"\']*)~', // Matches `js?ver=X.X.X` and everything to single or double quote. 741 'js', // The replacement, `js` without the version arg. 742 $print_scripts // Printed scripts. 743 ); 728 744 729 745 $this->assertEquals( $expected, $print_scripts ); … … 751 767 wp_add_inline_script( $handle, 'tryCustomizeDependency()' ); 752 768 753 wp_print_scripts();754 $print_scripts = get_echo( '_print_scripts' );769 $print_scripts = get_echo( 'wp_print_scripts' ); 770 $print_scripts .= get_echo( '_print_scripts' ); 755 771 756 772 $tail = substr( $print_scripts, strrpos( $print_scripts, "<script type='text/javascript' src='/customize-dependency.js'>" ) );
Note: See TracChangeset
for help on using the changeset viewer.