mirror of
https://github.com/mrclay/minify.git
synced 2025-01-17 21:28:14 +01:00
min/config.php : + bubbleCssImports option
test_Minify.php : + tests for bubbleCssImports
This commit is contained in:
parent
0fc245e8c6
commit
9ed412fe81
@ -66,6 +66,17 @@ $min_documentRoot = '';
|
||||
$min_cacheFileLocking = true;
|
||||
|
||||
|
||||
/**
|
||||
* Combining multiple CSS files can place @import declarations after rules, which
|
||||
* is invalid. Minify will attempt to detect when this happens and place a
|
||||
* warning comment at the top of the CSS output. To resolve this you can either
|
||||
* move the @imports within your CSS files, or enable this option, which will
|
||||
* move all @imports to the top of the output. Note that moving @imports could
|
||||
* affect CSS values (which is why this option is disabled by default).
|
||||
*/
|
||||
$min_serveOptions['bubbleCssImports'] = false;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum age of browser cache in seconds. After this period, the browser
|
||||
* will send another conditional GET. Use a longer period for lower traffic
|
||||
|
7
min_unit_tests/_test_files/minify/issue89_1.css
Normal file
7
min_unit_tests/_test_files/minify/issue89_1.css
Normal file
@ -0,0 +1,7 @@
|
||||
/* this { is a } comment */
|
||||
|
||||
@import "/1.css";
|
||||
|
||||
selector {
|
||||
property: value;
|
||||
}
|
7
min_unit_tests/_test_files/minify/issue89_2.css
Normal file
7
min_unit_tests/_test_files/minify/issue89_2.css
Normal file
@ -0,0 +1,7 @@
|
||||
/* this { is a } comment */
|
||||
|
||||
@import "/2.css";
|
||||
|
||||
selector2 {
|
||||
property: value;
|
||||
}
|
1
min_unit_tests/_test_files/minify/issue89_out.min.css
vendored
Normal file
1
min_unit_tests/_test_files/minify/issue89_out.min.css
vendored
Normal file
@ -0,0 +1 @@
|
||||
@import "/1.css";@import "/2.css";selector{property:value}selector2{property:value}
|
@ -10,6 +10,7 @@ function test_Minify()
|
||||
global $thisDir;
|
||||
|
||||
$minifyTestPath = dirname(__FILE__) . '/_test_files/minify';
|
||||
$thisFileActive = (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME']));
|
||||
$tomorrow = $_SERVER['REQUEST_TIME'] + 86400;
|
||||
$lastModified = $_SERVER['REQUEST_TIME'] - 86400;
|
||||
|
||||
@ -38,7 +39,7 @@ function test_Minify()
|
||||
,'encodeOutput' => false
|
||||
));
|
||||
$passed = assertTrue($expected === $output, 'Minify : 304 response');
|
||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||
if ($thisFileActive) {
|
||||
echo "\nOutput: " .var_export($output, 1). "\n\n";
|
||||
if (! $passed) {
|
||||
echo "\n\n\n\n---Expected: " .var_export($expected, 1). "\n\n";
|
||||
@ -84,7 +85,7 @@ function test_Minify()
|
||||
));
|
||||
|
||||
$passed = assertTrue($expected === $output, 'Minify : JS and Expires');
|
||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||
if ($thisFileActive) {
|
||||
echo "\nOutput: " .var_export($output, 1). "\n\n";
|
||||
if (! $passed) {
|
||||
echo "\n\n\n\n---Expected: " .var_export($expected, 1). "\n\n";
|
||||
@ -106,7 +107,60 @@ function test_Minify()
|
||||
$output = $output['content'];
|
||||
|
||||
$passed = assertTrue($expected === $output, 'Minify : Issue 73');
|
||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||
if ($thisFileActive) {
|
||||
if (! $passed) {
|
||||
echo "\n---Output : " .var_export($output, 1). "\n";
|
||||
echo "---Expected: " .var_export($expected, 1). "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
// test for Issue 89
|
||||
$expected = file_get_contents($minifyTestPath . '/issue89_out.min.css');
|
||||
$output = Minify::serve('Files', array(
|
||||
'files' => array(
|
||||
$minifyTestPath . '/issue89_1.css'
|
||||
,$minifyTestPath . '/issue89_2.css'
|
||||
)
|
||||
,'quiet' => true
|
||||
,'encodeOutput' => false
|
||||
,'bubbleCssImports' => true
|
||||
));
|
||||
$output = $output['content'];
|
||||
$passed = assertTrue($expected === $output, 'Minify : Issue 89 : bubbleCssImports');
|
||||
if ($thisFileActive) {
|
||||
if (! $passed) {
|
||||
echo "\n---Output : " .var_export($output, 1). "\n";
|
||||
echo "---Expected: " .var_export($expected, 1). "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
$output = Minify::serve('Files', array(
|
||||
'files' => array(
|
||||
$minifyTestPath . '/issue89_1.css'
|
||||
,$minifyTestPath . '/issue89_2.css'
|
||||
)
|
||||
,'quiet' => true
|
||||
,'encodeOutput' => false
|
||||
));
|
||||
$output = $output['content'];
|
||||
$passed = assertTrue(0 === strpos($output, Minify::$importWarning), 'Minify : Issue 89 : detect invalid imports');
|
||||
if ($thisFileActive) {
|
||||
if (! $passed) {
|
||||
echo "\n---Output : " .var_export($output, 1). "\n";
|
||||
echo "---Expected: " .var_export($expected, 1). "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
$output = Minify::serve('Files', array(
|
||||
'files' => array(
|
||||
$minifyTestPath . '/issue89_1.css'
|
||||
)
|
||||
,'quiet' => true
|
||||
,'encodeOutput' => false
|
||||
));
|
||||
$output = $output['content'];
|
||||
$passed = assertTrue(false === strpos($output, Minify::$importWarning), 'Minify : Issue 89 : don\'t warn about valid imports');
|
||||
if ($thisFileActive) {
|
||||
if (! $passed) {
|
||||
echo "\n---Output : " .var_export($output, 1). "\n";
|
||||
echo "---Expected: " .var_export($expected, 1). "\n\n";
|
||||
@ -146,7 +200,7 @@ function test_Minify()
|
||||
));
|
||||
|
||||
$passed = assertTrue($expected === $output, 'Minify : CSS and Etag/Last-Modified');
|
||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||
if ($thisFileActive) {
|
||||
echo "\nOutput: " .var_export($output, 1). "\n\n";
|
||||
if (! $passed) {
|
||||
echo "\n\n\n\n---Expected: " .var_export($expected, 1). "\n\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user