From c387014e273736693f32bb5106958ce09026974d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Wed, 20 Jan 2016 13:21:11 +0200 Subject: [PATCH] add test for #500 --- groupsConfig.php | 2 +- tests/LessSourceTest.php | 40 +++++++++++++++++++ tests/_test_files/htmlHelper_groupsConfig.php | 10 +++-- tests/_test_files/included.less | 1 + tests/_test_files/main.less | 33 +++++++++++++++ 5 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 tests/LessSourceTest.php create mode 100644 tests/_test_files/included.less create mode 100644 tests/_test_files/main.less diff --git a/groupsConfig.php b/groupsConfig.php index fee7b44..c4cb4b0 100644 --- a/groupsConfig.php +++ b/groupsConfig.php @@ -4,7 +4,7 @@ * @package Minify */ -/** +/** * You may wish to use the Minify URI Builder app to suggest * changes. http://yourdomain/min/builder/ * diff --git a/tests/LessSourceTest.php b/tests/LessSourceTest.php new file mode 100644 index 0000000..f61045c --- /dev/null +++ b/tests/LessSourceTest.php @@ -0,0 +1,40 @@ +realDocRoot = $_SERVER['DOCUMENT_ROOT']; + $_SERVER['DOCUMENT_ROOT'] = self::$document_root; + } + + /** + * @link https://github.com/mrclay/minify/issues/500 + */ + public function testLessTimestamp() + { + $baseDir = self::$test_files; + + $mainLess = "$baseDir/main.less"; + $includedLess = "$baseDir/included.less"; + + // touch timestamp with 1s difference + touch($mainLess); + sleep(1); + touch($includedLess); + + $mtime1 = filemtime($mainLess); + var_dump($mtime1); + $mtime2 = filemtime($includedLess); + var_dump($mtime2); + + $max = max($mtime1, $mtime2); + + $options = array( + 'groupsConfigFile' => "$baseDir/htmlHelper_groupsConfig.php", + ); + $res = Minify_HTML_Helper::getUri('less', $options); + + $this->assertEquals("/min/g=less&{$max}", $res); + } +} \ No newline at end of file diff --git a/tests/_test_files/htmlHelper_groupsConfig.php b/tests/_test_files/htmlHelper_groupsConfig.php index 7f5153d..cf67275 100644 --- a/tests/_test_files/htmlHelper_groupsConfig.php +++ b/tests/_test_files/htmlHelper_groupsConfig.php @@ -2,7 +2,11 @@ return array( 'css' => array( - '//_test_files/css/paths_prepend.css' - ,'//_test_files/css/styles.css' - ) + '//_test_files/css/paths_prepend.css', + '//_test_files/css/styles.css', + ), + + 'less' => array( + '//_test_files/main.less', + ), ); diff --git a/tests/_test_files/included.less b/tests/_test_files/included.less new file mode 100644 index 0000000..94ec1d6 --- /dev/null +++ b/tests/_test_files/included.less @@ -0,0 +1 @@ +/* lesstest2.less */ \ No newline at end of file diff --git a/tests/_test_files/main.less b/tests/_test_files/main.less new file mode 100644 index 0000000..a24f357 --- /dev/null +++ b/tests/_test_files/main.less @@ -0,0 +1,33 @@ +/*! preserving comment */ +@base: 24px; +@border-color: #B2B; + +/* import included-> */ +@import "included"; +/* <- import included */ + +.underline { + border-bottom: 1px solid green +} + +#header { + color: black; + border: 1px solid @border-color + #222222; + + .navigation { + font-size: @base / 2; + a { + .underline; + } + } + .logo { + width: 300px; + :hover { + text-decoration: none + } + } +} + +/* + a normal comment +*/ \ No newline at end of file