function CssCollectionOptimizerLazyUnitTest::testRelativePathsInLocalMinifiedCssAssets

Test that relative paths in local minified CSS files are updated.

This ensures that local minified assets have their relative paths correctly rewritten during optimization.

File

core/tests/Drupal/Tests/Core/Asset/CssCollectionOptimizerLazyUnitTest.php, line 260

Class

CssCollectionOptimizerLazyUnitTest
Tests the CSS asset optimizer.

Namespace

Drupal\Tests\Core\Asset

Code

public function testRelativePathsInLocalMinifiedCssAssets() : void {
  $mock_grouper = $this->createMock(AssetCollectionGrouperInterface::class);
  $optimizer = new CssCollectionOptimizerLazy($mock_grouper, $this->optimizer, $this->createMock(ThemeManagerInterface::class), $this->createMock(LibraryDependencyResolverInterface::class), new RequestStack(), $this->createMock(FileSystemInterface::class), $this->createMock(ConfigFactoryInterface::class), $this->createMock(FileUrlGeneratorInterface::class), $this->createMock(TimeInterface::class), $this->createMock(LanguageManagerInterface::class));
  $result = $optimizer->optimizeGroup([
    'items' => [
      [
        'type' => 'file',
        'data' => 'core/tests/Drupal/Tests/Core/Asset/css_test_files/css_minified_with_relative_paths.css',
        'media' => 'all',
        'license' => FALSE,
        'preprocess' => TRUE,
        'minified' => TRUE,
      ],
    ],
  ]);
  $expected = file_get_contents(__DIR__ . '/css_test_files/css_minified_with_relative_paths.css.optimized.css');
  self::assertEquals($expected, $result, 'Relative paths in local minified CSS assets are correctly replaced.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.