mirror of
https://github.com/mrclay/minify.git
synced 2025-08-11 16:44:44 +02:00
Minify.php : fix for Issue 73 and test
This commit is contained in:
@@ -56,7 +56,7 @@ class Minify {
|
|||||||
* need to recombine files, minify and encode the output.
|
* need to recombine files, minify and encode the output.
|
||||||
*
|
*
|
||||||
* @param mixed $cache object with identical interface as Minify_Cache_File or
|
* @param mixed $cache object with identical interface as Minify_Cache_File or
|
||||||
* a directory path. (default = '')
|
* a directory path, or null to disable caching. (default = '')
|
||||||
*
|
*
|
||||||
* @param bool $fileLocking (default = true) This only applies if the first
|
* @param bool $fileLocking (default = true) This only applies if the first
|
||||||
* parameter is a string.
|
* parameter is a string.
|
||||||
@@ -402,9 +402,10 @@ class Minify {
|
|||||||
protected static function _combineMinify() {
|
protected static function _combineMinify() {
|
||||||
$type = self::$_options['contentType']; // ease readability
|
$type = self::$_options['contentType']; // ease readability
|
||||||
|
|
||||||
// when combining scripts, make sure all statements separated
|
// when combining scripts, make sure all statements separated and
|
||||||
|
// trailing single line comment is terminated
|
||||||
$implodeSeparator = ($type === self::TYPE_JS)
|
$implodeSeparator = ($type === self::TYPE_JS)
|
||||||
? ';'
|
? "\n;"
|
||||||
: '';
|
: '';
|
||||||
// allow the user to pass a particular array of options to each
|
// allow the user to pass a particular array of options to each
|
||||||
// minifier (designated by type). source objects may still override
|
// minifier (designated by type). source objects may still override
|
||||||
|
2
min_unit_tests/_test_files/minify/issue73_1.js
Normal file
2
min_unit_tests/_test_files/minify/issue73_1.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
// end in comment
|
3
min_unit_tests/_test_files/minify/issue73_2.js
Normal file
3
min_unit_tests/_test_files/minify/issue73_2.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
function h() {
|
||||||
|
|
||||||
|
}
|
@@ -46,7 +46,6 @@ function test_Minify()
|
|||||||
}
|
}
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
//! class_exists('Cache_Lite_File', false)
|
|
||||||
! class_exists('HTTP_Encoder', false)
|
! class_exists('HTTP_Encoder', false)
|
||||||
&& ! class_exists('Minify_CSS', false)
|
&& ! class_exists('Minify_CSS', false)
|
||||||
&& ! class_exists('Minify_Cache', false)
|
&& ! class_exists('Minify_Cache', false)
|
||||||
@@ -83,8 +82,8 @@ function test_Minify()
|
|||||||
,'maxAge' => 86400
|
,'maxAge' => 86400
|
||||||
,'encodeOutput' => false
|
,'encodeOutput' => false
|
||||||
));
|
));
|
||||||
$passed = assertTrue($expected === $output, 'Minify : JS and Expires');
|
|
||||||
|
|
||||||
|
$passed = assertTrue($expected === $output, 'Minify : JS and Expires');
|
||||||
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||||
echo "\nOutput: " .var_export($output, 1). "\n\n";
|
echo "\nOutput: " .var_export($output, 1). "\n\n";
|
||||||
if (! $passed) {
|
if (! $passed) {
|
||||||
@@ -92,6 +91,28 @@ function test_Minify()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test for Issue 73
|
||||||
|
Minify::setCache(null);
|
||||||
|
|
||||||
|
$expected = ";function h(){}";
|
||||||
|
$output = Minify::serve('Files', array(
|
||||||
|
'files' => array(
|
||||||
|
$minifyTestPath . '/issue73_1.js'
|
||||||
|
,$minifyTestPath . '/issue73_2.js'
|
||||||
|
)
|
||||||
|
,'quiet' => true
|
||||||
|
,'encodeOutput' => false
|
||||||
|
));
|
||||||
|
$output = $output['content'];
|
||||||
|
|
||||||
|
$passed = assertTrue($expected === $output, 'Minify : Issue 73');
|
||||||
|
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
|
||||||
|
if (! $passed) {
|
||||||
|
echo "\n---Output : " .var_export($output, 1). "\n";
|
||||||
|
echo "---Expected: " .var_export($expected, 1). "\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test minifying CSS and responding with Etag/Last-Modified
|
// Test minifying CSS and responding with Etag/Last-Modified
|
||||||
|
|
||||||
Minify::setCache();
|
Minify::setCache();
|
||||||
|
Reference in New Issue
Block a user