| | 89 | |
| | 90 | /** |
| | 91 | * Test if inline styles work |
| | 92 | * @ticket 24813 |
| | 93 | */ |
| | 94 | public function test_inline_styles() { |
| | 95 | |
| | 96 | $expected = "<link rel='stylesheet' id='handle-css' href='http://example.com?ver=1' type='text/css' media='all' />\n"; |
| | 97 | $expected .= "<style type='text/css'>\n"; |
| | 98 | $expected .= "background: red\n"; |
| | 99 | $expected .= "</style>\n"; |
| | 100 | |
| | 101 | wp_enqueue_style( 'handle', 'example.com', array(), 1 ); |
| | 102 | wp_add_inline_style( 'handle', 'background: red' ); |
| | 103 | |
| | 104 | // No styles left to print |
| | 105 | $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); |
| | 106 | } |
| | 107 | |
| | 108 | /** |
| | 109 | * Test if inline styles work with concatination |
| | 110 | * @global WP_Styles $wp_styles |
| | 111 | * @ticket 24813 |
| | 112 | */ |
| | 113 | public function test_inline_styles_concat() { |
| | 114 | |
| | 115 | global $wp_styles; |
| | 116 | |
| | 117 | $wp_styles->do_concat = true; |
| | 118 | $wp_styles->default_dirs = array( '/wp-admin/', '/wp-includes/css/' ); // Default dirs as in wp-includes/script-loader.php |
| | 119 | |
| | 120 | wp_enqueue_style( 'handle', 'example.com', array(), 1 ); |
| | 121 | wp_add_inline_style( 'handle', 'background: red' ); |
| | 122 | |
| | 123 | $expected = "<link rel='stylesheet' id='handle-css' href='http://example.com?ver=1' type='text/css' media='all' />\n"; |
| | 124 | $expected .= "<style type='text/css'>\n"; |
| | 125 | $expected .= "background: red\n"; |
| | 126 | $expected .= "</style>\n"; |
| | 127 | |
| | 128 | wp_print_styles(); |
| | 129 | $this->assertEquals( $expected, $wp_styles->print_html ); |
| | 130 | |
| | 131 | } |
| | 132 | |
| | 133 | /** |
| | 134 | * Test if multiple inline styles work |
| | 135 | * @ticket 24813 |
| | 136 | */ |
| | 137 | public function test_multiple_inline_styles() { |
| | 138 | |
| | 139 | $expected = "<link rel='stylesheet' id='handle-css' href='http://example.com?ver=1' type='text/css' media='all' />\n"; |
| | 140 | $expected .= "<style type='text/css'>\n"; |
| | 141 | $expected .= "background: red\n"; |
| | 142 | $expected .= "background: green\n"; |
| | 143 | $expected .= "</style>\n"; |
| | 144 | |
| | 145 | wp_enqueue_style( 'handle', 'example.com', array(), 1 ); |
| | 146 | wp_add_inline_style( 'handle', 'background: red' ); |
| | 147 | wp_add_inline_style( 'handle', 'background: green' ); |
| | 148 | |
| | 149 | // No styles left to print |
| | 150 | $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) ); |
| | 151 | |
| | 152 | } |
| | 153 | |