Changeset 25786 for trunk/tests/phpunit/tests/dependencies/styles.php
- Timestamp:
- 10/15/2013 02:34:33 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/dependencies/styles.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/styles.php
r25376 r25786 87 87 $wp_styles->base_url = $base_url_backup; 88 88 } 89 90 /** 91 * Test if inline styles work 92 * @ticket 24813 93 */ 94 public function test_inline_styles() { 95 96 $style = ".thing {\n"; 97 $style .= "\tbackground: red;\n"; 98 $style .= "}"; 99 100 $expected = "<link rel='stylesheet' id='handle-css' href='http://example.com?ver=1' type='text/css' media='all' />\n"; 101 $expected .= "<style type='text/css'>\n"; 102 $expected .= "$style\n"; 103 $expected .= "</style>\n"; 104 105 wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); 106 wp_add_inline_style( 'handle', $style ); 107 108 // No styles left to print 109 $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); 110 } 111 112 /** 113 * Test if inline styles work with concatination 114 * @global WP_Styles $wp_styles 115 * @ticket 24813 116 */ 117 public function test_inline_styles_concat() { 118 119 global $wp_styles; 120 121 $wp_styles->do_concat = true; 122 $wp_styles->default_dirs = array( '/wp-admin/', '/wp-includes/css/' ); // Default dirs as in wp-includes/script-loader.php 123 124 $style = ".thing {\n"; 125 $style .= "\tbackground: red;\n"; 126 $style .= "}"; 127 128 $expected = "<link rel='stylesheet' id='handle-css' href='http://example.com?ver=1' type='text/css' media='all' />\n"; 129 $expected .= "<style type='text/css'>\n"; 130 $expected .= "$style\n"; 131 $expected .= "</style>\n"; 132 133 wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); 134 wp_add_inline_style( 'handle', $style ); 135 136 wp_print_styles(); 137 $this->assertEquals( $expected, $wp_styles->print_html ); 138 139 } 140 141 /** 142 * Test if multiple inline styles work 143 * @ticket 24813 144 */ 145 public function test_multiple_inline_styles() { 146 147 $style1 = ".thing1 {\n"; 148 $style1 .= "\tbackground: red;\n"; 149 $style1 .= "}"; 150 151 $style2 = ".thing2 {\n"; 152 $style2 .= "\tbackground: blue;\n"; 153 $style2 .= "}"; 154 155 $expected = "<link rel='stylesheet' id='handle-css' href='http://example.com?ver=1' type='text/css' media='all' />\n"; 156 $expected .= "<style type='text/css'>\n"; 157 $expected .= "$style1\n"; 158 $expected .= "$style2\n"; 159 $expected .= "</style>\n"; 160 161 wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); 162 wp_add_inline_style( 'handle', $style1 ); 163 wp_add_inline_style( 'handle', $style2 ); 164 165 // No styles left to print 166 $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); 167 168 } 169 170 /** 171 * Test if a plugin doing it the wrong way still works 172 * 173 * @expectedIncorrectUsage wp_add_inline_style 174 * @ticket 24813 175 */ 176 public function test_plugin_doing_inline_styles_wrong() { 177 178 $style = "<style type='text/css'>\n"; 179 $style .= ".thing {\n"; 180 $style .= "\tbackground: red;\n"; 181 $style .= "}\n"; 182 $style .= "</style>"; 183 184 $expected = "<link rel='stylesheet' id='handle-css' href='http://example.com?ver=1' type='text/css' media='all' />\n"; 185 $expected .= "$style\n"; 186 187 wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); 188 189 wp_add_inline_style( 'handle', $style ); 190 191 $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); 192 193 } 194 195 /** 196 * Test to make sure <style> tags aren't output if there are no inline styles. 197 * @ticket 24813 198 */ 199 public function test_unnecessary_style_tags() { 200 201 $expected = "<link rel='stylesheet' id='handle-css' href='http://example.com?ver=1' type='text/css' media='all' />\n"; 202 203 wp_enqueue_style( 'handle', 'http://example.com', array(), 1 ); 204 205 $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); 206 207 } 208 89 209 }
Note: See TracChangeset
for help on using the changeset viewer.