2013-04-14 23:38:24 +02:00
< ? php
use MatthiasMullie\Minify ;
/**
* CSS minifier test case .
*/
class CSSTest extends PHPUnit_Framework_TestCase
{
2014-10-12 21:10:12 +02:00
/**
* @ var Minify\CSS
*/
2013-04-14 23:38:24 +02:00
private $minifier ;
/**
* Prepares the environment before running a test .
*/
protected function setUp ()
{
parent :: setUp ();
2015-05-13 17:43:23 +02:00
// override save method, there's no point in writing the result out here
$this -> minifier = $this -> getMockBuilder ( '\MatthiasMullie\Minify\CSS' )
-> setMethods ( array ( 'save' ))
-> getMock ();
2013-04-14 23:38:24 +02:00
}
/**
* Cleans up the environment after running a test .
*/
protected function tearDown ()
{
$this -> minifier = null ;
parent :: tearDown ();
}
/**
2014-10-12 21:10:12 +02:00
* Test CSS minifier rules , provided by dataProvider .
2013-04-14 23:38:24 +02:00
*
* @ test
* @ dataProvider dataProvider
*/
2014-10-12 17:42:22 +02:00
public function minify ( $input , $expected )
2013-04-14 23:38:24 +02:00
{
2016-08-12 12:44:25 -04:00
$this -> minifier -> add ( $input );
2014-10-07 18:21:22 +02:00
$result = $this -> minifier -> minify ();
2013-12-26 20:39:10 +01:00
$this -> assertEquals ( $expected , $result );
2013-04-14 23:38:24 +02:00
}
2013-12-01 23:47:40 +01:00
/**
2014-10-12 21:10:12 +02:00
* Test conversion of relative paths , provided by dataProviderPaths .
2013-12-01 23:47:40 +01:00
*
* @ test
* @ dataProvider dataProviderPaths
*/
2014-10-30 10:43:48 +01:00
public function convertRelativePath ( $source , $target , $expected )
2014-10-09 08:56:14 +02:00
{
2015-02-20 16:50:56 +01:00
$source = ( array ) $source ;
2015-05-13 17:43:23 +02:00
foreach ( $source as $path => $css ) {
2015-02-20 16:50:56 +01:00
$this -> minifier -> add ( $css );
2015-05-13 17:43:23 +02:00
// $source also accepts an array where the key is a bogus path
if ( is_string ( $path )) {
$object = new ReflectionObject ( $this -> minifier );
$property = $object -> getProperty ( 'data' );
$property -> setAccessible ( true );
$data = $property -> getValue ( $this -> minifier );
// keep content, but make it appear from the given path
$data [ $path ] = array_pop ( $data );
$property -> setValue ( $this -> minifier , $data );
$property -> setAccessible ( false );
}
2015-02-20 16:50:56 +01:00
}
2015-05-13 17:43:23 +02:00
2014-10-30 10:43:48 +01:00
$result = $this -> minifier -> minify ( $target );
2013-12-01 23:47:40 +01:00
2013-12-26 20:39:10 +01:00
$this -> assertEquals ( $expected , $result );
2013-12-01 23:47:40 +01:00
}
2016-02-15 22:56:01 +03:00
/**
2016-02-17 09:58:12 +01:00
* Test loop while importing file .
2016-02-15 22:56:01 +03:00
*
* @ test
*
2016-02-17 11:42:59 +01:00
* @ expectedException MatthiasMullie\Minify\Exceptions\FileImportException
2016-02-15 22:56:01 +03:00
*/
public function fileImportLoop ()
{
$testFile = __DIR__ . '/sample/loop/first.css' ;
$this -> minifier -> add ( $testFile );
2016-02-17 11:42:59 +01:00
$this -> minifier -> minify ();
2016-02-15 22:56:01 +03:00
}
2013-04-14 23:38:24 +02:00
/**
2014-10-12 21:10:12 +02:00
* Test minifier import configuration methods .
2013-04-14 23:38:24 +02:00
*
2014-10-12 21:10:12 +02:00
* @ test
*/
2015-02-12 13:34:48 +01:00
public function setConfig ()
{
2014-10-12 21:10:12 +02:00
$this -> minifier -> setMaxImportSize ( 10 );
$this -> minifier -> setImportExtensions ( array ( 'gif' => 'data:image/gif' ));
$object = new ReflectionObject ( $this -> minifier );
$property = $object -> getProperty ( 'maxImportSize' );
$property -> setAccessible ( true );
$this -> assertEquals ( $property -> getValue ( $this -> minifier ), 10 );
$property = $object -> getProperty ( 'importExtensions' );
$property -> setAccessible ( true );
$this -> assertEquals ( $property -> getValue ( $this -> minifier ), array ( 'gif' => 'data:image/gif' ));
}
/**
* @ return array [ input , expected result ]
2013-04-14 23:38:24 +02:00
*/
public function dataProvider ()
{
$tests = array ();
2016-08-12 12:44:25 -04:00
// passing in an array of css inputs
$tests [] = array (
[
__DIR__ . '/sample/combine_imports/index.css' ,
__DIR__ . '/sample/bom/bom.css' ,
'p { width: 55px , margin: 0 0 0 0}' ,
],
'body{color:red}body{color:red}p{width:55px,margin:0 0 0 0}' ,
);
2014-10-12 21:55:30 +02:00
// try importing, with both @import syntax types & media queries
2013-04-14 23:38:24 +02:00
$tests [] = array (
2015-03-06 13:17:33 +01:00
__DIR__ . '/sample/combine_imports/index.css' ,
2013-12-26 23:59:56 +01:00
'body{color:red}' ,
2013-04-14 23:38:24 +02:00
);
2014-10-12 21:10:12 +02:00
$tests [] = array (
2015-03-06 13:17:33 +01:00
__DIR__ . '/sample/combine_imports/index2.css' ,
2014-10-12 21:10:12 +02:00
'body{color:red}' ,
);
2014-10-12 21:41:25 +02:00
$tests [] = array (
2015-03-06 13:17:33 +01:00
__DIR__ . '/sample/combine_imports/index3.css' ,
2014-10-12 21:41:25 +02:00
'body{color:red}body{color:red}' ,
);
2014-10-12 21:55:30 +02:00
$tests [] = array (
2015-03-06 13:17:33 +01:00
__DIR__ . '/sample/combine_imports/index4.css' ,
2014-10-12 21:55:30 +02:00
'@media only screen{body{color:red}}@media only screen{body{color:red}}' ,
);
2014-10-20 11:08:51 +02:00
$tests [] = array (
2015-03-06 13:17:33 +01:00
__DIR__ . '/sample/combine_imports/index5.css' ,
2014-10-20 11:08:51 +02:00
'body{color:red}body{color:red}' ,
);
2014-10-30 10:16:29 +01:00
$tests [] = array (
2015-03-06 13:17:33 +01:00
__DIR__ . '/sample/combine_imports/index6a.css' ,
2014-10-30 10:16:29 +01:00
'body{color:red}' ,
);
2013-04-14 23:38:24 +02:00
2014-10-12 22:00:18 +02:00
// shorthand hex color codes
2013-04-14 23:38:24 +02:00
$tests [] = array (
2013-12-26 23:59:56 +01:00
'color:#FF00FF;' ,
'color:#F0F;' ,
2013-04-14 23:38:24 +02:00
);
2014-10-12 22:00:18 +02:00
// import files
2013-04-14 23:38:24 +02:00
$tests [] = array (
2015-03-06 13:17:33 +01:00
__DIR__ . '/sample/import_files/index.css' ,
'body{background:url(data:image/png;base64,' . base64_encode ( file_get_contents ( __DIR__ . '/sample/import_files/file.png' )) . ')}' ,
2013-04-14 23:38:24 +02:00
);
2014-10-12 22:00:18 +02:00
// strip comments
2013-04-14 23:38:24 +02:00
$tests [] = array (
'/* This is a CSS comment */' ,
'' ,
);
2014-10-12 22:00:18 +02:00
// strip whitespace
2013-04-14 23:38:24 +02:00
$tests [] = array (
'body { color: red; }' ,
'body{color:red}' ,
);
2014-10-12 22:00:18 +02:00
// whitespace inside strings shouldn't be replaced
$tests [] = array (
2014-10-30 10:16:29 +01:00
'content:"preserve whitespace"' ,
'content:"preserve whitespace"' ,
);
$tests [] = array (
' html
body {
color : red ;
} ' ,
2015-03-06 13:17:33 +01:00
'html body{color:red}' ,
2014-10-30 10:16:29 +01:00
);
$tests [] = array (
2015-02-20 17:24:53 +01:00
<<< 'JS'
2014-10-30 10:16:29 +01:00
p * i , html
/* remove spaces */
/* " comments have no escapes \*/
body /* keep */ /* space */ p ,
p [ remove ~= " spaces " ] : nth - child ( 3 + 2 n ) > b span i , div :: after
{
/* comment */
content : " escapes \" allowed \\ " ;
2015-02-20 17:24:53 +01:00
content : " /* string */ " ! important ;
2014-10-30 10:16:29 +01:00
width : calc ( 100 % - 3 em + 5 px ) ;
margin - top : 0 ;
margin - bottom : 0 ;
margin - left : 10 px ;
margin - right : 10 px ;
}
2015-02-20 17:24:53 +01:00
JS
,
2015-03-06 13:17:33 +01:00
'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}' ,
2014-10-12 22:00:18 +02:00
);
2013-04-22 10:19:35 +02:00
/*
* https :// github . com / forkcms / forkcms / issues / 387
*
* CSS backslash .
* * Backslash escaped by backslash in CSS
* * Double CSS backslashed escaped twice for in PHP string
*/
$tests [] = array (
'.iconic.map-pin:before { content: "\\\\"; }' ,
'.iconic.map-pin:before{content:"\\\\"}' ,
);
2013-04-22 10:16:01 +02:00
2014-10-20 11:08:51 +02:00
// strip BOM
$tests [] = array (
2015-03-06 13:17:33 +01:00
__DIR__ . '/sample/bom/bom.css' ,
2014-10-20 11:08:51 +02:00
'body{color:red}' ,
);
2014-11-20 21:39:05 +01:00
// https://github.com/matthiasmullie/minify/issues/22
$tests [] = array (
'p { background-position: -0px -64px; }' ,
2014-11-20 21:42:49 +01:00
'p{background-position:0 -64px}' ,
2014-11-20 21:39:05 +01:00
);
2014-12-04 20:08:57 +01:00
// https://github.com/matthiasmullie/minify/issues/23
$tests [] = array (
' ul . pagination {
display : block ;
min - height : 1.5 rem ;
margin - left : - 0.3125 rem ;
} ' ,
2015-08-25 14:56:09 +02:00
'ul.pagination{display:block;min-height:1.5rem;margin-left:-.3125rem}' ,
2014-12-04 20:08:57 +01:00
);
// edge cases for stripping zeroes
$tests [] = array (
2014-12-04 20:09:49 +01:00
'p { margin: -0.0rem; }' ,
2015-08-25 14:43:28 +02:00
'p{margin:0rem}' ,
2014-12-04 20:09:49 +01:00
);
$tests [] = array (
'p { margin: -0.01rem; }' ,
2015-08-25 14:56:09 +02:00
'p{margin:-.01rem}' ,
2014-12-04 20:08:57 +01:00
);
$tests [] = array (
'p { margin: .0; }' ,
'p{margin:0}' ,
);
2015-01-09 13:24:48 +01:00
$tests [] = array (
'p { margin: .0%; }' ,
2015-08-25 14:43:28 +02:00
'p{margin:0%}' ,
2015-01-09 13:24:48 +01:00
);
$tests [] = array (
'p { margin: 1.0; }' ,
'p{margin:1}' ,
);
$tests [] = array (
'p { margin: 1.0px; }' ,
'p{margin:1px}' ,
);
$tests [] = array (
'p { margin: 1.1; }' ,
'p{margin:1.1}' ,
);
$tests [] = array (
'p { margin: 1.1em; }' ,
'p{margin:1.1em}' ,
);
2014-12-07 18:35:07 +01:00
$tests [] = array (
'p { margin: 00px; }' ,
'p{margin:0}' ,
);
2015-08-25 14:56:09 +02:00
$tests [] = array (
'p { margin: 0.1px; }' ,
'p{margin:.1px}' ,
);
$tests [] = array (
'p { margin: 01.1px; }' ,
'p{margin:1.1px}' ,
);
$tests [] = array (
'p { margin: 0.060px; }' ,
'p{margin:.06px}' ,
);
2014-12-07 18:35:07 +01:00
$tests [] = array (
'p.class00 { background-color: #000000; color: #000; }' ,
'p.class00{background-color:#000;color:#000}' ,
);
2014-12-04 20:08:57 +01:00
2014-12-05 14:28:07 +01:00
// https://github.com/matthiasmullie/minify/issues/24
$tests [] = array (
'.col-1-1 { width: 100.00%; }' ,
'.col-1-1{width:100%}' ,
);
2014-12-07 14:02:46 +01:00
// https://github.com/matthiasmullie/minify/issues/25
$tests [] = array (
'p { background-color: #000000; color: #000; }' ,
'p{background-color:#000;color:#000}' ,
);
2015-01-07 12:01:22 +01:00
// https://github.com/matthiasmullie/minify/issues/26
$tests [] = array (
'.hr > :first-child { width: 0.0001%; }' ,
2015-08-25 14:56:09 +02:00
'.hr>:first-child{width:.0001%}' ,
2015-01-07 12:01:22 +01:00
);
2015-01-09 13:24:48 +01:00
// https://github.com/matthiasmullie/minify/issues/28
$tests [] = array (
2015-09-05 21:49:18 +02:00
'@font-face { src: url(//netdna.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.eot?v=4.2.0); }' ,
'@font-face{src:url(//netdna.bootstrapcdn.com/font-awesome/4.2.0/fonts/fontawesome-webfont.eot?v=4.2.0)}' ,
2015-01-09 13:24:48 +01:00
);
2015-01-23 09:13:48 -08:00
// https://github.com/matthiasmullie/minify/issues/31
$tests [] = array (
2015-09-07 21:47:18 +02:00
'dfn,em,img{color:red}' ,
'dfn,em,img{color:red}' ,
2015-01-23 09:13:48 -08:00
);
2015-05-05 14:52:16 +02:00
// https://github.com/matthiasmullie/minify/issues/49
$tests [] = array (
__DIR__ . '/sample/import_files/issue49.css' ,
2015-09-05 21:49:18 +02:00
'.social-btn a[href*="facebook"]{background-image:url(data:image/png;base64,' . base64_encode ( file_get_contents ( __DIR__ . '/sample/import_files/facebook.png' )) . ')}' .
'.social-btn a[href*="vimeo"]{background-image:url(data:image/png;base64,' . base64_encode ( file_get_contents ( __DIR__ . '/sample/import_files/vimeo.png' )) . ')}' .
'.social-btn a[href*="instagram"]{background-image:url(data:image/png;base64,' . base64_encode ( file_get_contents ( __DIR__ . '/sample/import_files/instagram.png' )) . ')}' ,
2015-05-05 14:52:16 +02:00
);
2015-09-02 17:33:56 +02:00
// https://github.com/matthiasmullie/minify/issues/68
2015-09-05 21:49:18 +02:00
$tests [] = array (
2015-09-02 17:33:56 +02:00
__DIR__ . '/sample/external_imports/issue68.css' ,
2015-09-05 21:49:18 +02:00
'@import url(http://localhost/file.css);body{background:green}' ,
2015-09-02 17:33:56 +02:00
);
2015-09-05 21:49:18 +02:00
2015-09-07 21:47:18 +02:00
// https://github.com/matthiasmullie/minify/issues/67
$tests [] = array (
' body { }
p { color : #fff; }',
'p{color:#fff}' ,
);
2015-09-08 12:40:02 +02:00
$tests [] = array (
' body {}
p { color : #fff; }
h1 { }
strong { color : red ; } ' ,
'p{color:#fff}strong{color:red}' ,
);
2015-09-07 21:47:18 +02:00
2015-09-21 21:21:48 +02:00
// https://github.com/matthiasmullie/minify/issues/74
$tests [] = array (
" @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 : 44 px 152 px ;
}
#fancybox-loading div {
background - image : url ( '/path/to/image.gif' );
background - size : 24 px 24 px ;
}
} " ,
2016-01-06 16:44:12 -08:00
'@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}}' ,
2015-09-21 21:21:48 +02:00
);
2016-01-10 18:09:47 -08:00
// https://github.com/matthiasmullie/minify/issues/92
$tests [] = array (
' @ media ( min - width : 320 px ) {
/* smartphones, iPhone, portrait 480x320 phones */
p {
background - color : red ;
}
}
@ media ( min - width : 1025 px ) {
/* big landscape tablets, laptops, and desktops */
/* LEFT EMPTY OF ANY SELECTORS */
}
@ media ( min - width : 1281 px ) {
/* hi-res laptops and desktops */
p {
background - color : blue ;
}
} ' ,
'@media (min-width:320px){p{background-color:red}}@media (min-width:1281px){p{background-color:blue}}' ,
);
2016-04-27 12:52:26 +02:00
// https://github.com/matthiasmullie/minify/issues/103
$tests [] = array (
'background:url(http://example.com/test.png);' ,
'background:url(http://example.com/test.png);' ,
);
2016-04-27 12:56:10 +02:00
// https://github.com/matthiasmullie/minify/issues/104
$tests [] = array (
'@media screen and (min-aspect-ratio: 16/9) { p { color: red } }' ,
'@media screen and (min-aspect-ratio:16/9){p{color:red}}' ,
);
2016-04-27 13:03:37 +02:00
// https://github.com/matthiasmullie/minify/issues/107
$tests [] = array (
'@import "https://font.googleapis.com/css?family=RobotoDraft:regular&lang=en";' ,
'@import "https://font.googleapis.com/css?family=RobotoDraft:regular&lang=en";' ,
);
$tests [] = array (
'@import "https://font.googleapis.com/css?family=RobotoDraft:regular&lang=en";' ,
'@import "https://font.googleapis.com/css?family=RobotoDraft:regular&lang=en";' ,
);
2016-06-09 21:24:27 +02:00
// https://github.com/matthiasmullie/minify/issues/109
$tests [] = array (
'p{font-weight:bold;}' ,
'p{font-weight:700}' ,
);
$tests [] = array (
' p {
font - weight : normal
} ' ,
'p{font-weight:400}' ,
);
2016-06-09 21:35:53 +02:00
$tests [] = array (
'p{background-color:#ff0000}' ,
'p{background-color:red}' ,
);
$tests [] = array (
'p{color:#F0E68C}' ,
'p{color:khaki}' ,
);
2016-06-09 21:24:27 +02:00
2016-09-20 14:58:00 +02:00
// https://github.com/matthiasmullie/minify/issues/137
$tests [] = array (
'p{width: calc(35% - 0px);}' ,
'p{width:calc(35%)}' ,
);
$tests [] = array (
'p{width: calc(0px + 35%);}' ,
'p{width:calc(35%)}' ,
);
$tests [] = array (
'p{width: calc(0px - 35%);}' ,
'p{width:calc(-35%)}' ,
);
$tests [] = array (
'p{width: calc(0px + 35% - 0px);}' ,
'p{width:calc(35%)}' ,
);
$tests [] = array (
'p{width: calc(5% + 0px + 35% - 0px + 5%);}' ,
'p{width:calc(5% + 35% + 5%)}' ,
);
$tests [] = array (
'p{width:calc(35% + (10% + 0px))}' ,
'p{width:calc(35% + (10%))}' ,
);
$tests [] = array (
'p{width:calc(35% + (10% + 0px + 10%))}' ,
'p{width:calc(35% + (10% + 10%))}' ,
);
2016-10-27 15:32:47 -07:00
// https://github.com/matthiasmullie/minify/issues/139
$tests [] = array (
__DIR__ . '/sample/line_endings/lf/parent.css' ,
'p{color:green}body{color:red}' ,
);
$tests [] = array (
__DIR__ . '/sample/line_endings/cr/parent.css' ,
'p{color:green}body{color:red}' ,
);
$tests [] = array (
__DIR__ . '/sample/line_endings/crlf/parent.css' ,
'p{color:green}body{color:red}' ,
);
2016-11-09 22:15:22 +01:00
// https://github.com/matthiasmullie/minify/issues/145
$tests [] = array (
' /* some imports */
@ import \ ' ./ css1 . css\ ' ;
@ import url ( \ ' https :// www . google . com / main . css\ ' );
. empty - rule {
}
body {
background : white ;
} ' ,
'@import "./css1.css";@import url(\'https://www.google.com/main.css\');body{background:white}' ,
);
2016-11-23 11:11:07 +01:00
// https://github.com/matthiasmullie/minify/commit/3253a81d07cd01afcb651e309900d8ad58a052da#commitcomment-19223603
$tests [] = array (
'p{border: 1px solid #f00000;}' ,
'p{border:1px solid #f00000}' ,
);
2016-11-23 15:24:58 +01:00
// https://github.com/matthiasmullie/minify/issues/149
$tests [] = array (
" .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 ;
} " ,
" .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} " ,
);
$tests [] = array (
" .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 ;
} " ,
" .headerWrapper { background:url('') no-repeat;background-position:100% 0;width:100%;min-height:0} " ,
);
2016-11-25 08:46:06 +01:00
// https://github.com/matthiasmullie/minify/issues/150
$tests [] = array (
'.text { box-shadow: 0 0 1em -0.5em #000; }' ,
'.text{box-shadow:0 0 1em -.5em #000}' ,
);
2013-04-14 23:38:24 +02:00
return $tests ;
}
2013-12-01 23:47:40 +01:00
2014-10-12 21:10:12 +02:00
/**
* @ return array [ input , expected result ]
*/
2014-10-09 08:56:14 +02:00
public function dataProviderPaths ()
{
2013-12-01 23:47:40 +01:00
$tests = array ();
2015-03-06 13:17:33 +01:00
$source = __DIR__ . '/sample/convert_relative_path/source' ;
$target = __DIR__ . '/sample/convert_relative_path/target' ;
2013-12-01 23:47:40 +01:00
2014-10-12 22:00:18 +02:00
// external link
2013-12-01 23:47:40 +01:00
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/external.css' ,
$target . '/external.css' ,
file_get_contents ( $source . '/external.css' ),
2013-12-01 23:47:40 +01:00
);
2014-10-12 22:00:18 +02:00
// absolute path
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/absolute.css' ,
$target . '/absolute.css' ,
file_get_contents ( $source . '/absolute.css' ),
2014-10-12 22:00:18 +02:00
);
2014-10-12 22:07:59 +02:00
// relative paths
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/relative.css' ,
$target . '/relative.css' ,
2016-01-04 15:56:41 -08:00
'@import url(stylesheet.css);' ,
2014-10-12 22:07:59 +02:00
);
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/../source/relative.css' ,
$target . '/target/relative.css' ,
2016-01-04 15:56:41 -08:00
'@import url(../stylesheet.css);' ,
2014-10-30 10:43:48 +01:00
);
2015-02-20 16:50:56 +01:00
// https://github.com/matthiasmullie/minify/issues/29
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/issue29.css' ,
$target . '/issue29.css' ,
2015-02-20 16:50:56 +01:00
" @import url('http://myurl.de'); " ,
);
// https://github.com/matthiasmullie/minify/issues/38
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/relative.css' ,
2015-02-20 16:50:56 +01:00
null , // no output file
2015-03-06 13:17:33 +01:00
file_get_contents ( $source . '/relative.css' ),
2015-02-20 16:50:56 +01:00
);
2015-02-20 17:27:05 +01:00
// https://github.com/matthiasmullie/minify/issues/39
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/issue39.css' ,
2015-02-20 17:27:05 +01:00
null , // no output file
// relative paths should remain untouched
2016-06-09 21:24:27 +02:00
" @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} " ,
2015-02-20 17:27:05 +01:00
);
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/issue39.css' ,
$target . '/issue39.css' ,
2015-02-20 17:27:05 +01:00
// relative paths should remain untouched
2016-06-09 21:24:27 +02:00
" @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} " ,
2015-02-20 17:27:05 +01:00
);
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/issue39.css' ,
$target . '/target/issue39.css' ,
2015-02-20 17:27:05 +01:00
// relative paths should have changed
2016-06-09 21:24:27 +02:00
" @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} " ,
2015-02-20 17:27:05 +01:00
);
2015-03-06 12:01:30 +01:00
// https://github.com/forkcms/forkcms/issues/1121
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/nested/nested.css' ,
$target . '/nested.css' ,
2016-01-04 15:56:41 -08:00
'@import url(stylesheet.css);' ,
2015-03-06 12:01:30 +01:00
);
2015-05-13 17:43:23 +02:00
// https://github.com/forkcms/forkcms/issues/1186
$tests [] = array (
array (
// key is a bogus path
'/Users/mathias/Documents/— Projecten/PROJECT_NAAM/Web/src/Backend/Core/Layout/Css/screen.css' => '@import url("imports/typography.css");' ,
),
'/Users/mathias/Documents/— Projecten/PROJECT_NAAM/Web/src/Backend/Cache/MinifiedCss/some-hash.css' ,
'@import url(../../Core/Layout/Css/imports/typography.css);' ,
);
2016-01-20 10:23:52 +01:00
// https://github.com/matthiasmullie/minify/issues/77#issuecomment-172844822
$tests [] = array (
$source . '/get-params.css' ,
$target . '/get-params.css' ,
'@import url(../source/some-file.css?some=param);' ,
);
2014-10-30 10:43:48 +01:00
$sourceRelative = 'tests/css/sample/convert_relative_path/source' ;
$targetRelative = 'tests/css/sample/convert_relative_path/target' ;
// from and/or to are relative links
$tests [] = array (
2015-03-06 13:17:33 +01:00
$sourceRelative . '/relative.css' ,
$target . '/relative.css' ,
2016-01-04 15:56:41 -08:00
'@import url(stylesheet.css);' ,
2014-10-30 10:43:48 +01:00
);
2015-05-13 18:03:44 +02:00
// note: relative target only works if the file already exists: it has
// to be able to realpath()
2014-10-30 10:43:48 +01:00
$tests [] = array (
2015-03-06 13:17:33 +01:00
$source . '/relative.css' ,
$targetRelative . '/relative.css' ,
2016-01-04 15:56:41 -08:00
'@import url(stylesheet.css);' ,
2014-10-30 10:43:48 +01:00
);
$tests [] = array (
2015-03-06 13:17:33 +01:00
$sourceRelative . '/relative.css' ,
$targetRelative . '/relative.css' ,
2016-01-04 15:56:41 -08:00
'@import url(stylesheet.css);' ,
2014-10-12 22:07:59 +02:00
);
2016-01-06 16:38:59 -08:00
$source = __DIR__ . '/sample/symlink' ;
$target = __DIR__ . '/sample/symlink/target' ;
$sourceRelative = 'tests/css/sample/symlink' ;
$targetRelative = 'tests/css/sample/symlink/target' ;
// import symlinked files: relative, absolute & mix
$tests [] = array (
$source . '/import_symlinked_file.css' ,
$target . '/import_symlinked_file.css' ,
'' ,
);
$tests [] = array (
$sourceRelative . '/import_symlinked_file.css' ,
$targetRelative . '/import_symlinked_file.css' ,
'' ,
);
2016-01-04 23:43:16 -08:00
$tests [] = array (
2016-01-06 16:38:59 -08:00
$source . '/import_symlinked_file.css' ,
$targetRelative . '/import_symlinked_file.css' ,
2016-01-06 15:11:53 -08:00
'' ,
2016-01-04 23:43:16 -08:00
);
$tests [] = array (
2016-01-06 16:38:59 -08:00
$sourceRelative . '/import_symlinked_file.css' ,
$target . '/import_symlinked_file.css' ,
'' ,
);
// move symlinked files: relative, absolute & mix
$tests [] = array (
$source . '/move_symlinked_file.css' ,
$target . '/move_symlinked_file.css' ,
'body{background-url:url(../assets/symlink.bmp)}' ,
);
$tests [] = array (
$sourceRelative . '/move_symlinked_file.css' ,
$targetRelative . '/move_symlinked_file.css' ,
'body{background-url:url(../assets/symlink.bmp)}' ,
);
$tests [] = array (
$source . '/move_symlinked_file.css' ,
$targetRelative . '/move_symlinked_file.css' ,
'body{background-url:url(../assets/symlink.bmp)}' ,
);
$tests [] = array (
$source . '/move_symlinked_file.css' ,
$targetRelative . '/move_symlinked_file.css' ,
2016-01-06 15:11:53 -08:00
'body{background-url:url(../assets/symlink.bmp)}' ,
2016-01-04 23:43:16 -08:00
);
2016-01-06 16:38:59 -08:00
// import symlinked folders: relative, absolute & mix
$tests [] = array (
$source . '/import_symlinked_folder.css' ,
$target . '/import_symlinked_folder.css' ,
'' ,
);
$tests [] = array (
$sourceRelative . '/import_symlinked_folder.css' ,
$targetRelative . '/import_symlinked_folder.css' ,
'' ,
);
$tests [] = array (
$source . '/import_symlinked_folder.css' ,
$targetRelative . '/import_symlinked_folder.css' ,
'' ,
);
$tests [] = array (
$sourceRelative . '/import_symlinked_folder.css' ,
$target . '/import_symlinked_folder.css' ,
'' ,
);
// move symlinked folders: relative, absolute & mix
$tests [] = array (
$source . '/move_symlinked_folder.css' ,
$target . '/move_symlinked_folder.css' ,
'body{background-url:url(../assets_symlink/asset.bmp)}' ,
);
$tests [] = array (
$sourceRelative . '/move_symlinked_folder.css' ,
$targetRelative . '/move_symlinked_folder.css' ,
'body{background-url:url(../assets_symlink/asset.bmp)}' ,
);
$tests [] = array (
$source . '/move_symlinked_folder.css' ,
$targetRelative . '/move_symlinked_folder.css' ,
'body{background-url:url(../assets_symlink/asset.bmp)}' ,
);
$tests [] = array (
$sourceRelative . '/move_symlinked_folder.css' ,
$target . '/move_symlinked_folder.css' ,
'body{background-url:url(../assets_symlink/asset.bmp)}' ,
);
2016-04-27 12:40:09 +02:00
// https://github.com/matthiasmullie/minify/issues/100
$tests [] = array (
array (
// key is a bogus path
'/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); }' ,
),
'/var/www/app/www/turysta/shared/_cache/_css/minified.css' ,
'.ui-icon{width:16px;height:16px;background-image:url(/_lay/jqueryui/ui-icons_72b42d_256x240.png)}' ,
);
2013-12-01 23:47:40 +01:00
return $tests ;
}
2013-04-14 23:38:24 +02:00
}