function LibraryDiscoveryParserTest::testDefaultCssWeights
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php \Drupal\Tests\Core\Asset\LibraryDiscoveryParserTest::testDefaultCssWeights()
- 10 core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php \Drupal\Tests\Core\Asset\LibraryDiscoveryParserTest::testDefaultCssWeights()
- 11.x core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php \Drupal\Tests\Core\Asset\LibraryDiscoveryParserTest::testDefaultCssWeights()
Ensures that CSS weights are taken into account properly.
@covers ::buildByExtension
File
-
core/
tests/ Drupal/ Tests/ Core/ Asset/ LibraryDiscoveryParserTest.php, line 280
Class
- LibraryDiscoveryParserTest
- @coversDefaultClass \Drupal\Core\Asset\LibraryDiscoveryParser @group Asset
Namespace
Drupal\Tests\Core\AssetCode
public function testDefaultCssWeights() {
$this->moduleHandler
->expects($this->atLeastOnce())
->method('moduleExists')
->with('css_weights')
->will($this->returnValue(TRUE));
$path = __DIR__ . '/library_test_files';
$path = substr($path, strlen($this->root) + 1);
$this->libraryDiscoveryParser
->setPaths('module', 'css_weights', $path);
$libraries = $this->libraryDiscoveryParser
->buildByExtension('css_weights');
$library = $libraries['example'];
$css = $library['css'];
$this->assertCount(10, $css);
// The following default weights are tested:
// - CSS_BASE: -200
// - CSS_LAYOUT: -100
// - CSS_COMPONENT: 0
// - CSS_STATE: 100
// - CSS_THEME: 200
$this->assertEquals(200, $css[0]['weight']);
$this->assertEquals(200 + 29, $css[1]['weight']);
$this->assertEquals(-200, $css[2]['weight']);
$this->assertEquals(-200 + 97, $css[3]['weight']);
$this->assertEquals(-100, $css[4]['weight']);
$this->assertEquals(-100 + 92, $css[5]['weight']);
$this->assertEquals(0, $css[6]['weight']);
$this->assertEquals(45, $css[7]['weight']);
$this->assertEquals(100, $css[8]['weight']);
$this->assertEquals(100 + 8, $css[9]['weight']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.