PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / mrclay / minify / tests / MinifyNailgunClosureCompilerTest.php

MinifyNailgunClosureCompilerTest.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/mrclay/minify/tests/MinifyNailgunClosureCompilerTest.php

58 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Minify\Test;
4
5 use Exception;
6 use Minify_ClosureCompiler;
7 use Minify_NailgunClosureCompiler;
8
9 class MinifyNailgunClosureCompilerTest extends TestCase
10 {
11 public static function setupBeforeClass()
12 {
13 parent::setupBeforeClass();
14 Minify_ClosureCompiler::$isDebug = true;
15
16 // To test more functionality, download a compiler.jar from
17 // https://github.com/google/closure-compiler#getting-started,
18 // put it under tests dir as 'compiler.jar'
19
20 // set minimum necessary settings
21 Minify_ClosureCompiler::$jarFile = __DIR__ . DIRECTORY_SEPARATOR . 'compiler.jar';
22 Minify_ClosureCompiler::$tempDir = sys_get_temp_dir();
23 Minify_NailgunClosureCompiler::$ngJarFile = __DIR__ . DIRECTORY_SEPARATOR . 'nailgun.jar';
24 }
25
26 /**
27 * Test minimisation with the minimum necessary settings
28 */
29 public function test1()
30 {
31 $this->assertHasJar();
32 $src = "
33 (function (window, undefined){
34 function addOne(input) {
35 return 1 + input;
36 }
37 window.addOne = addOne;
38 window.undefined = undefined;
39 })(window);
40 ";
41 $minExpected = "(function(a,b){a.addOne=function(a){return 1+a};a.undefined=b})(window);";
42 $minOutput = Minify_NailgunClosureCompiler::minify($src);
43 $this->assertSame($minExpected, $minOutput, 'minimum necessary settings');
44 }
45
46 protected function assertHasJar()
47 {
48 $this->assertNotEmpty(Minify_ClosureCompiler::$jarFile);
49 $this->assertNotEmpty(Minify_NailgunClosureCompiler::$ngJarFile);
50 try {
51 $this->assertFileExists(Minify_ClosureCompiler::$jarFile, "Have closure compiler compiler.jar");
52 $this->assertFileExists(Minify_NailgunClosureCompiler::$ngJarFile, "Have nailgun.jar");
53 } catch (Exception $e) {
54 $this->markTestSkipped($e->getMessage());
55 }
56 }
57 }
58