You are here

public function JsMinifierUnitTest::testMinifyJsmin in Advanced CSS/JS Aggregation 8.4

Same name and namespace in other branches
  1. 8.3 advagg_js_minify/tests/src/Kernel/Asset/JsMinifierUnitTest.php \Drupal\Tests\advagg_js_minify\Kernel\Asset\JsMinifierUnitTest::testMinifyJsmin()

Tests minification of a JS Asset with jsmin.

@dataProvider providerTestMinification

Parameters

array $js_asset: An fake asset array with the filepath to pass to the minifier.

string $contents: The asset string contents to be minified.

File

advagg_js_minify/tests/src/Kernel/Asset/JsMinifierUnitTest.php, line 141

Class

JsMinifierUnitTest
Tests the JS asset minifier.

Namespace

Drupal\Tests\advagg_js_minify\Kernel\Asset

Code

public function testMinifyJsmin(array $js_asset, $contents) {

  // Requires the JSMin PHP extension; if it isn't available skip the test.
  if (!function_exists('jsmin')) {
    $this
      ->markTestSkipped('The function jsmin doesn\'t exist, requires the JSMin PHP extension.');
  }
  $this
    ->config('advagg_js_minify.settings')
    ->set('minifier', 3)
    ->save();
  $expected = file_get_contents($js_asset['data'] . '.jsmin.js');
  $this
    ->assertEquals($expected, $this->optimizer
    ->optimize($contents, $js_asset, []));
}