function CssOptimizerUnitTest::testTypeExternal

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php \Drupal\Tests\Core\Asset\CssOptimizerUnitTest::testTypeExternal()
  2. 10 core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php \Drupal\Tests\Core\Asset\CssOptimizerUnitTest::testTypeExternal()
  3. 11.x 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 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.