You are here

public function JsMinifierUnitTest::testMinifyJsqueeze 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::testMinifyJsqueeze()

Tests minification of a JS Asset with JSqueeze.

@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 177

Class

JsMinifierUnitTest
Tests the JS asset minifier.

Namespace

Drupal\Tests\advagg_js_minify\Kernel\Asset

Code

public function testMinifyJsqueeze(array $js_asset, $contents) {
  $this
    ->config('advagg_js_minify.settings')
    ->set('minifier', 5)
    ->save();

  // Due to an odd bug we use a different test file for PHP5.x comparison.
  // See https://www.drupal.org/node/2916193.
  if (version_compare(phpversion(), '7', '<')) {
    $js_asset['data'] .= '.php5';
  }
  $expected = file_get_contents($js_asset['data'] . '.jsqueeze.js');
  $this
    ->assertEquals($expected, $this->optimizer
    ->optimize($contents, $js_asset, []));
}