You are here

public function CssOptimizerUnitTest::testTypeExternal in Drupal 10

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

Tests a CSS asset with 'type' => 'external'.

File

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

Class

CssOptimizerUnitTest
Tests the CSS asset optimizer.

Namespace

Drupal\Tests\Core\Asset

Code

public function testTypeExternal() {
  $this
    ->expectException('Exception');
  $this
    ->expectExceptionMessage('Only file CSS assets can be optimized.');
  $css_asset = [
    'group' => -100,
    // Type external.
    'type' => 'external',
    'weight' => 0.012,
    'media' => 'all',
    'preprocess' => TRUE,
    'data' => 'http://example.com/foo.js',
  ];
  $this->optimizer
    ->optimize($css_asset);
}