Changeset 47122 for trunk/tests/phpunit/tests/dependencies/scripts.php
- Timestamp:
- 01/29/2020 12:43:23 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/scripts.php
r46612 r47122 54 54 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 55 55 56 // No scripts left to print 56 // No scripts left to print. 57 57 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 58 58 } … … 82 82 */ 83 83 public function test_protocols() { 84 // Init 84 // Init. 85 85 global $wp_scripts; 86 86 $base_url_backup = $wp_scripts->base_url; … … 89 89 $ver = get_bloginfo( 'version' ); 90 90 91 // Try with an HTTP reference 91 // Try with an HTTP reference. 92 92 wp_enqueue_script( 'jquery-http', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 93 93 $expected .= "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n"; 94 94 95 // Try with an HTTPS reference 95 // Try with an HTTPS reference. 96 96 wp_enqueue_script( 'jquery-https', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 97 97 $expected .= "<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n"; 98 98 99 // Try with an automatic protocol reference (//) 99 // Try with an automatic protocol reference (//). 100 100 wp_enqueue_script( 'jquery-doubleslash', '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 101 101 $expected .= "<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n"; 102 102 103 // Try with a local resource and an automatic protocol reference (//) 103 // Try with a local resource and an automatic protocol reference (//). 104 104 $url = '//my_plugin/script.js'; 105 105 wp_enqueue_script( 'plugin-script', $url ); 106 106 $expected .= "<script type='text/javascript' src='$url?ver=$ver'></script>\n"; 107 107 108 // Try with a bad protocol 108 // Try with a bad protocol. 109 109 wp_enqueue_script( 'jquery-ftp', 'ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 110 110 $expected .= "<script type='text/javascript' src='{$wp_scripts->base_url}ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n"; … … 113 113 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 114 114 115 // No scripts left to print 115 // No scripts left to print. 116 116 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 117 117 118 // Cleanup 118 // Cleanup. 119 119 $wp_scripts->base_url = $base_url_backup; 120 120 } … … 148 148 */ 149 149 function test_wp_script_add_data_with_data_key() { 150 // Enqueue & add data150 // Enqueue and add data. 151 151 wp_enqueue_script( 'test-only-data', 'example.com', array(), null ); 152 152 wp_script_add_data( 'test-only-data', 'data', 'testing' ); … … 157 157 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 158 158 159 // No scripts left to print 159 // No scripts left to print. 160 160 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 161 161 } … … 167 167 */ 168 168 function test_wp_script_add_data_with_conditional_key() { 169 // Enqueue & add conditional comments169 // Enqueue and add conditional comments. 170 170 wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); 171 171 wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); … … 175 175 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 176 176 177 // No scripts left to print 177 // No scripts left to print. 178 178 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 179 179 } … … 185 185 */ 186 186 function test_wp_script_add_data_with_data_and_conditional_keys() { 187 // Enqueue & add data plus conditional comments for both187 // Enqueue and add data plus conditional comments for both. 188 188 wp_enqueue_script( 'test-conditional-with-data', 'example.com', array(), null ); 189 189 wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' ); … … 195 195 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 196 196 197 // No scripts left to print 197 // No scripts left to print. 198 198 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 199 199 } … … 205 205 */ 206 206 function test_wp_script_add_data_with_invalid_key() { 207 // Enqueue & add an invalid key207 // Enqueue and add an invalid key. 208 208 wp_enqueue_script( 'test-invalid', 'example.com', array(), null ); 209 209 wp_script_add_data( 'test-invalid', 'invalid', 'testing' ); … … 213 213 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 214 214 215 // No scripts left to print 215 // No scripts left to print. 216 216 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 217 217 } … … 311 311 */ 312 312 function test_wp_register_script_with_dependencies_in_head_and_footer() { 313 wp_register_script( 'parent', '/parent.js', array( 'child-head' ), null, true ); // in footer314 wp_register_script( 'child-head', '/child-head.js', array( 'child-footer' ), null, false ); // in head315 wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // in footer313 wp_register_script( 'parent', '/parent.js', array( 'child-head' ), null, true ); // In footer. 314 wp_register_script( 'child-head', '/child-head.js', array( 'child-footer' ), null, false ); // In head. 315 wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // In footer. 316 316 317 317 wp_enqueue_script( 'parent' ); … … 332 332 */ 333 333 function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order() { 334 wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // in head335 wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // in footer336 wp_register_script( 'parent', '/parent.js', array( 'child-head', 'child-footer' ), null, true ); // in footer334 wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // In head. 335 wp_register_script( 'child-footer', '/child-footer.js', array(), null, true ); // In footer. 336 wp_register_script( 'parent', '/parent.js', array( 'child-head', 'child-footer' ), null, true ); // In footer. 337 337 338 338 wp_enqueue_script( 'parent' ); … … 353 353 */ 354 354 function test_wp_register_script_with_dependencies_in_head_and_footer_in_reversed_order_and_two_parent_scripts() { 355 wp_register_script( 'grandchild-head', '/grandchild-head.js', array(), null, false ); // in head356 wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // in head357 wp_register_script( 'child-footer', '/child-footer.js', array( 'grandchild-head' ), null, true ); // in footer358 wp_register_script( 'child2-head', '/child2-head.js', array(), null, false ); // in head359 wp_register_script( 'child2-footer', '/child2-footer.js', array(), null, true ); // in footer360 wp_register_script( 'parent-footer', '/parent-footer.js', array( 'child-head', 'child-footer', 'child2-head', 'child2-footer' ), null, true ); // in footer361 wp_register_script( 'parent-header', '/parent-header.js', array( 'child-head' ), null, false ); // in head355 wp_register_script( 'grandchild-head', '/grandchild-head.js', array(), null, false ); // In head. 356 wp_register_script( 'child-head', '/child-head.js', array(), null, false ); // In head. 357 wp_register_script( 'child-footer', '/child-footer.js', array( 'grandchild-head' ), null, true ); // In footer. 358 wp_register_script( 'child2-head', '/child2-head.js', array(), null, false ); // In head. 359 wp_register_script( 'child2-footer', '/child2-footer.js', array(), null, true ); // In footer. 360 wp_register_script( 'parent-footer', '/parent-footer.js', array( 'child-head', 'child-footer', 'child2-head', 'child2-footer' ), null, true ); // In footer. 361 wp_register_script( 'parent-header', '/parent-header.js', array( 'child-head' ), null, false ); // In head. 362 362 363 363 wp_enqueue_script( 'parent-footer' ); … … 598 598 599 599 $wp_scripts->do_concat = true; 600 $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php 600 $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. 601 601 602 602 $expected_localized = "<!--[if gte IE 9]>\n"; … … 783 783 784 784 $wp_scripts->do_concat = true; 785 $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php 785 $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. 786 786 787 787 wp_enqueue_script( 'one', '/wp-includes/js/script.js' ); … … 808 808 809 809 $wp_scripts->do_concat = true; 810 $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php 810 $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. 811 811 812 812 wp_enqueue_script( 'one', '/wp-includes/js/script.js' );
Note: See TracChangeset
for help on using the changeset viewer.