diff --git a/core/lib/Drupal/Core/Theme/ThemeInitialization.php b/core/lib/Drupal/Core/Theme/ThemeInitialization.php index 0dbd0c6..7fb7f23 100644 --- a/core/lib/Drupal/Core/Theme/ThemeInitialization.php +++ b/core/lib/Drupal/Core/Theme/ThemeInitialization.php @@ -99,7 +99,7 @@ public function getActiveThemeByName($theme_name) { $ancestor = $theme_name; while ($ancestor && isset($themes[$ancestor]->base_theme)) { $ancestor = $themes[$ancestor]->base_theme; - $base_themes[] = $themes[$ancestor]; + array_unshift($base_themes, $themes[$ancestor]); } $active_theme = $this->getActiveTheme($themes[$theme_name], $base_themes); diff --git a/core/modules/system/src/Tests/Theme/ThemeTest.php b/core/modules/system/src/Tests/Theme/ThemeTest.php index 4573d01..980270b 100644 --- a/core/modules/system/src/Tests/Theme/ThemeTest.php +++ b/core/modules/system/src/Tests/Theme/ThemeTest.php @@ -154,7 +154,8 @@ function testFrontPageThemeSuggestion() { } /** - * Ensures a theme's .info.yml file is able to override a module CSS file from being added to the page. + * Ensures a theme's .info.yml and .libraries.yml files are able to override + * a module CSS file from being added to the page. * * @see test_theme.info.yml */ @@ -169,6 +170,13 @@ function testCSSOverride() { $this->drupalGet('theme-test/suggestion'); $this->assertNoText('system.module.css', 'The theme\'s .info.yml file is able to override a module CSS file from being added to the page.'); + // Ensure that parent's layout.css file gets overridden by test theme's + // layout.css file. + $classy_layout_css_url = drupal_get_path('theme', 'classy') .'/css/layout.css'; + $this->assertIdentical(0, count($this->xpath("//link[contains(@href, '" . $classy_layout_css_url . "')]")), $classy_layout_css_url . " not found"); + $theme_test_layout_css_url = drupal_get_path('theme', 'test_theme') .'/css/layout.css'; + $this->assertIdentical(1, count($this->xpath("//link[contains(@href, '" . $theme_test_layout_css_url . "')]")), $theme_test_layout_css_url . " found"); + // Also test with aggregation enabled, simply ensuring no PHP errors are // triggered during drupal_build_css_cache() when a source file doesn't // exist. Then allow remaining tests to continue with aggregation disabled diff --git a/core/modules/system/tests/themes/test_theme/css/layout.css b/core/modules/system/tests/themes/test_theme/css/layout.css new file mode 100644 index 0000000..12b06dc --- /dev/null +++ b/core/modules/system/tests/themes/test_theme/css/layout.css @@ -0,0 +1,6 @@ + +/** + * This file is for testing CSS file override through *.libraries.yml file in + * ThemeTest::testCSSOverride(). + * No contents are necessary. + */ diff --git a/core/modules/system/tests/themes/test_theme/test_theme.info.yml b/core/modules/system/tests/themes/test_theme/test_theme.info.yml index 9eebc90..5000e74 100644 --- a/core/modules/system/tests/themes/test_theme/test_theme.info.yml +++ b/core/modules/system/tests/themes/test_theme/test_theme.info.yml @@ -14,6 +14,8 @@ description: 'Theme for testing the theme system' version: VERSION base theme: classy core: 8.x +libraries: + - test_theme/global-styling stylesheets-remove: - system.module.css regions: diff --git a/core/modules/system/tests/themes/test_theme/test_theme.libraries.yml b/core/modules/system/tests/themes/test_theme/test_theme.libraries.yml new file mode 100644 index 0000000..ed21a2d --- /dev/null +++ b/core/modules/system/tests/themes/test_theme/test_theme.libraries.yml @@ -0,0 +1,5 @@ +global-styling: + version: VERSION + css: + theme: + css/layout.css: {}