From d1860b9d6830762ed02d09745fcadbcaa53624cf Mon Sep 17 00:00:00 2001 From: catch <catch@35733.no-reply.drupal.org> Date: Wed, 17 Aug 2022 17:41:46 +0900 Subject: [PATCH] Issue #3302800 by nod_, quietone, longwave: Core tests need to filter out deprecated themes when looping over all themes --- .../system/tests/src/Functional/System/ThemeTest.php | 3 ++- .../src/Functional/Theme/EntityFilteringThemeTest.php | 10 ++++++++++ .../Asset/ResolvedLibraryDefinitionsFilesMatchTest.php | 3 +-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core/modules/system/tests/src/Functional/System/ThemeTest.php b/core/modules/system/tests/src/Functional/System/ThemeTest.php index 19574c4d9e10..e63d96f23c7a 100644 --- a/core/modules/system/tests/src/Functional/System/ThemeTest.php +++ b/core/modules/system/tests/src/Functional/System/ThemeTest.php @@ -423,7 +423,7 @@ public function testInvalidTheme() { public function testUninstallingThemes() { // Install olivero. \Drupal::service('theme_installer')->install(['olivero']); - // Set up claro as the admin theme. + // Set up Claro as the admin theme. \Drupal::service('theme_installer')->install(['claro']); $edit = [ 'admin_theme' => 'claro', @@ -431,6 +431,7 @@ public function testUninstallingThemes() { ]; $this->drupalGet('admin/appearance'); $this->submitForm($edit, 'Save configuration'); + // Set olivero as the default theme. $this->cssSelect('a[title="Set Olivero as default theme"]')[0]->click(); // Check that claro cannot be uninstalled as it is the admin theme. diff --git a/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php b/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php index 820554fa0714..54f39af75c98 100644 --- a/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/tests/src/Functional/Theme/EntityFilteringThemeTest.php @@ -6,6 +6,7 @@ use Drupal\Core\Extension\ExtensionDiscovery; use Drupal\comment\CommentInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; +use Drupal\Core\Extension\ExtensionLifecycle; use Drupal\node\NodeInterface; use Drupal\comment\Entity\Comment; use Drupal\taxonomy\Entity\Term; @@ -87,6 +88,15 @@ protected function setUp(): void { // Install all available non-testing themes. $listing = new ExtensionDiscovery(\Drupal::root()); $this->themes = $listing->scan('theme', FALSE); + /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */ + $theme_data = \Drupal::service('theme_handler')->rebuildThemeData(); + foreach (array_keys($this->themes) as $theme) { + // Skip obsolete and deprecated themes. + $info = $theme_data[$theme]->info; + if ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::OBSOLETE || $info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::DEPRECATED) { + unset($this->themes[$theme]); + } + } \Drupal::service('theme_installer')->install(array_keys($this->themes)); // Create a test user. diff --git a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php index 36d2942b2ca0..71ed51e3b564 100644 --- a/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Asset/ResolvedLibraryDefinitionsFilesMatchTest.php @@ -60,10 +60,9 @@ class ResolvedLibraryDefinitionsFilesMatchTest extends KernelTestBase { * @var string[] */ protected $allThemes = [ - 'bartik', + 'claro', 'classy', 'olivero', - 'seven', 'stable', 'stark', ]; -- GitLab