]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Minify/extlib/minify/min_unit_tests/test_Minify_HTML.php
Added minify plugin
[quix0rs-gnu-social.git] / plugins / Minify / extlib / minify / min_unit_tests / test_Minify_HTML.php
1 <?php
2 require_once '_inc.php';
3
4 require_once 'Minify/HTML.php';
5 require_once 'Minify/CSS.php';
6 require_once 'JSMin.php';
7
8 function test_HTML()
9 {
10     global $thisDir;
11     
12     $src = file_get_contents($thisDir . '/_test_files/html/before.html');
13     $minExpected = file_get_contents($thisDir . '/_test_files/html/before.min.html');
14     
15     $time = microtime(true);
16     $minOutput = Minify_HTML::minify($src, array(
17         'cssMinifier' => array('Minify_CSS', 'minify')
18         ,'jsMinifier' => array('JSMin', 'minify')
19     ));
20     $time = microtime(true) - $time;
21     
22     $passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
23     
24     if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
25         if ($passed) {
26             echo "\n---Source: ", strlen($src), " bytes\n"
27                , "---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
28         } else {
29             echo "\n---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n"
30                , "---Expected: ", strlen($minExpected), " bytes\n\n{$minExpected}\n\n"
31                , "---Source: ", strlen($src), " bytes\n\n{$src}\n\n\n";
32         }
33     }
34     
35     $src = file_get_contents($thisDir . '/_test_files/html/before2.html');
36     $minExpected = file_get_contents($thisDir . '/_test_files/html/before2.min.html');
37     
38     $time = microtime(true);
39     $minOutput = Minify_HTML::minify($src, array(
40         'cssMinifier' => array('Minify_CSS', 'minify')
41         ,'jsMinifier' => array('JSMin', 'minify')
42     ));
43     $time = microtime(true) - $time;
44     
45     $passed = assertTrue($minExpected === $minOutput, 'Minify_HTML');
46     
47     if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
48         if ($passed) {
49             echo "\n---Source: ", strlen($src), " bytes\n"
50                , "---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n\n";
51         } else {
52             echo "\n---Output: ", strlen($minOutput), " bytes (", round($time * 1000), " ms)\n\n{$minOutput}\n\n"
53                , "---Expected: ", strlen($minExpected), " bytes\n\n{$minExpected}\n\n"
54                , "---Source: ", strlen($src), " bytes\n\n{$src}\n\n\n";
55         }
56     }
57 }
58
59 test_HTML();