1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-31 09:31:48 +02:00

add Nailgun based ClosureCompiler

This commit is contained in:
Elan Ruusamäe
2015-11-20 13:54:42 +02:00
parent 273a08f2ee
commit 5458206700
2 changed files with 153 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php
class MinifyNailgunClosureCompilerTest extends TestCase
{
public static function setupBeforeClass()
{
parent::setupBeforeClass();
Minify_ClosureCompiler::$isDebug = true;
// To test more functionality, download a compiler.jar from
// https://github.com/google/closure-compiler#getting-started,
// put it under tests dir as 'compiler.jar'
// set minimum necessary settings
Minify_ClosureCompiler::$jarFile = __DIR__ . DIRECTORY_SEPARATOR . 'compiler.jar';
Minify_ClosureCompiler::$tempDir = sys_get_temp_dir();
Minify_NailgunClosureCompiler::$ngJarFile = __DIR__ . DIRECTORY_SEPARATOR . 'nailgun.jar';
}
/**
* Test minimisation with the minimum necessary settings
*/
public function test2()
{
$this->assertHasJar();
$src = "
(function (window, undefined){
function addOne(input) {
return 1 + input;
}
window.addOne = addOne;
window.undefined = undefined;
})(window);
";
$minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);";
$minOutput = Minify_NailgunClosureCompiler::minify($src);
$this->assertSame($minExpected, $minOutput, 'minimum necessary settings');
}
protected function assertHasJar()
{
$this->assertNotEmpty(Minify_ClosureCompiler::$jarFile);
try {
$this->assertFileExists(Minify_ClosureCompiler::$jarFile, "Have closure compiler compiler.jar");
} catch (Exception $e) {
$this->markTestSkipped($e->getMessage());
}
}
}