| 1 |
<?php |
| 2 |
|
| 3 |
namespace MatthiasMullie\Minify\Test; |
| 4 |
|
| 5 |
use PHPUnit\Framework\TestCase; |
| 6 |
use ReflectionObject; |
| 7 |
|
| 8 |
/** |
| 9 |
* CSS minifier test case. |
| 10 |
*/ |
| 11 |
class CSSTest extends TestCase |
| 12 |
{ |
| 13 |
protected function mockMinifier() |
| 14 |
{ |
| 15 |
// override save method, there's no point in writing the result out here |
| 16 |
return $this->getMockBuilder('\MatthiasMullie\Minify\CSS') |
| 17 |
->setMethods(array('save')) |
| 18 |
->getMock(); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Test CSS minifier rules, provided by dataProvider. |
| 23 |
* |
| 24 |
* @dataProvider dataProvider |
| 25 |
*/ |
| 26 |
public function testMinify($input, $expected) |
| 27 |
{ |
| 28 |
$minifier = $this->mockMinifier(); |
| 29 |
$minifier->add($input); |
| 30 |
$result = $minifier->minify(); |
| 31 |
$this->assertEquals($expected, $result); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Test conversion of relative paths, provided by dataProviderPaths. |
| 36 |
* |
| 37 |
* @dataProvider dataProviderPaths |
| 38 |
*/ |
| 39 |
public function testConvertRelativePath($source, $target, $expected) |
| 40 |
{ |
| 41 |
$minifier = $this->mockMinifier(); |
| 42 |
$source = (array) $source; |
| 43 |
foreach ($source as $path => $css) { |
| 44 |
$minifier->add($css); |
| 45 |
|
| 46 |
// $source also accepts an array where the key is a bogus path |
| 47 |
if (is_string($path)) { |
| 48 |
$object = new ReflectionObject($minifier); |
| 49 |
$property = $object->getProperty('data'); |
| 50 |
$property->setAccessible(true); |
| 51 |
$data = $property->getValue($minifier); |
| 52 |
|
| 53 |
// keep content, but make it appear from the given path |
| 54 |
$data[$path] = array_pop($data); |
| 55 |
$property->setValue($minifier, $data); |
| 56 |
$property->setAccessible(false); |
| 57 |
} |
| 58 |
} |
| 59 |
|
| 60 |
$result = $minifier->minify($target); |
| 61 |
|
| 62 |
$this->assertEquals($expected, $result); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Test loop while importing file. |
| 67 |
*/ |
| 68 |
public function testFileImportLoop() |
| 69 |
{ |
| 70 |
$this->expectException('MatthiasMullie\Minify\Exceptions\FileImportException'); |
| 71 |
|
| 72 |
$testFile = __DIR__.'/sample/loop/first.css'; |
| 73 |
|
| 74 |
$minifier = $this->mockMinifier(); |
| 75 |
$minifier->add($testFile); |
| 76 |
|
| 77 |
$minifier->minify(); |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Test minifier import configuration methods. |
| 82 |
*/ |
| 83 |
public function testSetConfig() |
| 84 |
{ |
| 85 |
$minifier = $this->mockMinifier(); |
| 86 |
$minifier->setMaxImportSize(10); |
| 87 |
$minifier->setImportExtensions(array('gif' => 'data:image/gif')); |
| 88 |
|
| 89 |
$object = new ReflectionObject($minifier); |
| 90 |
|
| 91 |
$property = $object->getProperty('maxImportSize'); |
| 92 |
$property->setAccessible(true); |
| 93 |
$this->assertEquals($property->getValue($minifier), 10); |
| 94 |
|
| 95 |
$property = $object->getProperty('importExtensions'); |
| 96 |
$property->setAccessible(true); |
| 97 |
$this->assertEquals($property->getValue($minifier), array('gif' => 'data:image/gif')); |
| 98 |
} |
| 99 |
|
| 100 |
/** |
| 101 |
* @return array [input, expected result] |
| 102 |
*/ |
| 103 |
public function dataProvider() |
| 104 |
{ |
| 105 |
$tests = array(); |
| 106 |
|
| 107 |
// passing in an array of css inputs |
| 108 |
$tests[] = array( |
| 109 |
array( |
| 110 |
__DIR__.'/sample/combine_imports/index.css', |
| 111 |
__DIR__.'/sample/bom/bom.css', |
| 112 |
'p { width: 55px , margin: 0 0 0 0}', |
| 113 |
), |
| 114 |
'body{color:red}body{color:red}p{width:55px,margin:0 0 0 0}', |
| 115 |
); |
| 116 |
|
| 117 |
// try importing, with both @import syntax types & media queries |
| 118 |
$tests[] = array( |
| 119 |
__DIR__.'/sample/combine_imports/index.css', |
| 120 |
'body{color:red}', |
| 121 |
); |
| 122 |
$tests[] = array( |
| 123 |
__DIR__.'/sample/combine_imports/index2.css', |
| 124 |
'body{color:red}', |
| 125 |
); |
| 126 |
$tests[] = array( |
| 127 |
__DIR__.'/sample/combine_imports/index3.css', |
| 128 |
'body{color:red}body{color:red}', |
| 129 |
); |
| 130 |
$tests[] = array( |
| 131 |
__DIR__.'/sample/combine_imports/index4.css', |
| 132 |
'@media only screen{body{color:red}}@media only screen{body{color:red}}', |
| 133 |
); |
| 134 |
$tests[] = array( |
| 135 |
__DIR__.'/sample/combine_imports/index5.css', |
| 136 |
'body{color:red}body{color:red}', |
| 137 |
); |
| 138 |
$tests[] = array( |
| 139 |
__DIR__.'/sample/combine_imports/index6a.css', |
| 140 |
'body{color:red}', |
| 141 |
); |
| 142 |
|
| 143 |
// shorthand hex color codes |
| 144 |
$tests[] = array( |
| 145 |
'color:#FF00FF;', |
| 146 |
'color:#F0F;', |
| 147 |
); |
| 148 |
|
| 149 |
// import files |
| 150 |
$tests[] = array( |
| 151 |
__DIR__.'/sample/import_files/index.css', |
| 152 |
'body{background:url(data:image/png;base64,'.base64_encode(file_get_contents(__DIR__.'/sample/import_files/file.png')).')}', |
| 153 |
); |
| 154 |
|
| 155 |
// strip comments |
| 156 |
$tests[] = array( |
| 157 |
'/* This is a CSS comment */', |
| 158 |
'', |
| 159 |
); |
| 160 |
|
| 161 |
// preserve important comments |
| 162 |
$tests[] = array( |
| 163 |
'/*! This is a CSS comment */', |
| 164 |
'/*! This is a CSS comment */', |
| 165 |
); |
| 166 |
|
| 167 |
$tests[] = array( |
| 168 |
'/* @license copyright [email protected] */', |
| 169 |
'/* @license copyright [email protected] */', |
| 170 |
); |
| 171 |
|
| 172 |
$tests[] = array( |
| 173 |
'/* @preserve This is a CSS comment */', |
| 174 |
'/* @preserve This is a CSS comment */', |
| 175 |
); |
| 176 |
|
| 177 |
// strip whitespace |
| 178 |
$tests[] = array( |
| 179 |
'body { color: red; }', |
| 180 |
'body{color:red}', |
| 181 |
); |
| 182 |
|
| 183 |
// whitespace inside strings shouldn't be replaced |
| 184 |
$tests[] = array( |
| 185 |
'content:"preserve whitespace"', |
| 186 |
'content:"preserve whitespace"', |
| 187 |
); |
| 188 |
|
| 189 |
$tests[] = array( |
| 190 |
'html |
| 191 |
body { |
| 192 |
color: red; |
| 193 |
}', |
| 194 |
'html body{color:red}', |
| 195 |
); |
| 196 |
|
| 197 |
$tests[] = array( |
| 198 |
<<<'JS' |
| 199 |
p * i , html |
| 200 |
/* remove spaces */ |
| 201 |
|
| 202 |
/* " comments have no escapes \*/ |
| 203 |
body/* keep */ /* space */p, |
| 204 |
p [ remove ~= " spaces " ] :nth-child( 3 + 2n ) > b span i , div::after |
| 205 |
|
| 206 |
{ |
| 207 |
/* comment */ |
| 208 |
content : " escapes \" allowed \\" ; |
| 209 |
content: " /* string */ " !important ; |
| 210 |
width: calc( 100% - 3em + 5px ) ; |
| 211 |
margin-top : 0; |
| 212 |
margin-bottom : 0; |
| 213 |
margin-left : 10px; |
| 214 |
margin-right : 10px; |
| 215 |
} |
| 216 |
JS |
| 217 |
, |
| 218 |
'p * i,html body p,p [remove~=" spaces "] :nth-child(3+2n)>b span i,div::after{content:" escapes \\" allowed \\\\";content:" /* string */ "!important;width:calc(100% - 3em + 5px);margin-top:0;margin-bottom:0;margin-left:10px;margin-right:10px}', |
| 219 |
); |
| 220 |
|
| 221 |
/* |
| 222 |
* https://github.com/forkcms/forkcms/issues/387 |
| 223 |
* |
| 224 |
* CSS backslash. |
| 225 |
* * Backslash escaped by backslash in CSS |
| 226 |
* * Double CSS backslashed escaped twice for in PHP string |
| 227 |
*/ |
| 228 |
$tests[] = array( |
| 229 |
'.iconic.map-pin:before { content: "\\\\"; }', |
| 230 |
'.iconic.map-pin:before{content:"\\\\"}', |
| 231 |
); |
| 232 |
|
| 233 |
// strip BOM |
| 234 |
$tests[] = array( |
| 235 |
__DIR__.'/sample/bom/bom.css', |
| 236 |
'body{color:red}', |
| 237 |
); |
| 238 |
|
| 239 |
// https://github.com/matthiasmullie/minify/issues/22 |
| 240 |
$tests[] = array( |
| 241 |
'p { background-position: -0px -64px; }', |
| 242 |
'p{background-position:0 -64px}', |
| 243 |
); |
| 244 |
|
| 245 |
// https://github.com/matthiasmullie/minify/issues/23 |
| 246 |
$tests[] = array( |
| 247 |
'ul.pagination { |
| 248 |
display: block; |
| 249 |
min-height: 1.5rem; |
| 250 |
margin-left: -0.3125rem; |
| 251 |
}', |
| 252 |
'ul.pagination{display:block;min-height:1.5rem;margin-left:-.3125rem}', |
| 253 |
); |
| 254 |
|
| 255 |
// edge cases for stripping zeroes |
| 256 |
$tests[] = array( |
| 257 |
'p { margin: -0.0rem; }', |
| 258 |
'p{margin:0rem}', |
| 259 |
); |
| 260 |
$tests[] = array( |
| 261 |
'p { margin: -0.01rem; }', |
| 262 |
'p{margin:-.01rem}', |
| 263 |
); |
| 264 |
$tests[] = array( |
| 265 |
'p { margin: .0; }', |
| 266 |
'p{margin:0}', |
| 267 |
); |
| 268 |
$tests[] = array( |
| 269 |
'p { margin: .0%; }', |
| 270 |
'p{margin:0%}', |
| 271 |
); |
| 272 |
$tests[] = array( |
| 273 |
'p { margin: 1.0; }', |
| 274 |
'p{margin:1}', |
| 275 |
); |
| 276 |
$tests[] = array( |
| 277 |
'p { margin: 1.0px; }', |
| 278 |
'p{margin:1px}', |
| 279 |
); |
| 280 |
$tests[] = array( |
| 281 |
'p { margin: 1.1; }', |
| 282 |
'p{margin:1.1}', |
| 283 |
); |
| 284 |
$tests[] = array( |
| 285 |
'p { margin: 1.1em; }', |
| 286 |
'p{margin:1.1em}', |
| 287 |
); |
| 288 |
$tests[] = array( |
| 289 |
'p { margin: 00px; }', |
| 290 |
'p{margin:0}', |
| 291 |
); |
| 292 |
$tests[] = array( |
| 293 |
'p { margin: 0.1px; }', |
| 294 |
'p{margin:.1px}', |
| 295 |
); |
| 296 |
$tests[] = array( |
| 297 |
'p { margin: 01.1px; }', |
| 298 |
'p{margin:1.1px}', |
| 299 |
); |
| 300 |
$tests[] = array( |
| 301 |
'p { margin: 0.060px; }', |
| 302 |
'p{margin:.06px}', |
| 303 |
); |
| 304 |
$tests[] = array( |
| 305 |
'p.class00 { background-color: #000000; color: #000; }', |
| 306 |
'p.class00{background-color:#000;color:#000}', |
| 307 |
); |
| 308 |
|
| 309 |
// https://github.com/matthiasmullie/minify/issues/24 |
| 310 |
$tests[] = array( |
| 311 |
'.col-1-1 { width: 100.00%; }', |
| 312 |
'.col-1-1{width:100%}', |
| 313 |
); |
| 314 |
|
| 315 |
// https://github.com/matthiasmullie/minify/issues/25 |
| 316 |
$tests[] = array( |
| 317 |
'p { background-color: #000000; color: #000; }', |
| 318 |
'p{background-color:#000;color:#000}', |
| 319 |
); |
| 320 |
|
| 321 |
// https://github.com/matthiasmullie/minify/issues/26 |
| 322 |
$tests[] = array( |
| 323 |
'.hr > :first-child { width: 0.0001%; }', |
| 324 |
'.hr>:first-child{width:.0001%}', |
| 325 |
); |
| 326 |
|
| 327 |
// https://github.com/matthiasmullie/minify/issues/28 |
| 328 |
$tests[] = array( |
| 329 |
'@font-face { src: url(//netdna.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.eot?v=4.2.0); }', |
| 330 |
'@font-face{src:url(//netdna.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.eot?v=4.2.0)}', |
| 331 |
); |
| 332 |
|
| 333 |
// https://github.com/matthiasmullie/minify/issues/31 |
| 334 |
$tests[] = array( |
| 335 |
'dfn,em,img{color:red}', |
| 336 |
'dfn,em,img{color:red}', |
| 337 |
); |
| 338 |
|
| 339 |
// https://github.com/matthiasmullie/minify/issues/49 |
| 340 |
$tests[] = array( |
| 341 |
__DIR__.'/sample/import_files/issue49.css', |
| 342 |
'.social-btn a[href*="facebook"]{background-image:url(data:image/png;base64,'.base64_encode(file_get_contents(__DIR__.'/sample/import_files/facebook.png')).')}'. |
| 343 |
'.social-btn a[href*="vimeo"]{background-image:url(data:image/png;base64,'.base64_encode(file_get_contents(__DIR__.'/sample/import_files/vimeo.png')).')}'. |
| 344 |
'.social-btn a[href*="instagram"]{background-image:url(data:image/png;base64,'.base64_encode(file_get_contents(__DIR__.'/sample/import_files/instagram.png')).')}', |
| 345 |
); |
| 346 |
|
| 347 |
// https://github.com/matthiasmullie/minify/issues/68 |
| 348 |
$tests[] = array( |
| 349 |
__DIR__.'/sample/external_imports/issue68.css', |
| 350 |
'@import url(http://localhost/file.css);body{background:green}', |
| 351 |
); |
| 352 |
|
| 353 |
// https://github.com/matthiasmullie/minify/issues/67 |
| 354 |
$tests[] = array( |
| 355 |
'body { } |
| 356 |
p { color: #fff; }', |
| 357 |
'p{color:#fff}', |
| 358 |
); |
| 359 |
$tests[] = array( |
| 360 |
'body {} |
| 361 |
p { color: #fff; } |
| 362 |
h1 { } |
| 363 |
strong { color: red; }', |
| 364 |
'p{color:#fff}strong{color:red}', |
| 365 |
); |
| 366 |
|
| 367 |
// https://github.com/matthiasmullie/minify/issues/74 |
| 368 |
$tests[] = array( |
| 369 |
"@media only screen and (-webkit-min-device-pixel-ratio: 1.5), |
| 370 |
only screen and (min--moz-device-pixel-ratio: 1.5), |
| 371 |
only screen and (min-device-pixel-ratio: 1.5) { |
| 372 |
|
| 373 |
#fancybox-loading,.fancybox-close,.fancybox-prev span,.fancybox-next span { |
| 374 |
background-image: url('/path/to/image.png'); |
| 375 |
background-size: 44px 152px; |
| 376 |
} |
| 377 |
|
| 378 |
#fancybox-loading div { |
| 379 |
background-image: url('/path/to/image.gif'); |
| 380 |
background-size: 24px 24px; |
| 381 |
} |
| 382 |
}", |
| 383 |
'@media only screen and (-webkit-min-device-pixel-ratio:1.5),only screen and (min--moz-device-pixel-ratio:1.5),only screen and (min-device-pixel-ratio:1.5){#fancybox-loading,.fancybox-close,.fancybox-prev span,.fancybox-next span{background-image:url(/path/to/image.png);background-size:44px 152px}#fancybox-loading div{background-image:url(/path/to/image.gif);background-size:24px 24px}}', |
| 384 |
); |
| 385 |
|
| 386 |
// https://github.com/matthiasmullie/minify/issues/92 |
| 387 |
$tests[] = array( |
| 388 |
'@media (min-width:320px) { |
| 389 |
/* smartphones, iPhone, portrait 480x320 phones */ |
| 390 |
p { |
| 391 |
background-color: red; |
| 392 |
} |
| 393 |
} |
| 394 |
@media (min-width:1025px) { |
| 395 |
/* big landscape tablets, laptops, and desktops */ |
| 396 |
/* LEFT EMPTY OF ANY SELECTORS */ |
| 397 |
} |
| 398 |
@media (min-width:1281px) { |
| 399 |
/* hi-res laptops and desktops */ |
| 400 |
p { |
| 401 |
background-color: blue; |
| 402 |
} |
| 403 |
}', |
| 404 |
'@media (min-width:320px){p{background-color:red}}@media (min-width:1281px){p{background-color:blue}}', |
| 405 |
); |
| 406 |
|
| 407 |
// https://github.com/matthiasmullie/minify/issues/103 |
| 408 |
$tests[] = array( |
| 409 |
'background:url(http://example.com/test.png);', |
| 410 |
'background:url(http://example.com/test.png);', |
| 411 |
); |
| 412 |
|
| 413 |
// https://github.com/matthiasmullie/minify/issues/104 |
| 414 |
$tests[] = array( |
| 415 |
'@media screen and (min-aspect-ratio: 16/9) { p { color: red } }', |
| 416 |
'@media screen and (min-aspect-ratio:16/9){p{color:red}}', |
| 417 |
); |
| 418 |
|
| 419 |
// https://github.com/matthiasmullie/minify/issues/107 |
| 420 |
$tests[] = array( |
| 421 |
'@import "https://font.googleapis.com/css?family=RobotoDraft:regular&lang=en";', |
| 422 |
'@import "https://font.googleapis.com/css?family=RobotoDraft:regular&lang=en";', |
| 423 |
); |
| 424 |
$tests[] = array( |
| 425 |
'@import "https://font.googleapis.com/css?family=RobotoDraft:regular&lang=en";', |
| 426 |
'@import "https://font.googleapis.com/css?family=RobotoDraft:regular&lang=en";', |
| 427 |
); |
| 428 |
|
| 429 |
// https://github.com/matthiasmullie/minify/issues/109 |
| 430 |
$tests[] = array( |
| 431 |
'p{font-weight:bold;}', |
| 432 |
'p{font-weight:700}', |
| 433 |
); |
| 434 |
$tests[] = array( |
| 435 |
'p { |
| 436 |
font-weight : normal |
| 437 |
}', |
| 438 |
'p{font-weight:400}', |
| 439 |
); |
| 440 |
$tests[] = array( |
| 441 |
'p{background-color:#ff0000}', |
| 442 |
'p{background-color:red}', |
| 443 |
); |
| 444 |
$tests[] = array( |
| 445 |
'p{color:#F0E68C}', |
| 446 |
'p{color:khaki}', |
| 447 |
); |
| 448 |
|
| 449 |
// https://github.com/matthiasmullie/minify/issues/137 |
| 450 |
$tests[] = array( |
| 451 |
'p{width: calc(35% - 0px);}', |
| 452 |
'p{width:calc(35% - 0px)}', |
| 453 |
); |
| 454 |
$tests[] = array( |
| 455 |
'p{width: calc(0px + 35%);}', |
| 456 |
'p{width:calc(0px + 35%)}', |
| 457 |
); |
| 458 |
$tests[] = array( |
| 459 |
'p{width: calc(0px - 35%);}', |
| 460 |
'p{width:calc(0px - 35%)}', |
| 461 |
); |
| 462 |
$tests[] = array( |
| 463 |
'p{width: calc(0px + 35% - 0px);}', |
| 464 |
'p{width:calc(0px + 35% - 0px)}', |
| 465 |
); |
| 466 |
$tests[] = array( |
| 467 |
'p{width: calc(5% + 0px + 35% - 0px + 5%);}', |
| 468 |
'p{width:calc(5% + 0px + 35% - 0px + 5%)}', |
| 469 |
); |
| 470 |
$tests[] = array( |
| 471 |
'p{width:calc(35% + (10% + 0px))}', |
| 472 |
'p{width:calc(35% + (10% + 0px))}', |
| 473 |
); |
| 474 |
$tests[] = array( |
| 475 |
'p{width:calc(35% + (10% + 0px + 10%))}', |
| 476 |
'p{width:calc(35% + (10% + 0px + 10%))}', |
| 477 |
); |
| 478 |
|
| 479 |
// https://github.com/matthiasmullie/minify/issues/274 |
| 480 |
$tests[] = array( |
| 481 |
'.cvp-live-filter select { |
| 482 |
background-position: |
| 483 |
calc(100% - 20px) calc(1em + 2px), |
| 484 |
calc(100% - 15px) calc(1em + 2px), |
| 485 |
calc(100% - 2.5em) 0.5em; |
| 486 |
}', |
| 487 |
'.cvp-live-filter select{background-position:calc(100% - 20px) calc(1em + 2px),calc(100% - 15px) calc(1em + 2px),calc(100% - 2.5em) .5em}', |
| 488 |
); |
| 489 |
|
| 490 |
// https://github.com/matthiasmullie/minify/issues/301 |
| 491 |
$tests[] = array( |
| 492 |
'.e-gallery-masonry .e-gallery-item{--percent-height: 0;position:absolute;width:calc(100% / var(--columns) - (var(--hgap) * (var(--columns) - 1) / var(--columns)));left:calc((100% / var(--columns) - (var(--hgap) * (var(--columns) - 1) / var(--columns))) * var(--column) + (var(--hgap) * var(--column)));top:calc(var(--percent-height) + (var(--row) * var(--vgap)))}.e-gallery-masonry .e-gallery-image{padding-bottom:var(--item-height)}', |
| 493 |
'.e-gallery-masonry .e-gallery-item{--percent-height:0;position:absolute;width:calc(100% / var(--columns) - (var(--hgap) * (var(--columns) - 1) / var(--columns)));left:calc((100% / var(--columns) - (var(--hgap) * (var(--columns) - 1) / var(--columns))) * var(--column) + (var(--hgap) * var(--column)));top:calc(var(--percent-height) + (var(--row) * var(--vgap)))}.e-gallery-masonry .e-gallery-image{padding-bottom:var(--item-height)}', |
| 494 |
); |
| 495 |
|
| 496 |
// https://github.com/matthiasmullie/minify/issues/139 |
| 497 |
$tests[] = array( |
| 498 |
__DIR__.'/sample/line_endings/lf/parent.css', |
| 499 |
'p{color:green}body{color:red}', |
| 500 |
); |
| 501 |
$tests[] = array( |
| 502 |
__DIR__.'/sample/line_endings/cr/parent.css', |
| 503 |
'p{color:green}body{color:red}', |
| 504 |
); |
| 505 |
$tests[] = array( |
| 506 |
__DIR__.'/sample/line_endings/crlf/parent.css', |
| 507 |
'p{color:green}body{color:red}', |
| 508 |
); |
| 509 |
|
| 510 |
// https://github.com/matthiasmullie/minify/issues/145 |
| 511 |
$tests[] = array( |
| 512 |
'/* some imports */ |
| 513 |
@import \'./css1.css\'; |
| 514 |
@import url(\'https://www.google.com/main.css\'); |
| 515 |
|
| 516 |
.empty-rule{ |
| 517 |
} |
| 518 |
|
| 519 |
body{ |
| 520 |
background: white; |
| 521 |
}', |
| 522 |
'@import "./css1.css";@import url(https://www.google.com/main.css);body{background:#fff}', |
| 523 |
); |
| 524 |
|
| 525 |
// https://github.com/matthiasmullie/minify/commit/3253a81d07cd01afcb651e309900d8ad58a052da#commitcomment-19223603 |
| 526 |
$tests[] = array( |
| 527 |
'p{border: 1px solid #f00000;}', |
| 528 |
'p{border:1px solid #f00000}', |
| 529 |
); |
| 530 |
|
| 531 |
// https://github.com/matthiasmullie/minify/issues/149 |
| 532 |
$tests[] = array( |
| 533 |
".headerWrapper{ |
| 534 |
background:url(/_media/images/general/bg_top_right.png) no-repeat; |
| 535 |
background:url('') no-repeat; |
| 536 |
background-position:100% 0; |
| 537 |
width:100%; |
| 538 |
min-height: 0; |
| 539 |
}", |
| 540 |
".headerWrapper{background:url(/_media/images/general/bg_top_right.png) no-repeat;background:url('') no-repeat;background-position:100% 0;width:100%;min-height:0}", |
| 541 |
); |
| 542 |
$tests[] = array( |
| 543 |
".headerWrapper{ |
| 544 |
/*background:url(/_media/images/general/bg_top_right.png) no-repeat;*/ |
| 545 |
background:url('') no-repeat; |
| 546 |
background-position:100% 0; |
| 547 |
width:100%; |
| 548 |
min-height: 0; |
| 549 |
}", |
| 550 |
".headerWrapper{background:url('') no-repeat;background-position:100% 0;width:100%;min-height:0}", |
| 551 |
); |
| 552 |
|
| 553 |
// https://github.com/matthiasmullie/minify/issues/150 |
| 554 |
$tests[] = array( |
| 555 |
'.text { box-shadow: 0 0 1em -0.5em #000; }', |
| 556 |
'.text{box-shadow:0 0 1em -.5em #000}', |
| 557 |
); |
| 558 |
|
| 559 |
// https://github.com/matthiasmullie/minify/issues/159 |
| 560 |
$tests[] = array( |
| 561 |
'.columns { |
| 562 |
-webkit-flex: 1 1 0px; |
| 563 |
-ms-flex: 1 1 0px; |
| 564 |
flex: 1 1 0px; |
| 565 |
min-width: 0; |
| 566 |
}', |
| 567 |
'.columns{-webkit-flex:1 1 0%;-ms-flex:1 1 0%;flex:1 1 0%;min-width:0}', |
| 568 |
); |
| 569 |
$tests[] = array( |
| 570 |
'html{height:100%;font-family:sans-serif}.grid{max-width:60em;display:-webkit-box;display:-ms-flexbox;display:flex;margin:0 auto;-ms-flex-wrap:wrap;flex-wrap:wrap}.column{margin:.5em;-webkit-box-flex:1;-ms-flex:1 1 0px;flex:1 1 0px;border:1px solid #333;height:1em;padding:1em;text-align:center;color:#333}', |
| 571 |
'html{height:100%;font-family:sans-serif}.grid{max-width:60em;display:-webkit-box;display:-ms-flexbox;display:flex;margin:0 auto;-ms-flex-wrap:wrap;flex-wrap:wrap}.column{margin:.5em;-webkit-box-flex:1;-ms-flex:1 1 0%;flex:1 1 0%;border:1px solid #333;height:1em;padding:1em;text-align:center;color:#333}', |
| 572 |
); |
| 573 |
$tests[] = array( |
| 574 |
'p{flex:1 1 0;-ms-flex-basis:0%;}', |
| 575 |
'p{flex:1 1 0%;-ms-flex-basis:0%}', |
| 576 |
); |
| 577 |
|
| 578 |
// https://github.com/matthiasmullie/minify/issues/162 |
| 579 |
$tests[] = array( |
| 580 |
"p{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23007aff'%2F%3E%3C%2Fsvg%3E\")}", |
| 581 |
"p{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M0%2C22L22%2C0l2.1%2C2.1L4.2%2C22l19.9%2C19.9L22%2C44L0%2C22L0%2C22L0%2C22z'%20fill%3D'%23007aff'%2F%3E%3C%2Fsvg%3E\")}", |
| 582 |
); |
| 583 |
$tests[] = array( |
| 584 |
"p{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%236c6c6c'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(60%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(90%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(120%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(150%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.37'%20transform%3D'rotate(180%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.46'%20transform%3D'rotate(210%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.56'%20transform%3D'rotate(240%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.66'%20transform%3D'rotate(270%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.75'%20transform%3D'rotate(300%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.85'%20transform%3D'rotate(330%2060%2C60)'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E\")}", |
| 585 |
"p{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D'0%200%20120%20120'%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20xmlns%3Axlink%3D'http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink'%3E%3Cdefs%3E%3Cline%20id%3D'l'%20x1%3D'60'%20x2%3D'60'%20y1%3D'7'%20y2%3D'27'%20stroke%3D'%236c6c6c'%20stroke-width%3D'11'%20stroke-linecap%3D'round'%2F%3E%3C%2Fdefs%3E%3Cg%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(30%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(60%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(90%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(120%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.27'%20transform%3D'rotate(150%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.37'%20transform%3D'rotate(180%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.46'%20transform%3D'rotate(210%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.56'%20transform%3D'rotate(240%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.66'%20transform%3D'rotate(270%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.75'%20transform%3D'rotate(300%2060%2C60)'%2F%3E%3Cuse%20xlink%3Ahref%3D'%23l'%20opacity%3D'.85'%20transform%3D'rotate(330%2060%2C60)'%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E\")}", |
| 586 |
); |
| 587 |
$tests[] = array( |
| 588 |
'p{background-image:url(\'data:image/svg+xml;utf8,<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="100.000000pt" height="100.000000pt" viewBox="0 0 100.000000 100.000000" preserveAspectRatio="xMidYMid meet"><g transform="translate(0.000000,100.000000) scale(0.100000,-0.100000)" fill="#888888" stroke="none"><path d="M407 993 c-41 -5 -43 -6 -52 -73 -5 -44 -8 -47 -64 -74 l-59 -28 -50 18 c-49 18 -51 18 -71 0 -12 -11 -21 -24 -21 -31 0 -7 -12 -25 -26 -40 -15 -16 -35 -54 -46 -84 -21 -63 -25 -53 47 -104 22 -16 25 -25 25 -82 0 -60 -2 -66 -27 -80 -66 -35 -66 -36 -40 -107 13 -35 32 -74 43 -85 10 -12 27 -33 37 -47 21 -30 38 -32 97 -11 39 14 44 14 69 -4 15 -11 39 -23 54 -26 22 -6 27 -14 32 -53 9 -68 10 -69 52 -75 46 -8 157 -7 198 2 27 5 31 11 40 60 10 49 14 56 45 69 19 8 42 20 51 28 14 13 22 13 60 0 67 -24 81 -21 109 24 14 22 28 40 31 40 7 0 59 123 59 139 0 5 -20 22 -43 37 l-44 27 1 62 c1 61 15 95 41 95 6 0 20 9 30 20 17 19 17 22 -5 79 -12 33 -31 70 -41 83 -11 13 -30 37 -43 53 l-24 30 -51 -18 -51 -18 -59 27 -59 27 -9 56 -8 56 -45 7 c-48 7 -120 7 -183 1z m201 -325 c112 -69 129 -225 33 -311 -78 -70 -195 -75 -271 -10 -119 99 -78 298 70 342 47 14 128 4 168 -21z"/></g></svg>\')}', |
| 589 |
'p{background-image:url(\'data:image/svg+xml;utf8,<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="100.000000pt" height="100.000000pt" viewBox="0 0 100.000000 100.000000" preserveAspectRatio="xMidYMid meet"><g transform="translate(0.000000,100.000000) scale(0.100000,-0.100000)" fill="#888888" stroke="none"><path d="M407 993 c-41 -5 -43 -6 -52 -73 -5 -44 -8 -47 -64 -74 l-59 -28 -50 18 c-49 18 -51 18 -71 0 -12 -11 -21 -24 -21 -31 0 -7 -12 -25 -26 -40 -15 -16 -35 -54 -46 -84 -21 -63 -25 -53 47 -104 22 -16 25 -25 25 -82 0 -60 -2 -66 -27 -80 -66 -35 -66 -36 -40 -107 13 -35 32 -74 43 -85 10 -12 27 -33 37 -47 21 -30 38 -32 97 -11 39 14 44 14 69 -4 15 -11 39 -23 54 -26 22 -6 27 -14 32 -53 9 -68 10 -69 52 -75 46 -8 157 -7 198 2 27 5 31 11 40 60 10 49 14 56 45 69 19 8 42 20 51 28 14 13 22 13 60 0 67 -24 81 -21 109 24 14 22 28 40 31 40 7 0 59 123 59 139 0 5 -20 22 -43 37 l-44 27 1 62 c1 61 15 95 41 95 6 0 20 9 30 20 17 19 17 22 -5 79 -12 33 -31 70 -41 83 -11 13 -30 37 -43 53 l-24 30 -51 -18 -51 -18 -59 27 -59 27 -9 56 -8 56 -45 7 c-48 7 -120 7 -183 1z m201 -325 c112 -69 129 -225 33 -311 -78 -70 -195 -75 -271 -10 -119 99 -78 298 70 342 47 14 128 4 168 -21z"/></g></svg>\')}', |
| 590 |
); |
| 591 |
$tests[] = array( |
| 592 |
'p{background-image:url(\'data:image/svg+xml;utf8,<svg version="1.1" id="svg16357" xmlns:svg="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve"><path id="path3525" d="M16.992,10c0,3.861-3.131,6.992-6.992,6.992S3.008,13.861,3.008,10S6.139,3.008,10,3.008 S16.992,6.139,16.992,10z"/></svg>\')}', |
| 593 |
'p{background-image:url(\'data:image/svg+xml;utf8,<svg version="1.1" id="svg16357" xmlns:svg="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve"><path id="path3525" d="M16.992,10c0,3.861-3.131,6.992-6.992,6.992S3.008,13.861,3.008,10S6.139,3.008,10,3.008 S16.992,6.139,16.992,10z"/></svg>\')}', |
| 594 |
); |
| 595 |
|
| 596 |
// https://github.com/matthiasmullie/minify/issues/165 |
| 597 |
$tests[] = array( |
| 598 |
"p{src:url('../../font/archivo_narrow_regular.eot?#iefix') format('embedded-opentype')}", |
| 599 |
"p{src:url('../../font/archivo_narrow_regular.eot?#iefix') format('embedded-opentype')}", |
| 600 |
); |
| 601 |
$tests[] = array( |
| 602 |
"p{src:url('../../font/archivo_narrow_regular.svg#archivo narrow') format('svg')}", |
| 603 |
"p{src:url('../../font/archivo_narrow_regular.svg#archivo narrow') format('svg')}", |
| 604 |
); |
| 605 |
|
| 606 |
// https://github.com/matthiasmullie/minify/issues/183 |
| 607 |
$tests[] = array( |
| 608 |
".mce-container, |
| 609 |
.mce-container *, |
| 610 |
.mce-widget, |
| 611 |
.mce-widget *, |
| 612 |
.mce-reset { |
| 613 |
color: red; |
| 614 |
}", |
| 615 |
".mce-container,.mce-container *,.mce-widget,.mce-widget *,.mce-reset{color:red}", |
| 616 |
); |
| 617 |
|
| 618 |
// https://github.com/matthiasmullie/minify/issues/184 |
| 619 |
$tests[] = array( |
| 620 |
".soliloquy-container, .soliloquy-container * {color:red}", |
| 621 |
".soliloquy-container,.soliloquy-container *{color:red}", |
| 622 |
); |
| 623 |
$tests[] = array( |
| 624 |
"p{background: transparent url(images/preloader.gif) no-repeat scroll 50% 50%;}", |
| 625 |
"p{background:transparent url(images/preloader.gif) no-repeat scroll 50% 50%}", |
| 626 |
); |
| 627 |
|
| 628 |
// https://github.com/matthiasmullie/minify/issues/191 |
| 629 |
$tests[] = array( |
| 630 |
"some .weird- selector{display:none}", |
| 631 |
"some .weird- selector{display:none}", |
| 632 |
); |
| 633 |
$tests[] = array( |
| 634 |
"p:nth-child( - n + 3 ){display:none}", |
| 635 |
"p:nth-child(-n+3){display:none}", |
| 636 |
); |
| 637 |
$tests[] = array( |
| 638 |
"p:nth-child( + 3 ){display:none}", |
| 639 |
"p:nth-child(+3){display:none}", |
| 640 |
); |
| 641 |
$tests[] = array( |
| 642 |
"p:nth-child( n + 3 ){display:none}", |
| 643 |
"p:nth-child(n+3){display:none}", |
| 644 |
); |
| 645 |
$tests[] = array( |
| 646 |
"p:nth-child( odd ){display:none}", |
| 647 |
"p:nth-child(odd){display:none}", |
| 648 |
); |
| 649 |
$tests[] = array( |
| 650 |
"p:nth-child( n ){display:none}", |
| 651 |
"p:nth-child(n){display:none}", |
| 652 |
); |
| 653 |
$tests[] = array( |
| 654 |
"p:nth-child( -n ){display:none}", |
| 655 |
"p:nth-child(-n){display:none}", |
| 656 |
); |
| 657 |
|
| 658 |
// https://github.com/matthiasmullie/minify/issues/193 |
| 659 |
$tests[] = array( |
| 660 |
".swiper-button-prev{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23fff'%2F%3E%3C%2Fsvg%3E\");right:10px;left:auto}", |
| 661 |
".swiper-button-prev{background-image:url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg'%20viewBox%3D'0%200%2027%2044'%3E%3Cpath%20d%3D'M27%2C22L27%2C22L5%2C44l-2.1-2.1L22.8%2C22L2.9%2C2.1L5%2C0L27%2C22L27%2C22z'%20fill%3D'%23fff'%2F%3E%3C%2Fsvg%3E\");right:10px;left:auto}", |
| 662 |
); |
| 663 |
|
| 664 |
// https://github.com/matthiasmullie/minify/issues/210 |
| 665 |
$tests[] = array( |
| 666 |
'/*xs*/ |
| 667 |
@media (max-width: 767px) { |
| 668 |
.basket_ad{ |
| 669 |
margin-top:0 |
| 670 |
} |
| 671 |
} |
| 672 |
/*sm*/ |
| 673 |
@media (min-width: 768px) {} |
| 674 |
/*md*/ |
| 675 |
@media (min-width: 992px) {} |
| 676 |
/*lg*/ |
| 677 |
@media (min-width: 1200px) {}', |
| 678 |
'@media (max-width:767px){.basket_ad{margin-top:0}}', |
| 679 |
); |
| 680 |
|
| 681 |
// https://github.com/matthiasmullie/minify/issues/212 |
| 682 |
$tests[] = array( |
| 683 |
'p{color:#000000}', |
| 684 |
'p{color:#000}', |
| 685 |
); |
| 686 |
$tests[] = array( |
| 687 |
'p{border:0.5px solid red}', |
| 688 |
'p{border:.5px solid red}', |
| 689 |
); |
| 690 |
|
| 691 |
// https://github.com/matthiasmullie/minify/issues/215 |
| 692 |
$tests[] = array( |
| 693 |
'@import "http://minify.dev/?a=1&b=some/*lala*/thing";p{color:red}', |
| 694 |
'@import "http://minify.dev/?a=1&b=some/*lala*/thing";p{color:red}', |
| 695 |
); |
| 696 |
$tests[] = array( |
| 697 |
'p{color:red};@import "http://minify.dev/?a=1&b=some/*lala*/thing"', |
| 698 |
'@import "http://minify.dev/?a=1&b=some/*lala*/thing";p{color:red}', |
| 699 |
); |
| 700 |
|
| 701 |
// https://github.com/matthiasmullie/minify/issues/216 |
| 702 |
$tests[] = array( |
| 703 |
'.link-wrapper a:before{content:"Click for Download";}', |
| 704 |
'.link-wrapper a:before{content:"Click for Download"}', |
| 705 |
); |
| 706 |
|
| 707 |
// https://github.com/matthiasmullie/minify/issues/217 |
| 708 |
$tests[] = array( |
| 709 |
'div { background:url("sprite.svg") calc(-192px * 1) calc(0px * 1) no-repeat; }', |
| 710 |
'div{background:url(sprite.svg) calc(-192px * 1) calc(0px * 1) no-repeat}', |
| 711 |
); |
| 712 |
$tests[] = array( |
| 713 |
'div { background:url("sprite.svg") calc((-192px - 60px) * 0) calc(0px * 1) no-repeat; }', |
| 714 |
'div{background:url(sprite.svg) calc((-192px - 60px) * 0) calc(0px * 1) no-repeat}', |
| 715 |
); |
| 716 |
$tests[] = array( |
| 717 |
'div{border:calc((-192px - 60px) * 0) calc(0px * 1) calc(5px + (2px + (0px * 1) + 5px) * 3) calc(0px - 0px) solid red}', |
| 718 |
'div{border:calc((-192px - 60px) * 0) calc(0px * 1) calc(5px + (2px + (0px * 1) + 5px) * 3) calc(0px - 0px) solid red}', |
| 719 |
); |
| 720 |
|
| 721 |
// https://github.com/matthiasmullie/minify/issues/235 |
| 722 |
$tests[] = array( |
| 723 |
'#site-header.medium-header .top-col.logo-col{ |
| 724 |
-webkit-flex: auto 0 0; |
| 725 |
flex: auto 0 0; |
| 726 |
}', |
| 727 |
'#site-header.medium-header .top-col.logo-col{-webkit-flex:auto 0 0;flex:auto 0 0}', |
| 728 |
); |
| 729 |
|
| 730 |
// https://github.com/matthiasmullie/minify/issues/240 |
| 731 |
$tests[] = array( |
| 732 |
'p{color:red} |
| 733 |
@import url("http://minify.dev/?a=1&b=some/*lala*/thing"); |
| 734 |
body{font-family:sans-serif}', |
| 735 |
'@import url(http://minify.dev/?a=1&b=some/*lala*/thing);p{color:red}body{font-family:sans-serif}', |
| 736 |
); |
| 737 |
$tests[] = array( |
| 738 |
'p{color:red} |
| 739 |
@import url("http://minify.dev/?a=1&b=some/*lala*/thing") ; |
| 740 |
body{font-family:sans-serif}', |
| 741 |
'@import url(http://minify.dev/?a=1&b=some/*lala*/thing);p{color:red}body{font-family:sans-serif}', |
| 742 |
); |
| 743 |
|
| 744 |
// https://github.com/matthiasmullie/minify/issues/259 |
| 745 |
$tests[] = array( |
| 746 |
'#layout-newsletter-change .unsubscribe :checked + label .circle, #layout-newsletter-change .pause : checked + label .circle { color: white }', |
| 747 |
'#layout-newsletter-change .unsubscribe :checked+label .circle,#layout-newsletter-change .pause :checked+label .circle{color:#fff}', |
| 748 |
); |
| 749 |
$tests[] = array( |
| 750 |
'input + label{color:white}', |
| 751 |
'input+label{color:#fff}', |
| 752 |
); |
| 753 |
$tests[] = array( |
| 754 |
'input +label{color:white}', |
| 755 |
'input+label{color:#fff}', |
| 756 |
); |
| 757 |
$tests[] = array( |
| 758 |
'input+ label{color:white}', |
| 759 |
'input+label{color:#fff}', |
| 760 |
); |
| 761 |
$tests[] = array( |
| 762 |
'div{width:calc(100px + 100px)}', |
| 763 |
'div{width:calc(100px + 100px)}', |
| 764 |
); |
| 765 |
|
| 766 |
$tests[] = array( |
| 767 |
'p{color:#ffff0033}', |
| 768 |
'p{color:#ff03}', |
| 769 |
); |
| 770 |
$tests[] = array( |
| 771 |
'p{color:#ffff00ff}', |
| 772 |
'p{color:#ff0}', |
| 773 |
); |
| 774 |
$tests[] = array( |
| 775 |
'p{color:#ff0f}', |
| 776 |
'p{color:#ff0}', |
| 777 |
); |
| 778 |
|
| 779 |
// https://github.com/matthiasmullie/minify/issues/267 |
| 780 |
$tests[] = array( |
| 781 |
'ul p { padding-left: calc((var(--icon-size) / 2) + var(--horisontal-space)); }', |
| 782 |
'ul p{padding-left:calc((var(--icon-size) / 2) + var(--horisontal-space))}', |
| 783 |
); |
| 784 |
|
| 785 |
// https://github.com/matthiasmullie/minify/issues/351 |
| 786 |
$tests[] = array( |
| 787 |
'clamp(2.5rem, 1rem + 4vw, 4rem)', |
| 788 |
'clamp(2.5rem, 1rem + 4vw, 4rem)', |
| 789 |
); |
| 790 |
|
| 791 |
// https://github.com/matthiasmullie/minify/issues/342 |
| 792 |
$tests[] = array( |
| 793 |
'--headlineFontSize: 16px + var(--multiplicator); |
| 794 |
font-size: calc(var(--headlineFontSize));', |
| 795 |
'--headlineFontSize:16px + var(--multiplicator);font-size:calc(var(--headlineFontSize));', |
| 796 |
); |
| 797 |
|
| 798 |
// https://github.com/matthiasmullie/minify/issues/312 |
| 799 |
$tests[] = array( |
| 800 |
'.alignfull { width: calc(100% + calc(2 * var(--central-padding))); }', |
| 801 |
'.alignfull{width:calc(100% + calc(2 * var(--central-padding)))}', |
| 802 |
); |
| 803 |
$tests[] = array( |
| 804 |
'*{margin-left: calc(0.5rem * calc(1 - var(--space-x-reverse)));}', |
| 805 |
'*{margin-left:calc(0.5rem * calc(1 - var(--space-x-reverse)))}', |
| 806 |
); |
| 807 |
|
| 808 |
// https://github.com/matthiasmullie/minify/issues/349 |
| 809 |
$tests[] = array( |
| 810 |
'.space-x-4 > :not([hidden]) ~ :not([hidden]) { |
| 811 |
--tw-space-x-reverse: 0; |
| 812 |
margin-right: calc(1rem * var(--tw-space-x-reverse)); |
| 813 |
margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse))); |
| 814 |
}', |
| 815 |
'.space-x-4>:not([hidden])~:not([hidden]){--tw-space-x-reverse:0;margin-right:calc(1rem * var(--tw-space-x-reverse));margin-left:calc(1rem * calc(1 - var(--tw-space-x-reverse)))}', |
| 816 |
); |
| 817 |
|
| 818 |
// https://github.com/matthiasmullie/minify/issues/356 |
| 819 |
$tests[] = array( |
| 820 |
'.testclass{ grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr); }', |
| 821 |
'.testclass{grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,1fr)}', |
| 822 |
); |
| 823 |
|
| 824 |
// https://github.com/matthiasmullie/minify/issues/298 |
| 825 |
$tests[] = array( |
| 826 |
':root { |
| 827 |
--some-var: 0px; |
| 828 |
} |
| 829 |
.some-class { |
| 830 |
margin-left: calc(20px + var(--some-var)); |
| 831 |
}', |
| 832 |
':root{--some-var:0px}.some-class{margin-left:calc(20px + var(--some-var))}', |
| 833 |
); |
| 834 |
|
| 835 |
return $tests; |
| 836 |
} |
| 837 |
|
| 838 |
/** |
| 839 |
* @return array [input, expected result] |
| 840 |
*/ |
| 841 |
public function dataProviderPaths() |
| 842 |
{ |
| 843 |
$tests = array(); |
| 844 |
|
| 845 |
$source = __DIR__.'/sample/convert_relative_path/source'; |
| 846 |
$target = __DIR__.'/sample/convert_relative_path/target'; |
| 847 |
|
| 848 |
// external link |
| 849 |
$tests[] = array( |
| 850 |
$source.'/external.css', |
| 851 |
$target.'/external.css', |
| 852 |
file_get_contents($source.'/external.css'), |
| 853 |
); |
| 854 |
|
| 855 |
// absolute path |
| 856 |
$tests[] = array( |
| 857 |
$source.'/absolute.css', |
| 858 |
$target.'/absolute.css', |
| 859 |
file_get_contents($source.'/absolute.css'), |
| 860 |
); |
| 861 |
|
| 862 |
// relative paths |
| 863 |
$tests[] = array( |
| 864 |
$source.'/relative.css', |
| 865 |
$target.'/relative.css', |
| 866 |
'@import url(stylesheet.css);', |
| 867 |
); |
| 868 |
$tests[] = array( |
| 869 |
$source.'/../source/relative.css', |
| 870 |
$target.'/target/relative.css', |
| 871 |
'@import url(../stylesheet.css);', |
| 872 |
); |
| 873 |
|
| 874 |
// https://github.com/matthiasmullie/minify/issues/29 |
| 875 |
$tests[] = array( |
| 876 |
$source.'/issue29.css', |
| 877 |
$target.'/issue29.css', |
| 878 |
'@import url(http://myurl.de);', |
| 879 |
); |
| 880 |
|
| 881 |
// https://github.com/matthiasmullie/minify/issues/38 |
| 882 |
$tests[] = array( |
| 883 |
$source.'/relative.css', |
| 884 |
null, // no output file |
| 885 |
file_get_contents($source.'/relative.css'), |
| 886 |
); |
| 887 |
|
| 888 |
// https://github.com/matthiasmullie/minify/issues/39 |
| 889 |
$tests[] = array( |
| 890 |
$source.'/issue39.css', |
| 891 |
null, // no output file |
| 892 |
// relative paths should remain untouched |
| 893 |
"@font-face{font-family:'blackcat';src:url(../webfont/blackcat.eot);src:url('../webfont/blackcat.eot?#iefix') format('embedded-opentype'),url('../webfont/blackcat.svg#blackcat') format('svg'),url(../webfont/blackcat.woff) format('woff'),url(../webfont/blackcat.ttf) format('truetype');font-weight:400;font-style:normal}", |
| 894 |
); |
| 895 |
$tests[] = array( |
| 896 |
$source.'/issue39.css', |
| 897 |
$target.'/issue39.css', |
| 898 |
// relative paths should remain untouched |
| 899 |
"@font-face{font-family:'blackcat';src:url(../webfont/blackcat.eot);src:url('../webfont/blackcat.eot?#iefix') format('embedded-opentype'),url('../webfont/blackcat.svg#blackcat') format('svg'),url(../webfont/blackcat.woff) format('woff'),url(../webfont/blackcat.ttf) format('truetype');font-weight:400;font-style:normal}", |
| 900 |
); |
| 901 |
$tests[] = array( |
| 902 |
$source.'/issue39.css', |
| 903 |
$target.'/target/issue39.css', |
| 904 |
// relative paths should have changed |
| 905 |
"@font-face{font-family:'blackcat';src:url(../../webfont/blackcat.eot);src:url('../../webfont/blackcat.eot?#iefix') format('embedded-opentype'),url('../../webfont/blackcat.svg#blackcat') format('svg'),url(../../webfont/blackcat.woff) format('woff'),url(../../webfont/blackcat.ttf) format('truetype');font-weight:400;font-style:normal}", |
| 906 |
); |
| 907 |
|
| 908 |
// https://github.com/forkcms/forkcms/issues/1121 |
| 909 |
$tests[] = array( |
| 910 |
$source.'/nested/nested.css', |
| 911 |
$target.'/nested.css', |
| 912 |
'@import url(stylesheet.css);', |
| 913 |
); |
| 914 |
|
| 915 |
// https://github.com/forkcms/forkcms/issues/1186 |
| 916 |
$tests[] = array( |
| 917 |
array( |
| 918 |
// key is a bogus path |
| 919 |
'/Users/mathias/Documents/— Projecten/PROJECT_NAAM/Web/src/Backend/Core/Layout/Css/screen.css' => '@import url("imports/typography.css");', |
| 920 |
), |
| 921 |
'/Users/mathias/Documents/— Projecten/PROJECT_NAAM/Web/src/Backend/Cache/MinifiedCss/some-hash.css', |
| 922 |
'@import url(../../Core/Layout/Css/imports/typography.css);', |
| 923 |
); |
| 924 |
|
| 925 |
// https://github.com/matthiasmullie/minify/issues/77#issuecomment-172844822 |
| 926 |
$tests[] = array( |
| 927 |
$source.'/get-params.css', |
| 928 |
$target.'/get-params.css', |
| 929 |
'@import url(../source/some-file.css?some=param);', |
| 930 |
); |
| 931 |
|
| 932 |
$sourceRelative = 'tests/css/sample/convert_relative_path/source'; |
| 933 |
$targetRelative = 'tests/css/sample/convert_relative_path/target'; |
| 934 |
|
| 935 |
// from and/or to are relative links |
| 936 |
$tests[] = array( |
| 937 |
$sourceRelative.'/relative.css', |
| 938 |
$target.'/relative.css', |
| 939 |
'@import url(stylesheet.css);', |
| 940 |
); |
| 941 |
// note: relative target only works if the file already exists: it has |
| 942 |
// to be able to realpath() |
| 943 |
$tests[] = array( |
| 944 |
$source.'/relative.css', |
| 945 |
$targetRelative.'/relative.css', |
| 946 |
'@import url(stylesheet.css);', |
| 947 |
); |
| 948 |
$tests[] = array( |
| 949 |
$sourceRelative.'/relative.css', |
| 950 |
$targetRelative.'/relative.css', |
| 951 |
'@import url(stylesheet.css);', |
| 952 |
); |
| 953 |
|
| 954 |
$source = __DIR__.'/sample/symlink'; |
| 955 |
$target = __DIR__.'/sample/symlink/target'; |
| 956 |
$sourceRelative = 'tests/css/sample/symlink'; |
| 957 |
$targetRelative = 'tests/css/sample/symlink/target'; |
| 958 |
|
| 959 |
// import symlinked files: relative, absolute & mix |
| 960 |
$tests[] = array( |
| 961 |
$source.'/import_symlinked_file.css', |
| 962 |
$target.'/import_symlinked_file.css', |
| 963 |
'', |
| 964 |
); |
| 965 |
$tests[] = array( |
| 966 |
$sourceRelative.'/import_symlinked_file.css', |
| 967 |
$targetRelative.'/import_symlinked_file.css', |
| 968 |
'', |
| 969 |
); |
| 970 |
$tests[] = array( |
| 971 |
$source.'/import_symlinked_file.css', |
| 972 |
$targetRelative.'/import_symlinked_file.css', |
| 973 |
'', |
| 974 |
); |
| 975 |
$tests[] = array( |
| 976 |
$sourceRelative.'/import_symlinked_file.css', |
| 977 |
$target.'/import_symlinked_file.css', |
| 978 |
'', |
| 979 |
); |
| 980 |
|
| 981 |
// move symlinked files: relative, absolute & mix |
| 982 |
$tests[] = array( |
| 983 |
$source.'/move_symlinked_file.css', |
| 984 |
$target.'/move_symlinked_file.css', |
| 985 |
'body{background-url:url(../assets/symlink.bmp)}', |
| 986 |
); |
| 987 |
$tests[] = array( |
| 988 |
$sourceRelative.'/move_symlinked_file.css', |
| 989 |
$targetRelative.'/move_symlinked_file.css', |
| 990 |
'body{background-url:url(../assets/symlink.bmp)}', |
| 991 |
); |
| 992 |
$tests[] = array( |
| 993 |
$source.'/move_symlinked_file.css', |
| 994 |
$targetRelative.'/move_symlinked_file.css', |
| 995 |
'body{background-url:url(../assets/symlink.bmp)}', |
| 996 |
); |
| 997 |
$tests[] = array( |
| 998 |
$source.'/move_symlinked_file.css', |
| 999 |
$targetRelative.'/move_symlinked_file.css', |
| 1000 |
'body{background-url:url(../assets/symlink.bmp)}', |
| 1001 |
); |
| 1002 |
|
| 1003 |
// import symlinked folders: relative, absolute & mix |
| 1004 |
$tests[] = array( |
| 1005 |
$source.'/import_symlinked_folder.css', |
| 1006 |
$target.'/import_symlinked_folder.css', |
| 1007 |
'', |
| 1008 |
); |
| 1009 |
$tests[] = array( |
| 1010 |
$sourceRelative.'/import_symlinked_folder.css', |
| 1011 |
$targetRelative.'/import_symlinked_folder.css', |
| 1012 |
'', |
| 1013 |
); |
| 1014 |
$tests[] = array( |
| 1015 |
$source.'/import_symlinked_folder.css', |
| 1016 |
$targetRelative.'/import_symlinked_folder.css', |
| 1017 |
'', |
| 1018 |
); |
| 1019 |
$tests[] = array( |
| 1020 |
$sourceRelative.'/import_symlinked_folder.css', |
| 1021 |
$target.'/import_symlinked_folder.css', |
| 1022 |
'', |
| 1023 |
); |
| 1024 |
|
| 1025 |
// move symlinked folders: relative, absolute & mix |
| 1026 |
$tests[] = array( |
| 1027 |
$source.'/move_symlinked_folder.css', |
| 1028 |
$target.'/move_symlinked_folder.css', |
| 1029 |
'body{background-url:url(../assets_symlink/asset.bmp)}', |
| 1030 |
); |
| 1031 |
$tests[] = array( |
| 1032 |
$sourceRelative.'/move_symlinked_folder.css', |
| 1033 |
$targetRelative.'/move_symlinked_folder.css', |
| 1034 |
'body{background-url:url(../assets_symlink/asset.bmp)}', |
| 1035 |
); |
| 1036 |
$tests[] = array( |
| 1037 |
$source.'/move_symlinked_folder.css', |
| 1038 |
$targetRelative.'/move_symlinked_folder.css', |
| 1039 |
'body{background-url:url(../assets_symlink/asset.bmp)}', |
| 1040 |
); |
| 1041 |
$tests[] = array( |
| 1042 |
$sourceRelative.'/move_symlinked_folder.css', |
| 1043 |
$target.'/move_symlinked_folder.css', |
| 1044 |
'body{background-url:url(../assets_symlink/asset.bmp)}', |
| 1045 |
); |
| 1046 |
|
| 1047 |
// https://github.com/matthiasmullie/minify/issues/100 |
| 1048 |
$tests[] = array( |
| 1049 |
array( |
| 1050 |
// key is a bogus path |
| 1051 |
'/var/www/app/www/turysta/something/css/original.css' => '.ui-icon { width: 16px; height: 16px; background-image: url(/_lay/jqueryui/ui-icons_72b42d_256x240.png); }', |
| 1052 |
), |
| 1053 |
'/var/www/app/www/turysta/shared/_cache/_css/minified.css', |
| 1054 |
'.ui-icon{width:16px;height:16px;background-image:url(/_lay/jqueryui/ui-icons_72b42d_256x240.png)}', |
| 1055 |
); |
| 1056 |
|
| 1057 |
return $tests; |
| 1058 |
} |
| 1059 |
} |
| 1060 |
|