function CssOptimizerUnitTest::testTypeExternal

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

File

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

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',
    'browsers' => [
      'IE' => TRUE,
      '!IE' => TRUE,
    ],
  ];
  $this->optimizer
    ->optimize($css_asset);
}

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