You are here

public function CssOptimizerUnitTest::testOptimize in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php \Drupal\Tests\Core\Asset\CssOptimizerUnitTest::testOptimize()
  2. 10 core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php \Drupal\Tests\Core\Asset\CssOptimizerUnitTest::testOptimize()

Tests optimizing a CSS asset group containing 'type' => 'file'.

@dataProvider providerTestOptimize

File

core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php, line 211

Class

CssOptimizerUnitTest
Tests the CSS asset optimizer.

Namespace

Drupal\Tests\Core\Asset

Code

public function testOptimize($css_asset, $expected) {
  global $base_path;
  $original_base_path = $base_path;
  $base_path = '/';

  // \Drupal\Core\Asset\CssOptimizer::loadFile() relies on the current working
  // directory being the one that is used when index.php is the entry point.
  // Note: PHPUnit automatically restores the original working directory.
  chdir(realpath(__DIR__ . '/../../../../../../'));
  $this
    ->assertEquals($expected, $this->optimizer
    ->optimize($css_asset), 'Group of file CSS assets optimized correctly.');
  $base_path = $original_base_path;
}