function ThemeSettingsTest::testLogoConfig
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php \Drupal\KernelTests\Core\Theme\ThemeSettingsTest::testLogoConfig()
- 8.9.x core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php \Drupal\KernelTests\Core\Theme\ThemeSettingsTest::testLogoConfig()
- 10 core/tests/Drupal/KernelTests/Core/Theme/ThemeSettingsTest.php \Drupal\KernelTests\Core\Theme\ThemeSettingsTest::testLogoConfig()
Tests that the default logo config can be overridden.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Theme/ ThemeSettingsTest.php, line 69
Class
- ThemeSettingsTest
- Tests theme settings functionality.
Namespace
Drupal\KernelTests\Core\ThemeCode
public function testLogoConfig() : void {
/** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
$theme_installer = $this->container
->get('theme_installer');
$theme_installer->install([
'stark',
]);
/** @var \Drupal\Core\Extension\ThemeHandler $theme_handler */
$theme_handler = $this->container
->get('theme_handler');
$theme = $theme_handler->getTheme('stark');
// Tests default behavior.
$expected = '/' . $theme->getPath() . '/logo.svg';
$this->assertEquals($expected, theme_get_setting('logo.url', 'stark'));
$config = $this->config('stark.settings');
drupal_static_reset('theme_get_setting');
$values = [
'default_logo' => FALSE,
'logo_path' => 'public://logo_with_scheme.png',
];
theme_settings_convert_to_config($values, $config)->save();
// Tests logo path with scheme.
/** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
$file_url_generator = \Drupal::service('file_url_generator');
$expected = $file_url_generator->generateString('public://logo_with_scheme.png');
$this->assertEquals($expected, theme_get_setting('logo.url', 'stark'));
$values = [
'default_logo' => FALSE,
'logo_path' => $theme->getPath() . '/logo_relative_path.gif',
];
theme_settings_convert_to_config($values, $config)->save();
drupal_static_reset('theme_get_setting');
// Tests relative path.
$expected = '/' . $theme->getPath() . '/logo_relative_path.gif';
$this->assertEquals($expected, theme_get_setting('logo.url', 'stark'));
$theme_installer->install([
'test_theme',
]);
\Drupal::configFactory()->getEditable('system.theme')
->set('default', 'test_theme')
->save();
$theme = $theme_handler->getTheme('test_theme');
drupal_static_reset('theme_get_setting');
// Tests logo set in test_theme.info.yml.
$expected = '/' . $theme->getPath() . '/images/logo2.svg';
$this->assertEquals($expected, theme_get_setting('logo.url', 'test_theme'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.