forked from mrclay/minify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_Minify_HTML_Helper.php
68 lines (52 loc) · 2.39 KB
/
test_Minify_HTML_Helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
require_once '_inc.php';
require_once 'Minify/HTML/Helper.php';
function test_Minify_HTML_Helper()
{
global $thisDir;
$realDocRoot = $_SERVER['DOCUMENT_ROOT'];
$_SERVER['DOCUMENT_ROOT'] = $thisDir;
$file1 = $thisDir . '/_test_files/css/paths_prepend.css';
$file2 = $thisDir . '/_test_files/css/styles.css';
$maxTime = max(filemtime($file1), filemtime($file2));
$uri1 = '//_test_files/css/paths_prepend.css';
$uri2 = '//_test_files/css/styles.css';
$expected = "/min/b=_test_files/css&f=paths_prepend.css,styles.css&{$maxTime}";
$actual = Minify_HTML_Helper::getUri(array($uri1, $uri2));
$passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : given URIs');
$expected = "/min/b=_test_files/css&f=paths_prepend.css,styles.css&{$maxTime}";
$actual = Minify_HTML_Helper::getUri(array($file1, $file2));
$passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : given filepaths');
$expected = "/min/g=notRealGroup&debug";
$actual = Minify_HTML_Helper::getUri('notRealGroup', array('debug' => true));
$passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : non-existent group & debug');
$expected = "/myApp/min/?g=css&{$maxTime}";
$actual = Minify_HTML_Helper::getUri('css', array(
'rewriteWorks' => false
,'minAppUri' => '/myApp/min/'
,'groupsConfigFile' => $thisDir . '/_test_files/htmlHelper_groupsConfig.php'
));
$passed = assertTrue($actual === $expected, 'Minify_HTML_Helper : existing group');
$utilsFile = dirname(dirname(__FILE__)) . '/min/utils.php';
if (is_file($utilsFile)) {
require_once $utilsFile;
$fiveSecondsAgo = $_SERVER['REQUEST_TIME'] - 5;
$obj = new stdClass();
$obj->lastModified = $fiveSecondsAgo;
$output = Minify_mtime(array(
$uri1
,$uri2
,$obj
));
$passed = assertTrue($output === $fiveSecondsAgo, 'utils.php : Minify_mtime w/ files & obj');
$obj = new stdClass();
$obj->lastModified = strtotime('2000-01-01');
$output = Minify_mtime(array(
$obj
,'css'
), $thisDir . '/_test_files/htmlHelper_groupsConfig.php');
$passed = assertTrue($output === $maxTime, 'utils.php : Minify_mtime w/ obj & group');
}
$_SERVER['DOCUMENT_ROOT'] = $realDocRoot;
}
test_Minify_HTML_Helper();