Ticket #16560: 16560-unit-test.patch
File 16560-unit-test.patch, 4.2 KB (added by , 13 years ago) |
---|
-
wp-testcase/test_includes_wp-scripts.php
35 35 // No scripts left to print 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://localhost/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 // Go! 71 $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) ); 72 73 // No scripts left to print 74 $this->assertEquals( '', get_echo( 'wp_print_scripts' ) ); 75 76 // Cleanup 77 $wp_scripts->base_url = $base_url_backup; 78 } 38 79 } 39 80 ?> -
wp-testcase/test_includes_wp-styles.php
33 33 // No styles left to print 34 34 $this->assertEquals("", get_echo('wp_print_styles')); 35 35 } 36 37 /** 38 * Test the different protocol references in wp_enqueue_style 39 * @global WP_Styles $wp_styles 40 */ 41 public function test_protocols() { 42 $this->knownWPBug( 16560 ); 43 44 // Init 45 global $wp_styles; 46 $base_url_backup = $wp_styles->base_url; 47 $wp_styles->base_url = 'http://localhost/wordpress'; 48 $expected = ''; 49 $ver = get_bloginfo( 'version' ); 50 51 // Try with an HTTP reference 52 wp_enqueue_style( 'reset-css-http', 'http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css' ); 53 $expected .= "<link rel='stylesheet' id='reset-css-http-css' href='http://yui.yahooapis.com/2.8.1/build/reset/reset-min.css?ver=$ver' type='text/css' media='all' />\n"; 54 55 // Try with an HTTPS reference 56 wp_enqueue_style( 'reset-css-https', 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' ); 57 $expected .= "<link rel='stylesheet' id='reset-css-https-css' href='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js?ver=$ver' type='text/css' media='all' />\n"; 58 59 // Try with an automatic protocol reference (//) 60 wp_enqueue_style( 'reset-css-doubleslash', '//yui.yahooapis.com/2.8.1/build/reset/reset-min.css' ); 61 $expected .= "<link rel='stylesheet' id='reset-css-doubleslash-css' href='//yui.yahooapis.com/2.8.1/build/reset/reset-min.css?ver=$ver' type='text/css' media='all' />\n"; 62 63 // Try with a local resource and an automatic protocol reference (//) 64 $url = '/' . plugins_url( '/my_plugin/style.css'); 65 wp_enqueue_style( 'plugin-style', $url ); 66 $expected .= "<link rel='stylesheet' id='plugin-style-css' href='$url?ver=$ver' type='text/css' media='all' />\n"; 67 68 // Go! 69 $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); 70 71 // No styles left to print 72 $this->assertEquals( '', get_echo( 'wp_print_styles' ) ); 73 74 // Cleanup 75 $wp_styles->base_url = $base_url_backup; 76 } 36 77 } 37 78 ?>