Changeset 749 in tests for wp-testcase/test_includes_wp-scripts.php
- Timestamp:
- 06/28/2012 08:05:14 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_includes_wp-scripts.php
r581 r749 36 36 $this->assertEquals("", get_echo('wp_print_scripts')); 37 37 } 38 39 /** 40 * Test the different protocol references in wp_enqueue_script 41 * @global WP_Scripts $wp_scripts 42 */ 43 public function test_protocols() { 44 $this->knownWPBug( 16560 ); 45 46 // Init 47 global $wp_scripts; 48 $base_url_backup = $wp_scripts->base_url; 49 $wp_scripts->base_url = 'http://example.com/wordpress'; 50 $expected = ''; 51 $ver = get_bloginfo( 'version' ); 52 53 // Try with an HTTP reference 54 wp_enqueue_script( 'jquery-http', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 55 $expected .= "<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n"; 56 57 // Try with an HTTPS reference 58 wp_enqueue_script( 'jquery-https', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 59 $expected .= "<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n"; 60 61 // Try with an automatic protocol reference (//) 62 wp_enqueue_script( 'jquery-doubleslash', '//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 63 $expected .= "<script type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver'></script>\n"; 64 65 // Try with a local resource and an automatic protocol reference (//) 66 $url = '/' . plugins_url( '/my_plugin/script.js'); 67 wp_enqueue_script( 'plugin-script', $url ); 68 $expected .= "<script type='text/javascript' src='$url?ver=$ver'></script>\n"; 69 70 // Try with a bad protocol 71 wp_enqueue_script( 'jquery-ftp', 'ftp://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 72 $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"; 73 74 // Go! 75 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 76 77 // No scripts left to print 78 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 79 80 // Cleanup 81 $wp_scripts->base_url = $base_url_backup; 82 } 38 83 } 39 84 ?>
Note: See TracChangeset
for help on using the changeset viewer.