Go to the documentation of this file.
13 $server =
'http://doc.example.org';
16 'wgServer' => $server,
17 'wgCanonicalServer' => $server,
28 $this->assertEquals( $expectedOutput, $minified,
'Minified output should be in the form expected.' );
34 array(
"\r\t\f \v\n\r",
"" ),
35 array(
"foo, bar {\n\tprop: value;\n}",
"foo,bar{prop:value}" ),
38 array(
"/* foo */",
"" ),
39 array(
"/*******\n foo\n *******/",
"" ),
40 array(
"/*!\n foo\n */",
"" ),
43 array(
"/* comment */foo, bar {\n\tprop: value;\n}",
"foo,bar{prop:value}" ),
44 array(
"foo/* comment */, bar {\n\tprop: value;\n}",
"foo,bar{prop:value}" ),
45 array(
"foo,/* comment */ bar {\n\tprop: value;\n}",
"foo,bar{prop:value}" ),
46 array(
"foo, bar/* comment */ {\n\tprop: value;\n}",
"foo,bar{prop:value}" ),
47 array(
"foo, bar {\n\t/* comment */prop: value;\n}",
"foo,bar{prop:value}" ),
48 array(
"foo, bar {\n\tprop: /* comment */value;\n}",
"foo,bar{prop:value}" ),
49 array(
"foo, bar {\n\tprop: value /* comment */;\n}",
"foo,bar{prop:value }" ),
50 array(
"foo, bar {\n\tprop: value; /* comment */\n}",
"foo,bar{prop:value; }" ),
54 array(
'foo { prop: value ;}',
'foo{prop:value }' ),
55 array(
'foo { prop : value; }',
'foo{prop :value}' ),
56 array(
'foo { prop: value ; }',
'foo{prop:value }' ),
57 array(
'foo { font-family: "foo" , "bar"; }',
'foo{font-family:"foo" ,"bar"}' ),
58 array(
"foo { src:\n\turl('foo') ,\n\turl('bar') ; }",
"foo{src:url('foo') ,url('bar') }" ),
62 array(
'foo { content: ""; }',
'foo{content:""}' ),
63 array(
"foo { content: ''; }",
"foo{content:''}" ),
64 array(
'foo { content: "\'"; }',
'foo{content:"\'"}' ),
65 array(
"foo { content: '\"'; }",
"foo{content:'\"'}" ),
67 array(
'foo { content: " "; }',
'foo{content:" "}' ),
78 $remapped = call_user_func_array(
'CSSMin::remap',
$params );
80 $messageAdd =
" Case: $message";
81 $this->assertEquals( $expectedOutput, $remapped,
'CSSMin::remap should return the expected url form.' . $messageAdd );
90 array(
'foo { prop: url(bar.png); }',
false,
'http://example.org',
false ),
91 'foo { prop: url(http://example.org/bar.png); }',
94 'Without trailing slash',
95 array(
'foo { prop: url(../bar.png); }',
false,
'http://example.org/quux',
false ),
96 'foo { prop: url(http://example.org/quux/../bar.png); }',
99 'With trailing slash on remote (bug 27052)',
100 array(
'foo { prop: url(../bar.png); }',
false,
'http://example.org/quux/',
false ),
101 'foo { prop: url(http://example.org/quux/../bar.png); }',
104 'Guard against stripping double slashes from query',
105 array(
'foo { prop: url(bar.png?corge=//grault); }',
false,
'http://example.org/quux/',
false ),
106 'foo { prop: url(http://example.org/quux/bar.png?corge=//grault); }',
109 'Expand absolute paths',
110 array(
'foo { prop: url(/w/skin/images/bar.png); }',
false,
'http://example.org/quux',
false ),
111 'foo { prop: url(http://doc.example.org/w/skin/images/bar.png); }',
123 $localPath = __DIR__ .
'/../../data/cssmin/';
124 $remotePath =
'http://localhost/w/';
126 $realOutput =
CSSMin::remap( $input, $localPath, $remotePath );
130 preg_replace(
'/\d+-\d+-\d+T\d+:\d+:\d+Z/',
'timestamp', $realOutput ),
131 "CSSMin::remap: $message"
142 $red =
'data:image/gif;base64,R0lGODlhAQABAIAAAP8AADAAACwAAAAAAQABAAACAkQBADs=';
143 $green =
'data:image/gif;base64,R0lGODlhAQABAIAAAACAADAAACwAAAAAAQABAAACAkQBADs=';
148 'foo { background: url(red.gif); }',
149 'foo { background: url(http://localhost/w/red.gif?timestamp); }',
152 'Regular file (missing)',
153 'foo { background: url(theColorOfHerHair.gif); }',
154 'foo { background: url(http://localhost/w/theColorOfHerHair.gif); }',
158 'foo { background: url(http://example.org/w/foo.png); }',
159 'foo { background: url(http://example.org/w/foo.png); }',
162 'Protocol-relative remote URL',
163 'foo { background: url(//example.org/w/foo.png); }',
164 'foo { background: url(//example.org/w/foo.png); }',
167 'Remote URL with query',
168 'foo { background: url(http://example.org/w/foo.png?query=yes); }',
169 'foo { background: url(http://example.org/w/foo.png?query=yes); }',
172 'Protocol-relative remote URL with query',
173 'foo { background: url(//example.org/w/foo.png?query=yes); }',
174 'foo { background: url(//example.org/w/foo.png?query=yes); }',
177 'Domain-relative URL',
178 'foo { background: url(/static/foo.png); }',
179 'foo { background: url(http://doc.example.org/static/foo.png); }',
182 'Domain-relative URL with query',
183 'foo { background: url(/static/foo.png?query=yes); }',
184 'foo { background: url(http://doc.example.org/static/foo.png?query=yes); }',
187 'Remote URL (unnecessary quotes not preserved)',
188 'foo { background: url("http://example.org/w/foo.png"); }',
189 'foo { background: url(http://example.org/w/foo.png); }',
193 'foo { /* @embed */ background: url(red.gif); }',
194 "foo { background: url($red); background: url(http://localhost/w/red.gif?timestamp)!ie; }",
197 'Can not embed remote URLs',
198 'foo { /* @embed */ background: url(http://example.org/w/foo.png); }',
199 'foo { background: url(http://example.org/w/foo.png); }',
202 'Embedded file (inline @embed)',
203 'foo { background: /* @embed */ url(red.gif); }',
204 "foo { background: url($red); background: url(http://localhost/w/red.gif?timestamp)!ie; }",
207 'Can not embed large files',
208 'foo { /* @embed */ background: url(large.png); }',
209 "foo { background: url(http://localhost/w/large.png?timestamp); }",
212 'Two regular files in one rule',
213 'foo { background: url(red.gif), url(green.gif); }',
214 'foo { background: url(http://localhost/w/red.gif?timestamp), url(http://localhost/w/green.gif?timestamp); }',
217 'Two embedded files in one rule',
218 'foo { /* @embed */ background: url(red.gif), url(green.gif); }',
219 "foo { background: url($red), url($green); background: url(http://localhost/w/red.gif?timestamp), url(http://localhost/w/green.gif?timestamp)!ie; }",
222 'Two embedded files in one rule (inline @embed)',
223 'foo { background: /* @embed */ url(red.gif), /* @embed */ url(green.gif); }',
224 "foo { background: url($red), url($green); background: url(http://localhost/w/red.gif?timestamp), url(http://localhost/w/green.gif?timestamp)!ie; }",
227 'Two embedded files in one rule (inline @embed), one too large',
228 'foo { background: /* @embed */ url(red.gif), /* @embed */ url(large.png); }',
229 "foo { background: url($red), url(http://localhost/w/large.png?timestamp); background: url(http://localhost/w/red.gif?timestamp), url(http://localhost/w/large.png?timestamp)!ie; }",
232 'Practical example with some noise',
233 'foo { /* @embed */ background: #f9f9f9 url(red.gif) 0 0 no-repeat; }',
234 "foo { background: #f9f9f9 url($red) 0 0 no-repeat; background: #f9f9f9 url(http://localhost/w/red.gif?timestamp) 0 0 no-repeat!ie; }",
237 'Does not mess with other properties',
238 'foo { color: red; background: url(red.gif); font-size: small; }',
239 'foo { color: red; background: url(http://localhost/w/red.gif?timestamp); font-size: small; }',
242 'Spacing and miscellanea not changed (1)',
243 'foo { background: url(red.gif); }',
244 'foo { background: url(http://localhost/w/red.gif?timestamp); }',
247 'Spacing and miscellanea not changed (2)',
248 'foo {background:url(red.gif)}',
249 'foo {background:url(http://localhost/w/red.gif?timestamp)}',
252 'Spaces within url() parentheses are ignored',
253 'foo { background: url( red.gif ); }',
254 'foo { background: url(http://localhost/w/red.gif?timestamp); }',
257 '@import rule to local file (should we remap this?)',
258 '@import url(/styles.css)',
259 '@import url(http://doc.example.org/styles.css)',
262 '@import rule to URL (should we remap this?)',
263 '@import url(//localhost/styles.css?query=yes)',
264 '@import url(//localhost/styles.css?query=yes)',
279 "CSSMin::buildUrlValue: $message"
287 'scheme://user@domain:port/~user/fi%20le.png?query=yes&really=y+s',
288 'url(scheme://user@domain:port/~user/fi%20le.png?query=yes&really=y+s)',
292 'data:image/png;base64,R0lGODlh/+==',
293 'url(data:image/png;base64,R0lGODlh/+==)',
297 "https://en.wikipedia.org/wiki/Wendy's",
298 "url(\"https://en.wikipedia.org/wiki/Wendy's\")",
301 'URL with parentheses',
302 'https://en.wikipedia.org/wiki/Boston_(band)',
303 'url("https://en.wikipedia.org/wiki/Boston_(band)")',
316 $this->testMinifyOutput( $code, $expectedOutput );
323 array(
'foo { content: " "; }',
'foo{content:" "}' ),
325 array(
"foo { content: '\t'; }",
"foo{content:'\t'}" ),
327 array(
'foo::after { content: "{;}"; position: absolute; }',
'foo::after{content:"{;}";position:absolute}' ),
static buildUrlValue( $url)
Build a CSS 'url()' value for the given URL, quoting parentheses (and other funny characters) and esc...
static minify( $css)
Removes whitespace from CSS data.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static provideBuildUrlValueCases()
static remap( $source, $local, $remote, $embedData=true)
Remaps CSS URL paths and automatically embeds data URIs for CSS rules or url() values preceded by an ...
static provideMinifyCases()
This file test the CSSMin library shipped with Mediawiki.
testRemap( $message, $params, $expectedOutput)
This tests funky parameters to CSSMin::remap.
static provideStringCases()
static provideRemapCases()
testMinify( $code, $expectedOutput)
@dataProvider provideMinifyCases @covers CSSMin::minify
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
testBuildUrlValue( $message, $input, $expectedOutput)
This tests basic functionality of CSSMin::buildUrlValue.
testMinifyWithCSSStringValues( $code, $expectedOutput)
Seperated because they are currently broken (bug 35492)
testRemapRemapping( $message, $input, $expectedOutput)
This tests basic functionality of CSSMin::remap.
static provideRemapRemappingCases()