Changeset 61397 for trunk/tests/phpunit/tests/dependencies/styles.php
- Timestamp:
- 12/22/2025 12:54:50 AM (6 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/dependencies/styles.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/styles.php
r61392 r61397 56 56 * 57 57 * @ticket 11315 58 * @ticket 64372 58 59 */ 59 60 public function test_wp_enqueue_style() { 60 61 wp_enqueue_style( 'no-deps-no-version', 'example.com' ); 61 wp_enqueue_style( 'no-deps-version', 'example.com', array(), 1.2);62 wp_enqueue_style( 'no-deps-version', 'example.com', array(), '1.2' ); 62 63 wp_enqueue_style( 'no-deps-null-version', 'example.com', array(), null ); 63 64 wp_enqueue_style( 'no-deps-null-version-print-media', 'example.com', array(), null, 'print' ); 65 wp_enqueue_style( 'no-deps-arg-in-handle-with-ver?arg1=foo&arg2=bar', 'https://example.com/test.css', array(), '2.0' ); 66 wp_enqueue_style( 'no-deps-arg-in-handle-without-ver?arg1=foo&arg2=bar', 'https://example.com/test.css', array(), null ); 67 wp_register_style( 'registered-no-qs-handle-null-version-enqueued-with-qs', 'https://example.com/test.css' ); 68 wp_enqueue_style( 'registered-no-qs-handle-null-version-enqueued-with-qs?arg1=foo&arg2=bar' ); 64 69 65 70 $ver = get_bloginfo( 'version' ); … … 68 73 $expected .= "<link rel='stylesheet' id='no-deps-null-version-css' href='http://example.com' type='text/css' media='all' />\n"; 69 74 $expected .= "<link rel='stylesheet' id='no-deps-null-version-print-media-css' href='http://example.com' type='text/css' media='print' />\n"; 75 $expected .= "<link rel='stylesheet' id='no-deps-arg-in-handle-with-ver-css' href='https://example.com/test.css?ver=2.0&arg1=foo&arg2=bar' type='text/css' media='all' />\n"; 76 $expected .= "<link rel='stylesheet' id='no-deps-arg-in-handle-without-ver-css' href='https://example.com/test.css?arg1=foo&arg2=bar' type='text/css' media='all' />\n"; 77 $expected .= "<link rel='stylesheet' id='registered-no-qs-handle-null-version-enqueued-with-qs-css' href='https://example.com/test.css?ver={$ver}&arg1=foo&arg2=bar' type='text/css' media='all' />\n"; 70 78 71 79 $this->assertEqualHTML( $expected, get_echo( 'wp_print_styles' ) ); … … 845 853 ); 846 854 } 855 856 /** 857 * Test query string on handle when enqueuing styles directly. 858 * 859 * @ticket 64372 860 * 861 * @covers WP_Styles::do_item 862 * 863 * @dataProvider data_varying_versions_handle_args 864 * 865 * @param mixed $version Version to pass when enqueuing. 866 * @param string $expected_query_string Expected query string portion of the style sheet URL. 867 */ 868 public function test_varying_versions_added_to_handle_args_enqueued_styles( $version, $expected_query_string ) { 869 wp_enqueue_style( 'test-style?qs1=q1&qs2=q2', '/test-style.css', array(), $version ); 870 $markup = get_echo( 'wp_print_styles' ); 871 872 $expected = "<link rel='stylesheet' href='/test-style.css?{$expected_query_string}' id='test-style-css' type='text/css' media='all' />"; 873 $this->assertEqualHTML( $expected, $markup, '<body>', 'Expected equal snapshot for wp_print_styles() with version ' . var_export( $version, true ) . ":\n$markup" ); 874 } 875 876 /** 877 * Test query string on handle when registering then enqueuing styles. 878 * 879 * @ticket 64372 880 * 881 * @covers WP_Styles::do_item 882 * 883 * @dataProvider data_varying_versions_handle_args 884 * 885 * @param mixed $version Version to pass when enqueuing. 886 * @param string $expected_query_string Expected query string portion of the style sheet URL. 887 */ 888 public function test_varying_versions_added_to_handle_args_registered_then_enqueued_styles( $version, $expected_query_string ) { 889 wp_register_style( 'test-style', '/test-style.css', array(), $version ); 890 wp_enqueue_style( 'test-style?qs1=q1&qs2=q2' ); 891 $markup = get_echo( 'wp_print_styles' ); 892 893 $expected = "<link rel='stylesheet' href='/test-style.css?{$expected_query_string}' id='test-style-css' type='text/css' media='all' />"; 894 $this->assertEqualHTML( $expected, $markup, '<body>', 'Expected equal snapshot for wp_print_styles() with version ' . var_export( $version, true ) . ":\n$markup" ); 895 } 896 897 /** 898 * Data provider for: 899 * - test_varying_versions_added_to_handle_args_enqueued_styles 900 * - test_varying_versions_added_to_handle_args_registered_then_enqueued_styles 901 * 902 * @return array[] Data provider. 903 */ 904 public function data_varying_versions_handle_args() { 905 $default_version = get_bloginfo( 'version' ); 906 907 return array( 908 'string' => array( 909 '1.0.0', 910 'ver=1.0.0&qs1=q1&qs2=q2', 911 ), 912 'null' => array( 913 null, 914 'qs1=q1&qs2=q2', 915 ), 916 'false' => array( 917 false, 918 "ver={$default_version}&qs1=q1&qs2=q2", 919 ), 920 'empty-string' => array( 921 '', 922 "ver={$default_version}&qs1=q1&qs2=q2", 923 ), 924 'zero-string' => array( 925 '0', 926 "ver={$default_version}&qs1=q1&qs2=q2", 927 ), 928 'integer' => array( 929 123, 930 'ver=123&qs1=q1&qs2=q2', 931 ), 932 'zero-integer' => array( 933 0, 934 "ver={$default_version}&qs1=q1&qs2=q2", 935 ), 936 'float' => array( 937 1.23, 938 'ver=1.23&qs1=q1&qs2=q2', 939 ), 940 'zero-float' => array( 941 0.0, 942 "ver={$default_version}&qs1=q1&qs2=q2", 943 ), 944 ); 945 } 847 946 }
Note: See TracChangeset
for help on using the changeset viewer.