mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-15 01:54:30 +00:00
Script/Style Dependencies: Make sure that inline scripts for handles without a source are printed.
See [36550] for `WP_Styles`. Props bpayton. Fixes #44551. git-svn-id: https://develop.svn.wordpress.org/trunk@43565 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -405,6 +405,47 @@ class Tests_Dependencies_Scripts extends WP_UnitTestCase {
|
||||
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44551
|
||||
*/
|
||||
function test_wp_add_inline_script_before_for_handle_without_source() {
|
||||
wp_register_script( 'test-example', '' );
|
||||
wp_enqueue_script( 'test-example' );
|
||||
wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
|
||||
|
||||
$expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
|
||||
|
||||
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44551
|
||||
*/
|
||||
function test_wp_add_inline_script_after_for_handle_without_source() {
|
||||
wp_register_script( 'test-example', '' );
|
||||
wp_enqueue_script( 'test-example' );
|
||||
wp_add_inline_script( 'test-example', 'console.log("after");' );
|
||||
|
||||
$expected = "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
|
||||
|
||||
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 44551
|
||||
*/
|
||||
function test_wp_add_inline_script_before_and_after_for_handle_without_source() {
|
||||
wp_register_script( 'test-example', '' );
|
||||
wp_enqueue_script( 'test-example' );
|
||||
wp_add_inline_script( 'test-example', 'console.log("before");', 'before' );
|
||||
wp_add_inline_script( 'test-example', 'console.log("after");' );
|
||||
|
||||
$expected = "<script type='text/javascript'>\nconsole.log(\"before\");\n</script>\n";
|
||||
$expected .= "<script type='text/javascript'>\nconsole.log(\"after\");\n</script>\n";
|
||||
|
||||
$this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 14853
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user