function AssetResolverTest::testJsAssetsOrder

Test that order of scripts are correct.

File

core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php, line 271

Class

AssetResolverTest
@coversDefaultClass \Drupal\Core\Asset\AssetResolver @group Asset

Namespace

Drupal\Tests\Core\Asset

Code

public function testJsAssetsOrder() : void {
    $time = time();
    $assets_a = (new AttachedAssets())->setAlreadyLoadedLibraries([])
        ->setLibraries([
        'core/drupal',
        'core/ckeditor5',
        'core/jquery',
        'piggy/ckeditor',
    ])
        ->setSettings([
        'currentTime' => $time,
    ]);
    $assets_b = (new AttachedAssets())->setAlreadyLoadedLibraries([])
        ->setLibraries([
        'piggy/ckeditor',
        'core/drupal',
        'core/ckeditor5',
        'core/jquery',
    ])
        ->setSettings([
        'currentTime' => $time,
    ]);
    $js_assets_a = $this->assetResolver
        ->getJsAssets($assets_a, FALSE, $this->english);
    $js_assets_b = $this->assetResolver
        ->getJsAssets($assets_b, FALSE, $this->english);
    $grouper = new JsCollectionGrouper();
    $group_a = $grouper->group($js_assets_a[1]);
    $group_b = $grouper->group($js_assets_b[1]);
    foreach ($group_a as $key => $value) {
        $this->assertSame($value['items'], $group_b[$key]['items']);
    }
}

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