Changeset 60948 for trunk/tests/phpunit/tests/dependencies/scripts.php
- Timestamp:
- 10/16/2025 07:59:11 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/scripts.php
r60931 r60948 1960 1960 * Testing `wp_script_add_data` with the conditional key. 1961 1961 * 1962 * @expectedDeprecated WP_Dependencies->add_data() 1963 * 1964 * @since 6.9.0 Conditional comments should now return an empty string. 1965 * 1962 1966 * @ticket 16024 1963 1967 */ … … 1966 1970 wp_enqueue_script( 'test-only-conditional', 'example.com', array(), null ); 1967 1971 wp_script_add_data( 'test-only-conditional', 'conditional', 'gt IE 7' ); 1968 $expected = "<!--[if gt IE 7]>\n<script type=\"text/javascript\" src=\"http://example.com\" id=\"test-only-conditional-js\"></script>\n<![endif]-->\n";1969 1970 // Go!1971 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );1972 1973 // No scripts left to print.1974 $this->assertSame( '', get_echo( 'wp_print_scripts' ) );1975 }1976 1977 /**1978 * Testing `wp_script_add_data` with both the data & conditional keys.1979 *1980 * @ticket 160241981 */1982 public function test_wp_script_add_data_with_data_and_conditional_keys() {1983 // Enqueue and add data plus conditional comments for both.1984 wp_enqueue_script( 'test-conditional-with-data', 'example.com', array(), null );1985 wp_script_add_data( 'test-conditional-with-data', 'data', 'testing' );1986 wp_script_add_data( 'test-conditional-with-data', 'conditional', 'lt IE 9' );1987 $expected = "<!--[if lt IE 9]>\n<script type='text/javascript' id='test-conditional-with-data-js-extra'>\n/* <![CDATA[ */\ntesting\n//# sourceURL=test-conditional-with-data-js-extra\n/* ]]> */\n</script>\n<![endif]-->\n";1988 $expected .= "<!--[if lt IE 9]>\n<script type='text/javascript' src='http://example.com' id='test-conditional-with-data-js'></script>\n<![endif]-->\n";1989 $expected = str_replace( "'", '"', $expected );1990 1991 // Go!1992 $this->assertEqualHTML( $expected, get_echo( 'wp_print_scripts' ) );1993 1994 1972 // No scripts left to print. 1995 1973 $this->assertSame( '', get_echo( 'wp_print_scripts' ) ); … … 2404 2382 2405 2383 /** 2384 * @expectedDeprecated WP_Dependencies->add_data() 2385 * 2406 2386 * @ticket 14853 2387 * @ticket 63821 2407 2388 */ 2408 2389 public function test_wp_add_inline_script_after_and_before_with_concat_and_conditional() { … … 2412 2393 $wp_scripts->default_dirs = array( '/wp-admin/js/', '/wp-includes/js/' ); // Default dirs as in wp-includes/script-loader.php. 2413 2394 2414 $expected_localized = "<!--[if gte IE 9]>\n"; 2415 $expected_localized .= "<script type='text/javascript' id='test-example-js-extra'>\n/* <![CDATA[ */\nvar testExample = {\"foo\":\"bar\"};\n/* ]]> */\n</script>\n"; 2416 $expected_localized .= "<![endif]-->\n"; 2417 $expected_localized = str_replace( "'", '"', $expected_localized ); 2418 2419 $expected = "<!--[if gte IE 9]>\n"; 2420 $expected .= "<script type='text/javascript' id='test-example-js-before'>\n/* <![CDATA[ */\nconsole.log(\"before\");\n//# sourceURL=test-example-js-before\n/* ]]> */\n</script>\n"; 2421 $expected .= "<script type='text/javascript' src='http://example.com' id='test-example-js'></script>\n"; 2422 $expected .= "<script type='text/javascript' id='test-example-js-after'>\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n"; 2423 $expected .= "<![endif]-->\n"; 2424 $expected = str_replace( "'", '"', $expected ); 2395 // Conditional scripts should not output. 2396 $expected_localized = ''; 2397 $expected = ''; 2425 2398 2426 2399 wp_enqueue_script( 'test-example', 'example.com', array(), null ); … … 2460 2433 2461 2434 /** 2435 * @expectedDeprecated WP_Dependencies->add_data() 2436 * 2462 2437 * @ticket 36392 2438 * @ticket 63821 2463 2439 */ 2464 2440 public function test_wp_add_inline_script_after_with_concat_and_conditional_and_core_dependency() { 2465 global $wp_scripts, $wp_version; 2466 2441 global $wp_scripts; 2467 2442 wp_default_scripts( $wp_scripts ); 2468 2443 2469 2444 $wp_scripts->base_url = ''; 2470 2445 $wp_scripts->do_concat = true; 2471 2472 $expected = "<script type='text/javascript' src='/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate&ver={$wp_version}'></script>\n"; 2473 $expected .= "<!--[if gte IE 9]>\n"; 2474 $expected .= "<script type=\"text/javascript\" src=\"http://example.com\" id=\"test-example-js\"></script>\n"; 2475 $expected .= "<script type=\"text/javascript\" id=\"test-example-js-after\">\n/* <![CDATA[ */\nconsole.log(\"after\");\n//# sourceURL=test-example-js-after\n/* ]]> */\n</script>\n"; 2476 $expected .= "<![endif]-->\n"; 2446 $expected = ''; 2477 2447 2478 2448 wp_enqueue_script( 'test-example', 'http://example.com', array( 'jquery' ), null );
Note: See TracChangeset
for help on using the changeset viewer.