WordPress.org

Make WordPress Core

Changeset 46180


Ignore:
Timestamp:
09/19/2019 11:14:38 AM (2 months ago)
Author:
SergeyBiryukov
Message:

Tests: Update unit tests to account for the removal of old wp-a11y from the loaded scripts in [46179].

Props sstoqnov.
See #45066, #48071.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/dependencies/scripts.php

    r46169 r46180  
    713713
    714714        $ver       = get_bloginfo( 'version' );
    715         $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate,wp-sanitize,wp-a11y&amp;ver={$ver}'></script>\n";
     715        $expected  = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&amp;load%5Bchunk_0%5D=jquery-core,jquery-migrate&amp;ver={$ver}'></script>\n";
    716716        $expected .= "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
    717717        $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";
    718724        $expected .= "<script type='text/javascript' src='http://example2.com'></script>\n";
    719725        $expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
     
    724730        wp_add_inline_script( 'test-example2', 'console.log("after");', 'after' );
    725731
    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        );
    728744
    729745        $this->assertEquals( $expected, $print_scripts );
     
    751767        wp_add_inline_script( $handle, 'tryCustomizeDependency()' );
    752768
    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' );
    755771
    756772        $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.