1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-11 08:34:19 +02:00

Minify.php : fix for Issue 73 and test

This commit is contained in:
Steve Clay
2009-01-06 16:32:28 +00:00
parent 34349dfe02
commit 039a25fc7c
4 changed files with 67 additions and 40 deletions

View File

@@ -56,7 +56,7 @@ class Minify {
* need to recombine files, minify and encode the output.
*
* @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
* parameter is a string.
@@ -402,9 +402,10 @@ class Minify {
protected static function _combineMinify() {
$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)
? ';'
? "\n;"
: '';
// allow the user to pass a particular array of options to each
// minifier (designated by type). source objects may still override

View File

@@ -0,0 +1,2 @@
// end in comment

View File

@@ -0,0 +1,3 @@
function h() {
}

View File

@@ -46,7 +46,6 @@ function test_Minify()
}
assertTrue(
//! class_exists('Cache_Lite_File', false)
! class_exists('HTTP_Encoder', false)
&& ! class_exists('Minify_CSS', false)
&& ! class_exists('Minify_Cache', false)
@@ -83,8 +82,8 @@ function test_Minify()
,'maxAge' => 86400
,'encodeOutput' => false
));
$passed = assertTrue($expected === $output, 'Minify : JS and Expires');
$passed = assertTrue($expected === $output, 'Minify : JS and Expires');
if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
echo "\nOutput: " .var_export($output, 1). "\n\n";
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
Minify::setCache();