function test_Minify_JS_ClosureCompiler() { global $thisDir; $src = "\n(function (window, undefined){\n function addOne(input) {\n return 1 + input;\n }\n window.addOne = addOne;\n window.undefined = undefined;\n})(window);\n "; $minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);"; $minOutput = Minify_JS_ClosureCompiler::minify($src); if (false !== strpos($minOutput, 'Error(22): Too many compiles')) { echo "!NOTE: Too many recent calls to Closure Compiler API to test.\n"; return; } $passed = assertTrue($minExpected == $minOutput, 'Minify_JS_ClosureCompiler : Overall'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } $src = "function blah({ return 'blah';} "; $exc = null; try { $minOutput = Minify_JS_ClosureCompiler::minify($src); } catch (Exception $e) { $exc = $e; } $passed = assertTrue($exc instanceof Minify_JS_ClosureCompiler_Exception, 'Minify_JS_ClosureCompiler : Throws Minify_JS_ClosureCompiler_Exception'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Message: " . var_export($exc->getMessage(), 1) . "\n\n\n"; } }
function test_HTML() { global $thisDir; $src = file_get_contents($thisDir . '/_test_files/html/before.html'); $minExpected = file_get_contents($thisDir . '/_test_files/html/before.min.html'); $time = microtime(true); $minOutput = Minify_HTML::minify($src, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify'))); $time = microtime(true) - $time; $passed = assertTrue($minExpected === $minOutput, 'Minify_HTML'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { if ($passed) { echo "\n---Source: ", countBytes($src), " bytes\n", "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n"; } else { echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n", "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n", "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n"; } } $src = file_get_contents($thisDir . '/_test_files/html/before2.html'); $minExpected = file_get_contents($thisDir . '/_test_files/html/before2.min.html'); $time = microtime(true); $minOutput = Minify_HTML::minify($src, array('cssMinifier' => array('Minify_CSS', 'minify'), 'jsMinifier' => array('JSMin', 'minify'))); $time = microtime(true) - $time; $passed = assertTrue($minExpected === $minOutput, 'Minify_HTML'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { if ($passed) { echo "\n---Source: ", countBytes($src), " bytes\n", "---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n"; } else { echo "\n---Output: ", countBytes($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n", "---Expected: ", countBytes($minExpected), " bytes\n\n{$minExpected}\n\n", "---Source: ", countBytes($src), " bytes\n\n{$src}\n\n\n"; } } }
function test_JSMinPlus() { global $thisDir; $src = file_get_contents($thisDir . '/_test_files/js/condcomm.js'); $minExpected = file_get_contents($thisDir . '/_test_files/js/condcomm.min_plus.js'); $minOutput = JSMinPlus::minify($src); $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Conditional Comments'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } return; $src = file_get_contents($thisDir . '/_test_files/js/before.js'); $minExpected = file_get_contents($thisDir . '/_test_files/js/before.min_plus.js'); $minOutput = JSMinPlus::minify($src); $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Overall'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } $src = file_get_contents($thisDir . '/_test_files/js/issue74.js'); $minExpected = file_get_contents($thisDir . '/_test_files/js/issue74.min_plus.js'); $minOutput = JSMinPlus::minify($src); $passed = assertTrue($minExpected == $minOutput, 'JSMinPlus : Quotes in RegExp literals (Issue 74)'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } }
function test_Minify_Cache_File() { $data = str_repeat(md5(time()) . 'í', 100); // 3400 bytes in UTF-8 $id = 'Minify_test_cache_noLock'; $prefix = 'Minify_Cache_File : '; $cache = new Minify_Cache_File(); echo "NOTE: Minify_Cache_File : path is set to: '" . $cache->getPath() . "'.\n"; assertTrue(true === $cache->store($id, $data), $prefix . 'store'); assertTrue(countBytes($data) === $cache->getSize($id), $prefix . 'getSize'); assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid'); ob_start(); $cache->display($id); $displayed = ob_get_contents(); ob_end_clean(); assertTrue($data === $displayed, $prefix . 'display'); assertTrue($data === $cache->fetch($id), $prefix . 'fetch'); // test with locks $id = 'Minify_test_cache_withLock'; $cache = new Minify_Cache_File('', true); assertTrue(true === $cache->store($id, $data), $prefix . 'store w/ lock'); assertTrue(countBytes($data) === $cache->getSize($id), $prefix . 'getSize'); assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid'); ob_start(); $cache->display($id); $displayed = ob_get_contents(); ob_end_clean(); assertTrue($data === $displayed, $prefix . 'display w/ lock'); assertTrue($data === $cache->fetch($id), $prefix . 'fetch w/ lock'); }
function test_Minify_YuiCSS() { if (!is_file(MINIFY_TESTS_YUICOMPRESSOR_JAR_FILE)) { echo " Minify_YUICompressor : To test this, install the .jar file and customize the constant in:\n"; echo " " . __FILE__ . "\n"; return; } Minify_YUICompressor::$jarFile = MINIFY_TESTS_YUICOMPRESSOR_JAR_FILE; Minify_YUICompressor::$tempDir = sys_get_temp_dir(); $src = "/* stack overflow test */\n div.image {\n width: 100px;\n height: 100px;\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAALCAYAAABGbhwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1RDg4RDYwQzU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1RDg4RDYwRDU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkM0RjRBMkZGNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkM0RjRBMzAwNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+2Di36AAAALBJREFUeNpi+P//PwMQ60NpdMwIxAYgNogTBsQHgNgGi0IVIN4CxH4whSDwAk2xLBCvh8odhgmuRlNsCMSboWLHgDgE2Zp5SIrXQNlXgNgI5kZkh9+AKvgGpZWAmAUkz8SAADxAfAfK5oTS7ED8B8yCmqYOxOuA+AcQXwDiJVATn8I8CFIUCA0CmMNNoZqXILnZHiQQjeRwU7RwhCk+xAB17A4gdgFiNiyBDlKcBBBgAG/qVav+VuC1AAAAAElFTkSuQmCC');\n }\n "; $minExpected = "div.image{width:100px;height:100px;background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAALCAYAAABGbhwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDo1RDg4RDYwQzU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDo1RDg4RDYwRDU2N0ExMUUyOUNCMEY5NzdDNzlGNzg3MSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkM0RjRBMkZGNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkM0RjRBMzAwNTY3NzExRTI5Q0IwRjk3N0M3OUY3ODcxIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+2Di36AAAALBJREFUeNpi+P//PwMQ60NpdMwIxAYgNogTBsQHgNgGi0IVIN4CxH4whSDwAk2xLBCvh8odhgmuRlNsCMSboWLHgDgE2Zp5SIrXQNlXgNgI5kZkh9+AKvgGpZWAmAUkz8SAADxAfAfK5oTS7ED8B8yCmqYOxOuA+AcQXwDiJVATn8I8CFIUCA0CmMNNoZqXILnZHiQQjeRwU7RwhCk+xAB17A4gdgFiNiyBDlKcBBBgAG/qVav+VuC1AAAAAElFTkSuQmCC')}"; // fails with java.lang.StackOverflowError as of Yui 2.4.6 // unfortunately error output is not caught from yui, so have to guess try { $minOutput = Minify_YUICompressor::minifyCss($src); echo " Minify_YUICompressor : Correctly handles input which caused stack overflow in 2.4.6\n"; } catch (Exception $e) { assertTrue($e->getMessage() == 'Minify_YUICompressor : YUI compressor execution failed.', 'Minify_YUICompressor : got expected Exception'); } try { $options = array('stack-size' => '2m'); $minOutput = Minify_YUICompressor::minifyCss($src, $options); } catch (Exception $e) { assertTrue(false, $e->getMessage()); $minOutput = false; } $passed = assertTrue($minExpected == $minOutput, 'Minify_YUICompressor : Overall'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } }
function test_Minify_CSS_UriRewriter() { global $thisDir; Minify_CSS_UriRewriter::$debugText = ''; $in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css'); $expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp.css'); $actual = Minify_CSS_UriRewriter::rewrite($in, $thisDir . '/_test_files/css_uriRewriter', $thisDir); $passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter : rewrite'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Input:\n\n{$in}\n"; echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n"; } // show debugging only when test run directly echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText; } Minify_CSS_UriRewriter::$debugText = ''; $in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css'); $expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp_prepend.css'); $actual = Minify_CSS_UriRewriter::prepend($in, 'http://cnd.com/A/B/'); $passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter : prepend1'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Input:\n\n{$in}\n"; echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n"; } // show debugging only when test run directly echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText; } Minify_CSS_UriRewriter::$debugText = ''; $in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css'); $expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp_prepend2.css'); $actual = Minify_CSS_UriRewriter::prepend($in, '//cnd.com/A/B/'); $passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter : prepend2'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Input:\n\n{$in}\n"; echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n"; } // show debugging only when test run directly echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText; } Minify_CSS_UriRewriter::$debugText = ''; $in = '../../../../assets/skins/sam/sprite.png'; $exp = '/yui/assets/skins/sam/sprite.png'; $actual = Minify_CSS_UriRewriter::rewriteRelative($in, 'sf_root_dir\\web\\yui\\menu\\assets\\skins\\sam', 'sf_root_dir\\web'); $passed = assertTrue($exp === $actual, 'Minify_CSS_UriRewriter : Issue 99'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Input:\n\n{$in}\n"; echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($exp) . " bytes\n\n{$exp}\n\n\n"; } // show debugging only when test run directly echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText; } }
function test_JSMin() { global $thisDir; $src = file_get_contents($thisDir . '/_test_files/js/before.js'); $minExpected = file_get_contents($thisDir . '/_test_files/js/before.min.js'); $minOutput = JSMin::minify($src); assertTrue($minExpected == $minOutput, 'JSMin : Overall'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } $src = file_get_contents($thisDir . '/_test_files/js/issue144.js'); $minExpected = file_get_contents($thisDir . '/_test_files/js/issue144.min.js'); $minOutput = JSMin::minify($src); assertTrue($minExpected == $minOutput, 'JSMin : Handle "+ ++a" syntax (Issue 144)'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } $src = file_get_contents($thisDir . '/_test_files/js/issue256.js'); $minExpected = file_get_contents($thisDir . '/_test_files/js/issue256.min.js'); $minOutput = JSMin::minify($src); assertTrue($minExpected == $minOutput, 'JSMin : Handle \\n!function()... (Issue 256)'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } if (function_exists('mb_strlen') && (int) ini_get('mbstring.func_overload') & 2) { $src = file_get_contents($thisDir . '/_test_files/js/issue132.js'); $minExpected = file_get_contents($thisDir . '/_test_files/js/issue132.min.js'); $minOutput = JSMin::minify($src); assertTrue($minExpected == $minOutput, 'JSMin : mbstring.func_overload shouldn\'t cause failure (Issue 132)'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } } $src = file_get_contents($thisDir . '/_test_files/js/regexes.js'); $minExpected = file_get_contents($thisDir . '/_test_files/js/regexes.min.js'); $minOutput = JSMin::minify($src); assertTrue($minExpected == $minOutput, 'JSMin : Identify RegExp literals'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } test_JSMin_exception('"Hello', 'Unterminated String', 'JSMin_UnterminatedStringException', "JSMin: Unterminated String at byte 5: \"Hello"); test_JSMin_exception("return /regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 14: /regexp\n"); test_JSMin_exception("return/regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 13: /regexp\n"); test_JSMin_exception(";return/regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 14: /regexp\n"); test_JSMin_exception(";return /regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 15: /regexp\n"); test_JSMin_exception("typeof/regexp\n}", 'Unterminated RegExp', 'JSMin_UnterminatedRegExpException', "JSMin: Unterminated RegExp at byte 13: /regexp\n"); test_JSMin_exception("/* Comment ", 'Unterminated Comment', 'JSMin_UnterminatedCommentException', "JSMin: Unterminated comment at byte 11: /* Comment "); }
function countStrings($in) { $list = explode("\n", $in); $tot = 0; foreach ($list as $str) { if (!$str) { continue; } $code = countCode($str); $bytes = countBytes($str); $tot -= $code; $tot += $bytes; } echo "Tot is {$tot}\n"; }
function test_Minify_CommentPreserver() { global $thisDir; $inOut = array('/*!*/' => "\n/*!*/\n", '/*!*/a' => "\n/*!*/\n1A", 'a/*!*//*!*/b' => "2A\n/*!*/\n\n/*!*/\n3B", 'a/*!*/b/*!*/' => "4A\n/*!*/\n5B\n/*!*/\n"); foreach ($inOut as $in => $expected) { $actual = Minify_CommentPreserver::process($in, '_test_MCP_processor'); $passed = assertTrue($expected === $actual, 'Minify_CommentPreserver'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n"; } } } }
function test_Lines() { global $thisDir; $exp = file_get_contents("{$thisDir}/_test_files/minify/lines_output.js"); Minify::setCache(null); // no cache $ret = Minify::serve('Files', array('debug' => true, 'quiet' => true, 'encodeOutput' => false, 'files' => array("{$thisDir}/_test_files/minify/email.js", "{$thisDir}/_test_files/minify/lines_bugs.js", "{$thisDir}/_test_files/minify/QueryString.js", "{$thisDir}/_test_files/js/before.js"))); $passed = assertTrue($exp === $ret['content'], 'Minify_Lines'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($ret['content']) . " bytes\n\n{$ret['content']}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($exp) . " bytes\n\n{$exp}\n\n\n"; } } }
function test_Minify_ImportProcessor() { global $thisDir; $linDir = $thisDir . '/_test_files/importProcessor'; $expected = file_get_contents($linDir . '/css/output.css'); $actual = Minify_ImportProcessor::process($linDir . '/css/input.css'); $passed = assertTrue($expected === $actual, 'ImportProcessor'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n"; } } $expectedIncludes = array(realpath($linDir . '/css/input.css'), realpath($linDir . '/css/adjacent.css'), realpath($linDir . '/../css/styles.css'), realpath($linDir . '/css/1/tv.css'), realpath($linDir . '/css/1/adjacent.css'), realpath($linDir . '/lib/css/example.css')); $passed = assertTrue($expectedIncludes === Minify_ImportProcessor::$filesIncluded, 'ImportProcessor : included right files in right order'); }
function test_Minify_ClosureCompiler() { global $thisDir; Minify_ClosureCompiler::$isDebug = true; // --- Test minification w/o setting the necessary settings --- try { Minify_ClosureCompiler::minify(''); } catch (Exception $e) { $exc = $e; } $passed = assertTrue($exc instanceof Minify_ClosureCompiler_Exception, 'Minify_ClosureCompiler : Throws Minify_ClosureCompiler_Exception'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Message: " . var_export($exc->getMessage(), 1) . "\n\n\n"; } $compiler_jar_path = __DIR__ . DIRECTORY_SEPARATOR . 'compiler.jar'; if (is_file($compiler_jar_path)) { // set minimum necessary settings Minify_ClosureCompiler::$jarFile = $compiler_jar_path; Minify_ClosureCompiler::$tempDir = sys_get_temp_dir(); // --- Test minification with the minimum necessary settings --- $src = "\n (function (window, undefined){\n function addOne(input) {\n return 1 + input;\n }\n window.addOne = addOne;\n window.undefined = undefined;\n })(window);\n "; $minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);"; $minOutput = Minify_ClosureCompiler::minify($src); $passed = assertTrue($minExpected == $minOutput, 'Minify_ClosureCompiler : minimum necessary settings'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } // --- Test minification with advanced compilation level --- $src = "function unused() {};"; $minExpected = ''; $minOutput = Minify_ClosureCompiler::minify($src, array(Minify_ClosureCompiler::OPTION_COMPILATION_LEVEL => 'ADVANCED_OPTIMIZATIONS')); $passed = assertTrue($minExpected == $minOutput, 'Minify_ClosureCompiler : advanced optimizations'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } } else { echo " Minify_ClosureCompiler : To test more functionality, download a compiler.jar from\n"; echo " https://code.google.com/p/closure-compiler/wiki/BinaryDownloads,\n"; echo " put it under '{$compiler_jar_path}',\n"; echo " and make it readable by your webserver\n"; } }
function test_Lines() { global $thisDir; $exp = file_get_contents("{$thisDir}/_test_files/minify/lines_output.js"); $env = new Minify_Env(); $sourceFactory = new Minify_Source_Factory($env, array(), new Minify_Cache_Null()); $controller = new Minify_Controller_Files($env, $sourceFactory); $minify = new Minify(new Minify_Cache_Null()); $ret = $minify->serve($controller, array('debug' => true, 'quiet' => true, 'encodeOutput' => false, 'files' => array("{$thisDir}/_test_files/js/before.js"))); $passed = assertTrue($exp === $ret['content'], 'Minify_Lines'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($ret['content']) . " bytes\n\n{$ret['content']}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($exp) . " bytes\n\n{$exp}\n\n\n"; } } }
function test_Minify_ImportProcessor() { global $thisDir; $linDir = $thisDir . '/_test_files/importProcessor'; $testFilesUri = substr(realpath($thisDir . '/_test_files'), strlen(realpath($_SERVER['DOCUMENT_ROOT']))); $testFilesUri = str_replace('\\', '/', $testFilesUri); $expected = str_replace('%TEST_FILES_URI%', $testFilesUri, file_get_contents($linDir . '/output.css')); $actual = Minify_ImportProcessor::process($linDir . '/input.css'); $passed = assertTrue($expected === $actual, 'ImportProcessor'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($actual) . " bytes\n\n{$actual}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($expected) . " bytes\n\n{$expected}\n\n\n"; } } $expectedIncludes = array(realpath($linDir . '/input.css'), realpath($linDir . '/adjacent.css'), realpath($linDir . '/../css/styles.css'), realpath($linDir . '/1/tv.css'), realpath($linDir . '/1/adjacent.css')); $passed = assertTrue($expectedIncludes === Minify_ImportProcessor::$filesIncluded, 'ImportProcessor : included right files in right order'); }
/** * Prints a test result */ function test($file, $minExpected, $skip) { global $cssmin; if (!empty($skip) && in_array(basename($file), $skip)) { p("INFO: CSSmin: skipping " . basename($file), 'info'); return; } $src = file_get_contents($file); $minOutput = $cssmin->run($src); $passed = assertTrue(strcmp($minOutput, $minExpected) === 0, 'CSSmin: ' . basename(dirname($file)) . '/' . basename($file)); if (!$passed) { p("---Output: " . countBytes($minOutput) . " bytes", ''); $opcodes = FineDiff::getDiffOpcodes($minExpected, $minOutput); code(FineDiff::renderDiffToHTMLFromOpcodes($minExpected, $opcodes)); p("---Expected: " . countBytes($minExpected) . " bytes", ''); code($minExpected); p("---Source: " . countBytes($src) . " bytes", ''); code($src); } }
function test_Minify_Cache_APC() { $prefix = 'Minify_Cache_APC : '; if (!function_exists('apc_store')) { return; } $data = str_repeat(md5(time()) . 'í', 100); // 3400 bytes in UTF-8 $id = 'Minify_test_cache'; $cache = new Minify_Cache_APC(); assertTrue(true === $cache->store($id, $data), $prefix . 'store'); assertTrue(countBytes($data) === $cache->getSize($id), $prefix . 'getSize'); assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid'); ob_start(); $cache->display($id); $displayed = ob_get_contents(); ob_end_clean(); assertTrue($data === $displayed, $prefix . 'display'); assertTrue($data === $cache->fetch($id), $prefix . 'fetch'); }
function test_CSSmin() { $files = glob(dirname(__FILE__) . '/_test_files/yuic/*.css'); // some tests may exhaust memory/stack due to string size/PCRE $skip = array(); $cssmin = new CSSmin(); foreach ($files as $file) { if (!empty($skip) && in_array(basename($file), $skip)) { echo "INFO: CSSmin: skipping " . basename($file) . "\n"; continue; } $src = file_get_contents($file); $minExpected = trim(file_get_contents($file . '.min')); $minOutput = trim($cssmin->run($src)); $passed = assertTrue($minExpected == $minOutput, 'CSSmin : ' . basename($file)); if (!$passed && __FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } } }
function test_CSS() { global $thisDir; $cssPath = dirname(__FILE__) . '/_test_files/css'; // build test file list $d = dir($cssPath); while (false !== ($entry = $d->read())) { if (preg_match('/^([\\w\\-]+)\\.css$/', $entry, $m)) { $list[] = $m[1]; } } $d->close(); foreach ($list as $item) { $options = array(); if ($item === 'paths_prepend') { $options = array('prependRelativePath' => '../'); } elseif ($item === 'paths_rewrite') { $options = array('currentDir' => $thisDir . '/_test_files/css'); $tempDocRoot = $_SERVER['DOCUMENT_ROOT']; $_SERVER['DOCUMENT_ROOT'] = $thisDir; } $src = file_get_contents($cssPath . "/{$item}.css"); $minExpected = file_get_contents($cssPath . "/{$item}.min.css"); $minOutput = Minify_CSS::minify($src, $options); // reset doc root as configured if ($item === 'paths_rewrite') { $_SERVER['DOCUMENT_ROOT'] = $tempDocRoot; } $passed = assertTrue($minExpected === $minOutput, 'Minify_CSS : ' . $item); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; if (!$passed) { echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } } } }
function test_Minify_Cache_Memcache() { $prefix = 'Minify_Cache_Memcache : '; $thisFileActive = __FILE__ === realpath($_SERVER['SCRIPT_FILENAME']); if (!function_exists('memcache_set')) { if ($thisFileActive) { echo " {$prefix}To test this component, install memcache in PHP\n"; } return; } $mc = new Memcache(); if (!@$mc->connect('localhost', 11211)) { if ($thisFileActive) { echo " {$prefix}Memcache server not found on localhost:11211\n"; } return; } $data = str_repeat(md5(time()) . 'í', 100); // 3400 bytes in UTF-8 $id = 'Minify_test_memcache'; $cache = new Minify_Cache_Memcache($mc); assertTrue(true === $cache->store($id, $data), $prefix . 'store'); assertTrue(countBytes($data) === $cache->getSize($id), $prefix . 'getSize'); assertTrue(true === $cache->isValid($id, $_SERVER['REQUEST_TIME'] - 10), $prefix . 'isValid'); ob_start(); $cache->display($id); $displayed = ob_get_contents(); ob_end_clean(); assertTrue($data === $displayed, $prefix . 'display'); assertTrue($data === $cache->fetch($id), $prefix . 'fetch'); if (function_exists('gzencode')) { $data = gzencode($data); $id .= ".gz"; $cache->store($id, $data); assertTrue($data === $cache->fetch($id), $prefix . 'store/fetch gzencoded string'); } }
function test_Minify_JS_ClosureCompiler() { global $thisDir; $src = "\n(function (window, undefined){\n function addOne(input) {\n return 1 + input;\n }\n window.addOne = addOne;\n window.undefined = undefined;\n})(window);\n "; $minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);"; $minOutput = Minify_JS_ClosureCompiler::minify($src); if (false !== strpos($minOutput, 'Error(22): Too many compiles')) { echo "!---: Minify_JS_ClosureCompiler : Too many recent calls to Closure Compiler API to test.\n"; return; } $passed = assertTrue($minExpected == $minOutput, 'Minify_JS_ClosureCompiler : Overall'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Output: " . countBytes($minOutput) . " bytes\n\n{$minOutput}\n\n"; echo "---Expected: " . countBytes($minExpected) . " bytes\n\n{$minExpected}\n\n"; echo "---Source: " . countBytes($src) . " bytes\n\n{$src}\n\n\n"; } $src = "function blah({ return 'blah';} "; $exc = null; try { $minOutput = Minify_JS_ClosureCompiler::minify($src); } catch (Exception $e) { $exc = $e; } $passed = assertTrue($exc instanceof Minify_JS_ClosureCompiler_Exception, 'Minify_JS_ClosureCompiler : Throws Minify_JS_ClosureCompiler_Exception'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Message: " . var_export($exc->getMessage(), 1) . "\n\n\n"; } // Test maximum byte size check (default) $fn = "(function() {})();"; $src = str_repeat($fn, ceil(Minify_JS_ClosureCompiler::DEFAULT_MAX_BYTES / strlen($fn))); $exc = null; try { $minOutput = Minify_JS_ClosureCompiler::minify($src); } catch (Exception $e) { $exc = $e; } $passed = assertTrue($exc instanceof Minify_JS_ClosureCompiler_Exception, 'Minify_JS_ClosureCompiler : Throws Minify_JS_ClosureCompiler_Exception'); assertTrue($exc->getMessage() === 'POST content larger than ' . Minify_JS_ClosureCompiler::DEFAULT_MAX_BYTES . ' bytes', 'Minify_JS_ClosureCompiler : Message must tell how big maximum byte size is'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Message: " . var_export($exc->getMessage(), 1) . "\n\n\n"; } // Test maximum byte size check (no limit) $src = "(function(){})();"; try { $minOutput = Minify_JS_ClosureCompiler::minify($src, array(Minify_JS_ClosureCompiler::OPTION_MAX_BYTES => 0)); } catch (Exception $e) { $exc = $e; } $passed = assertTrue($src === $minOutput, 'Minify_JS_ClosureCompiler : With no limit set, it should compile properly'); // Test maximum byte size check (custom) $src = "(function() {})();"; $allowedBytes = 5; $exc = null; try { $minOutput = Minify_JS_ClosureCompiler::minify($src, array(Minify_JS_ClosureCompiler::OPTION_MAX_BYTES => $allowedBytes)); } catch (Exception $e) { $exc = $e; } $passed = assertTrue($exc instanceof Minify_JS_ClosureCompiler_Exception, 'Minify_JS_ClosureCompiler : Throws Minify_JS_ClosureCompiler_Exception'); assertTrue($exc->getMessage() === 'POST content larger than ' . $allowedBytes . ' bytes', 'Minify_JS_ClosureCompiler : Message must tell how big maximum byte size is'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Message: " . var_export($exc->getMessage(), 1) . "\n\n\n"; } // Test additional options passed to HTTP request $ecmascript5 = "[1,].length;"; $exc = null; try { $minOutput = Minify_JS_ClosureCompiler::minify($ecmascript5); } catch (Exception $e) { $exc = $e; } $passed = assertTrue($exc instanceof Minify_JS_ClosureCompiler_Exception, 'Minify_JS_ClosureCompiler : Throws Minify_JS_ClosureCompiler_Exception'); if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) { echo "\n---Message: " . var_export($exc->getMessage(), 1) . "\n\n\n"; } $minExpected = '1;'; $minOutput = Minify_JS_ClosureCompiler::minify($ecmascript5, array(Minify_JS_ClosureCompiler::OPTION_ADDITIONAL_OPTIONS => array('language' => 'ECMASCRIPT5'))); $passed = assertTrue($minOutput === $minExpected, 'Minify_JS_ClosureCompiler : Language option should make it compile'); }
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; // Test 304 response // simulate conditional headers $_SERVER['HTTP_IF_NONE_MATCH'] = "\"{$lastModified}pub\""; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = gmdate('D, d M Y H:i:s \\G\\M\\T', $lastModified); $expected = array('success' => true, 'statusCode' => 304, 'content' => '', 'headers' => array('Expires' => gmdate('D, d M Y H:i:s \\G\\M\\T', $_SERVER['REQUEST_TIME'] + 1800), 'Vary' => 'Accept-Encoding', 'Last-Modified' => gmdate('D, d M Y H:i:s \\G\\M\\T', $lastModified), 'ETag' => "\"pub{$lastModified}\"", 'Cache-Control' => 'max-age=1800', '_responseCode' => 'HTTP/1.0 304 Not Modified')); $output = Minify::serve('Files', array('files' => $thisDir . '/_test_files/css/styles.css', 'quiet' => true, 'lastModifiedTime' => $lastModified, 'encodeOutput' => false)); $passed = assertTrue($expected === $output, 'Minify : 304 response'); if ($thisFileActive) { echo "\nOutput: " . var_export($output, 1) . "\n\n"; if (!$passed) { echo "\n\n\n\n---Expected: " . var_export($expected, 1) . "\n\n"; } } assertTrue(!class_exists('Minify_CSS', false) && !class_exists('Minify_Cache_File', false), 'Minify : cache, and minifier classes aren\'t loaded for 304s'); // Test JS and Expires $content = preg_replace('/\\r\\n?/', "\n", file_get_contents($minifyTestPath . '/minified.js')); $lastModified = max(filemtime($minifyTestPath . '/email.js'), filemtime($minifyTestPath . '/QueryString.js')); $expected = array('success' => true, 'statusCode' => 200, 'content' => $content, 'headers' => array('Expires' => gmdate('D, d M Y H:i:s \\G\\M\\T', $tomorrow), 'Vary' => 'Accept-Encoding', 'Last-Modified' => gmdate('D, d M Y H:i:s \\G\\M\\T', $lastModified), 'ETag' => "\"pub{$lastModified}\"", 'Cache-Control' => 'max-age=86400', 'Content-Length' => countBytes($content), 'Content-Type' => 'application/x-javascript; charset=utf-8')); unset($_SERVER['HTTP_IF_NONE_MATCH']); unset($_SERVER['HTTP_IF_MODIFIED_SINCE']); $output = Minify::serve('Files', array('files' => array($minifyTestPath . '/email.js', $minifyTestPath . '/QueryString.js'), 'quiet' => true, 'maxAge' => 86400, 'encodeOutput' => false)); $passed = assertTrue($expected === $output, 'Minify : JS and Expires'); if ($thisFileActive) { echo "\nOutput: " . var_export($output, 1) . "\n\n"; if (!$passed) { echo "\n\n\n\n---Expected: " . var_export($expected, 1) . "\n\n"; } } // 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 ($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"; } } // Test Issue 132 if (function_exists('mb_strlen') && (int) ini_get('mbstring.func_overload') & 2) { $output = Minify::serve('Files', array('files' => array(dirname(__FILE__) . '/_test_files/js/issue132.js'), 'quiet' => true, 'encodeOutput' => false)); $passed = assertTrue($output['headers']['Content-Length'] == 77, 'Minify : Issue 132 : mbstring.func_overload shouldn\'t cause incorrect Content-Length'); } // Test minifying CSS and responding with Etag/Last-Modified // don't allow conditional headers unset($_SERVER['HTTP_IF_NONE_MATCH'], $_SERVER['HTTP_IF_MODIFIED_SINCE']); $expectedContent = file_get_contents($minifyTestPath . '/minified.css'); $expected = array('success' => true, 'statusCode' => 200, 'content' => $expectedContent, 'headers' => array('Vary' => 'Accept-Encoding', 'Last-Modified' => gmdate('D, d M Y H:i:s \\G\\M\\T', $lastModified), 'ETag' => "\"pub{$lastModified}\"", 'Cache-Control' => 'max-age=0', 'Content-Length' => countBytes($expectedContent), 'Content-Type' => 'text/css; charset=utf-8')); $output = Minify::serve('Files', array('files' => array($thisDir . '/_test_files/css/styles.css', $thisDir . '/_test_files/css/comments.css'), 'quiet' => true, 'lastModifiedTime' => $lastModified, 'encodeOutput' => false, 'maxAge' => false)); $passed = assertTrue($expected === $output, 'Minify : CSS and Etag/Last-Modified'); if ($thisFileActive) { echo "\nOutput: " . var_export($output, 1) . "\n\n"; if (!$passed) { echo "\n\n\n\n---Expected: " . var_export($expected, 1) . "\n\n"; } } }
?> </p> </section> <section class="numberContainer"> <span class="top">Median Job Size </span> <p><?php echo getMedium($quotes); ?> </p> </section> <section class="numberContainer"> <span class="top">MB of Customer Files </span> <p> <?php echo $filesSize = countBytes($quotes); ?> </p> </section> <section class="numberContainer"> <span class="top">Number of Customers</span> <p> <?php echo $filesSize = countCust($quotes); ?> </p> </section> <br class="clear" /> <?php $textMonths = array("Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"); $textDays = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
echo $Theyear; ?> </span> <p><?php echo getMedium($monthlyQuotes); ?> </p> </section> <section class="numberContainer"> <span class="top">MB of Customer Files in <?php echo $Theyear; ?> </span> <p> <?php echo $filesSize = countBytes($monthlyQuotes); ?> </p> </section> <section class="numberContainer"> <span class="top">Number of Customers in <?php echo $Theyear; ?> </span> <p> <?php echo $filesSize = countCust($monthlyQuotes); ?> </p> </section> <br class="clear" />
echo $textMonths[$currentMonth - 1]; ?> </span> <p><?php echo getMedium($testing); ?> </p> </section> <section class="numberContainer"> <span class="top">MB of Customer Files in <?php echo $textMonths[$currentMonth - 1]; ?> </span> <p> <?php echo $filesSize = countBytes($testing); ?> </p> </section> <section class="numberContainer"> <span class="top">Number of Customers in <?php echo $textMonths[$currentMonth - 1]; ?> </span> <p> <?php echo $filesSize = countCust($testing); ?> </p> </section> <?php