public function CssOptimizerUnitTest::testOptimize in Drupal 9
Same name and namespace in other branches
- 8 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 226
Class
- CssOptimizerUnitTest
- Tests the CSS asset optimizer.
Namespace
Drupal\Tests\Core\AssetCode
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;
}