class ManyAssetsLoadOrderTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/FunctionalTests/Libraries/ManyAssetsLoadOrderTest.php \Drupal\FunctionalTests\Libraries\ManyAssetsLoadOrderTest
- 10 core/tests/Drupal/FunctionalTests/Libraries/ManyAssetsLoadOrderTest.php \Drupal\FunctionalTests\Libraries\ManyAssetsLoadOrderTest
Tests the loading of many weighted assets.
@group libraries
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalTests\Libraries\ManyAssetsLoadOrderTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ManyAssetsLoadOrderTest
File
-
core/
tests/ Drupal/ FunctionalTests/ Libraries/ ManyAssetsLoadOrderTest.php, line 12
Namespace
Drupal\FunctionalTests\LibrariesView source
class ManyAssetsLoadOrderTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected static $modules = [
'many_assets_test',
];
/**
* Loads a page with many assets that have different but close weights.
*
* Confirms the load order reflects the configured weights for each asset.
*/
public function testLoadOrder() {
$this->drupalGet('many_assets_test');
$js = $this->getSession()
->getPage()
->findAll('css', 'script[data-weight]');
$js_files = array_map(function ($item) {
return $item->getAttribute('data-weight');
}, $js);
$this->assertGreaterThan(0, count($js_files));
$js_files_sorted = $js_files;
asort($js_files_sorted);
// If the JavaScript files are loading in the proper order, the sorted array
// should match the unsorted one.
$this->assertSame($js_files_sorted, $js_files);
$css = $this->getSession()
->getPage()
->findAll('css', 'link[data-weight]');
$css_files = array_map(function ($item) {
return $item->getAttribute('data-weight');
}, $css);
$this->assertGreaterThan(0, count($css_files));
$css_files_sorted = $css_files;
asort($css_files_sorted);
// If the CSS files are loading in the proper order, the sorted array should
// match the unsorted one.
$this->assertSame($css_files_sorted, $css_files);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.