public function LibraryDiscoveryParserTest::testDefaultCssWeights in Drupal 9
Same name and namespace in other branches
- 8 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()
Ensures that CSS weights are taken into account properly.
@covers ::buildByExtension
File
- core/
tests/ Drupal/ Tests/ Core/ Asset/ LibraryDiscoveryParserTest.php, line 322 - Contains \Drupal\Tests\Core\Asset\LibraryDiscoveryParserTest.
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->extensionPathResolver
->expects($this
->atLeastOnce())
->method('getPath')
->with('module', 'css_weights')
->willReturn($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']);
}