summaryrefslogtreecommitdiff
path: root/plugins/Minify/extlib/minify/min_unit_tests/test_Minify_HTML.php
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-12-04 12:36:00 -0500
committerCraig Andrews <candrews@integralblue.com>2009-12-04 12:36:00 -0500
commit01b089d9be046db1253cb3bb90e8635b50fddd84 (patch)
tree2a4cee14992807cbe19901743d48bc1447729a35 /plugins/Minify/extlib/minify/min_unit_tests/test_Minify_HTML.php
parent40afc7e9877855272caa5c65fb3575e4420b2966 (diff)
Added minify plugin
Diffstat (limited to 'plugins/Minify/extlib/minify/min_unit_tests/test_Minify_HTML.php')
-rw-r--r--plugins/Minify/extlib/minify/min_unit_tests/test_Minify_HTML.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/plugins/Minify/extlib/minify/min_unit_tests/test_Minify_HTML.php b/plugins/Minify/extlib/minify/min_unit_tests/test_Minify_HTML.php
new file mode 100644
index 000000000..69aeff568
--- /dev/null
+++ b/plugins/Minify/extlib/minify/min_unit_tests/test_Minify_HTML.php
@@ -0,0 +1,59 @@
+<?php
+require_once '_inc.php';
+
+require_once 'Minify/HTML.php';
+require_once 'Minify/CSS.php';
+require_once 'JSMin.php';
+
+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: ", strlen($src), " bytes\n"
+ , "---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
+ } else {
+ echo "\n---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n"
+ , "---Expected: ", strlen($minExpected), " bytes\n\n{$minExpected}\n\n"
+ , "---Source: ", strlen($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: ", strlen($src), " bytes\n"
+ , "---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
+ } else {
+ echo "\n---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n"
+ , "---Expected: ", strlen($minExpected), " bytes\n\n{$minExpected}\n\n"
+ , "---Source: ", strlen($src), " bytes\n\n{$src}\n\n\n";
+ }
+ }
+}
+
+test_HTML();