# wp-optimize/3.2.5/vendor/mrclay/minify/tests/MinifyNailgunClosureCompilerTest.php

WP-Optimize – Cache, Compress images, Minify &amp; Clean database to boost page speed &amp; performance, version 3.2.5. 58 lines.

- Page: https://pluginprobe.com/plugins/wp-optimize/3.2.5/code/vendor/mrclay/minify/tests/MinifyNailgunClosureCompilerTest.php
- Raw: https://pluginprobe.com/plugins/wp-optimize/3.2.5/raw/vendor/mrclay/minify/tests/MinifyNailgunClosureCompilerTest.php
- Modified: 2022-06-03T18:20:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-optimize/3.2.5/code/vendor/mrclay/minify/tests/MinifyNailgunClosureCompilerTest.php#L10-L20`.

```php
<?php

namespace Minify\Test;

use Exception;
use Minify_ClosureCompiler;
use Minify_NailgunClosureCompiler;

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 test1()
    {
        $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);
        $this->assertNotEmpty(Minify_NailgunClosureCompiler::$ngJarFile);
        try {
            $this->assertFileExists(Minify_ClosureCompiler::$jarFile, "Have closure compiler compiler.jar");
            $this->assertFileExists(Minify_NailgunClosureCompiler::$ngJarFile, "Have nailgun.jar");
        } catch (Exception $e) {
            $this->markTestSkipped($e->getMessage());
        }
    }
}

```
