function JsOptimizerUnitTest::providerTestOptimize

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php \Drupal\Tests\Core\Asset\JsOptimizerUnitTest::providerTestOptimize()
  2. 8.9.x core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php \Drupal\Tests\Core\Asset\JsOptimizerUnitTest::providerTestOptimize()
  3. 10 core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php \Drupal\Tests\Core\Asset\JsOptimizerUnitTest::providerTestOptimize()

Provides data for the JS asset optimize test.

Return value

array An array of test data.

See also

\Drupal\Core\Asset\JsOptimizer::optimize()

File

core/tests/Drupal/Tests/Core/Asset/JsOptimizerUnitTest.php, line 88

Class

JsOptimizerUnitTest
Tests the JS asset optimizer.

Namespace

Drupal\Tests\Core\Asset

Code

public static function providerTestOptimize() {
    $path = dirname(__FILE__) . '/js_test_files/';
    return [
        0 => [
            [
                'type' => 'file',
                'preprocess' => TRUE,
                'data' => $path . 'utf8_bom.js',
            ],
            file_get_contents($path . 'utf8_bom.js.optimized.js'),
        ],
        1 => [
            [
                'type' => 'file',
                'preprocess' => TRUE,
                'data' => $path . 'utf16_bom.js',
            ],
            file_get_contents($path . 'utf16_bom.js.optimized.js'),
        ],
        2 => [
            [
                'type' => 'file',
                'preprocess' => TRUE,
                'data' => $path . 'latin_9.js',
                'attributes' => [
                    'charset' => 'ISO-8859-15',
                ],
            ],
            file_get_contents($path . 'latin_9.js.optimized.js'),
        ],
        3 => [
            [
                'type' => 'file',
                'preprocess' => TRUE,
                'data' => $path . 'to_be_minified.js',
            ],
            file_get_contents($path . 'to_be_minified.js.optimized.js'),
        ],
        4 => [
            [
                'type' => 'file',
                'preprocess' => TRUE,
                'data' => $path . 'syntax_error.js',
            ],
            // When there is a syntax error, the 'optimized' contents are the
            // contents of the original file.
file_get_contents($path . 'syntax_error.js'),
        ],
    ];
}

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