diff --git a/min_unit_tests/test_Minify_HTML_Helper.php b/min_unit_tests/test_Minify_HTML_Helper.php deleted file mode 100644 index 47ea1ac..0000000 --- a/min_unit_tests/test_Minify_HTML_Helper.php +++ /dev/null @@ -1,72 +0,0 @@ - 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(__DIR__) . '/min/utils.php'; - if (is_file($utilsFile)) { - require_once $utilsFile; - - $fiveSecondsAgo = $_SERVER['REQUEST_TIME'] - 5; - $obj = new Minify_Source(array( - 'id' => '1', - 'content' => '1', - 'lastModified' => $fiveSecondsAgo, - )); - - $output = Minify_mtime(array( - $uri1 - ,$uri2 - ,$obj - )); - $passed = assertTrue($output === $fiveSecondsAgo, 'utils.php : Minify_mtime w/ files & obj'); - - $obj = new Minify_Source(array( - 'id' => '2', - 'content' => '2', - '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(); \ No newline at end of file diff --git a/min_unit_tests/test_all.php b/min_unit_tests/test_all.php index 7197c4c..b4e5436 100644 --- a/min_unit_tests/test_all.php +++ b/min_unit_tests/test_all.php @@ -1,7 +1,6 @@ realDocRoot = $_SERVER['DOCUMENT_ROOT']; + $_SERVER['DOCUMENT_ROOT'] = self::$document_root; + } + + // TODO: this is probably not needed if backupGlobals is enabled? + public function tearDown() + { + $_SERVER['DOCUMENT_ROOT'] = $this->realDocRoot; + } + + public function test1() + { + $file1 = self::$test_files . '/css/paths_prepend.css'; + $file2 = self::$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)); + $this->assertEquals($expected, $actual, 'given URIs'); + + $expected = "/min/b=_test_files/css&f=paths_prepend.css,styles.css&{$maxTime}"; + $actual = Minify_HTML_Helper::getUri(array($file1, $file2)); + $this->assertEquals($expected, $actual, 'given filepaths'); + + $expected = "/min/g=notRealGroup&debug"; + $actual = Minify_HTML_Helper::getUri('notRealGroup', array('debug' => true)); + $this->assertEquals($expected, $actual, 'non-existent group & debug'); + + $expected = "/myApp/min/?g=css&{$maxTime}"; + $actual = Minify_HTML_Helper::getUri('css', array( + 'rewriteWorks' => false + , 'minAppUri' => '/myApp/min/' + , 'groupsConfigFile' => self::$test_files . '/htmlHelper_groupsConfig.php' + )); + $this->assertEquals($expected, $actual, 'existing group'); + + + $utilsFile = dirname(__DIR__) . '/min/utils.php'; + if (is_file($utilsFile)) { + require_once $utilsFile; + + $fiveSecondsAgo = $_SERVER['REQUEST_TIME'] - 5; + $obj = new Minify_Source(array( + 'id' => '1', + 'content' => '1', + 'lastModified' => $fiveSecondsAgo, + )); + + $output = Minify_mtime(array($uri1, $uri2, $obj)); + $this->assertEquals($fiveSecondsAgo, $output, 'utils.php : Minify_mtime w/ files & obj'); + + $obj = new Minify_Source(array( + 'id' => '2', + 'content' => '2', + 'lastModified' => strtotime('2000-01-01'), + )); + $output = Minify_mtime(array( + $obj + , 'css' + ), self::$test_files . '/htmlHelper_groupsConfig.php'); + $this->assertEquals($maxTime, $output, 'utils.php : Minify_mtime w/ obj & group'); + } + } +} \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php index 0653a82..6891dbe 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,12 +2,15 @@ class TestCase extends PHPUnit_Framework_TestCase { + /** @var string */ + protected static $document_root; /** @var string */ protected static $test_files; public static function setupBeforeClass() { - self::$test_files = __DIR__ . '/../min_unit_tests/_test_files'; + self::$document_root = __DIR__ . '/../min_unit_tests'; + self::$test_files = self::$document_root . '/_test_files'; } /**