public function ThemeTest::testListThemes in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest::testListThemes()
- 9 core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest::testListThemes()
Tests the listInfo() function.
File
- core/
modules/ system/ tests/ src/ Kernel/ Theme/ ThemeTest.php, line 106
Class
- ThemeTest
- Tests low-level theme functions.
Namespace
Drupal\Tests\system\Kernel\ThemeCode
public function testListThemes() {
$this->container
->get('theme_installer')
->install([
'test_subtheme',
]);
$theme_handler = $this->container
->get('theme_handler');
$themes = $theme_handler
->listInfo();
// Check if ThemeHandlerInterface::listInfo() retrieves enabled themes.
$this
->assertSame(1, $themes['test_theme']->status, 'Installed theme detected');
// Check if ThemeHandlerInterface::listInfo() returns disabled themes.
// Check for base theme and subtheme lists.
$base_theme_list = [
'test_basetheme' => 'Theme test base theme',
];
$sub_theme_list = [
'test_subsubtheme' => 'Theme test subsubtheme',
'test_subtheme' => 'Theme test subtheme',
];
$this
->assertSame($sub_theme_list, $themes['test_basetheme']->sub_themes, 'Base theme\'s object includes list of subthemes.');
$this
->assertSame($base_theme_list, $themes['test_subtheme']->base_themes, 'Subtheme\'s object includes list of base themes.');
// Check for theme engine in subtheme.
$this
->assertSame('twig', $themes['test_subtheme']->engine, 'Subtheme\'s object includes the theme engine.');
// Check for theme engine prefix.
$this
->assertSame('twig', $themes['test_basetheme']->prefix, 'Base theme\'s object includes the theme engine prefix.');
$this
->assertSame('twig', $themes['test_subtheme']->prefix, 'Subtheme\'s object includes the theme engine prefix.');
}