You are here

public function JsMinifierUnitTest::testMinifyJsqueezeImportantComments in Advanced CSS/JS Aggregation 8.3

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

Tests JSqueeze minification's important comments/integration.

File

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

Class

JsMinifierUnitTest
Tests the JS asset minifier.

Namespace

Drupal\Tests\advagg_js_minify\Kernel\Asset

Code

public function testMinifyJsqueezeImportantComments() {
  $file = dirname(__FILE__) . '/js_test_files/jquery.once.js';
  $asset = [
    'data' => $file,
  ];
  $original = file_get_contents($file);
  $withComments = file_get_contents($file . '.with-important.js');
  $withoutComments = file_get_contents($file . '.without-important.js');
  $config = $this
    ->config('advagg_js_minify.settings');
  $config
    ->set('minifier', 5)
    ->set('add_license', TRUE)
    ->save();
  $this
    ->assertEquals($withComments, $this->optimizer
    ->optimize($original, $asset, []));
  $config
    ->set('add_license', FALSE)
    ->save();
  $this
    ->assertEquals($withoutComments, $this->optimizer
    ->optimize($original, $asset, []));
}