annotate core/modules/system/src/Tests/System/ThemeTest.php @ 16:c2387f117808

Routine composer update
author Chris Cannam
date Tue, 10 Jul 2018 15:07:59 +0100
parents 1fec387a4317
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\system\Tests\System;
Chris@0 4
Chris@0 5 use Drupal\Core\StreamWrapper\PublicStream;
Chris@0 6 use Drupal\simpletest\WebTestBase;
Chris@0 7
Chris@0 8 /**
Chris@0 9 * Tests the theme interface functionality by enabling and switching themes, and
Chris@0 10 * using an administration theme.
Chris@0 11 *
Chris@0 12 * @group system
Chris@0 13 */
Chris@0 14 class ThemeTest extends WebTestBase {
Chris@0 15
Chris@0 16 /**
Chris@0 17 * A user with administrative permissions.
Chris@0 18 *
Chris@0 19 * @var \Drupal\user\UserInterface
Chris@0 20 */
Chris@0 21 protected $adminUser;
Chris@0 22
Chris@0 23 /**
Chris@0 24 * Modules to enable.
Chris@0 25 *
Chris@0 26 * @var array
Chris@0 27 */
Chris@0 28 public static $modules = ['node', 'block', 'file'];
Chris@0 29
Chris@0 30 protected function setUp() {
Chris@0 31 parent::setUp();
Chris@0 32
Chris@0 33 $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
Chris@0 34
Chris@0 35 $this->adminUser = $this->drupalCreateUser(['access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks']);
Chris@0 36 $this->drupalLogin($this->adminUser);
Chris@0 37 $this->node = $this->drupalCreateNode();
Chris@0 38 $this->drupalPlaceBlock('local_tasks_block');
Chris@0 39 }
Chris@0 40
Chris@0 41 /**
Chris@0 42 * Test the theme settings form.
Chris@0 43 */
Chris@0 44 public function testThemeSettings() {
Chris@0 45 // Ensure invalid theme settings form URLs return a proper 404.
Chris@0 46 $this->drupalGet('admin/appearance/settings/bartik');
Chris@0 47 $this->assertResponse(404, 'The theme settings form URL for a uninstalled theme could not be found.');
Chris@0 48 $this->drupalGet('admin/appearance/settings/' . $this->randomMachineName());
Chris@0 49 $this->assertResponse(404, 'The theme settings form URL for a non-existent theme could not be found.');
Chris@0 50 $this->assertTrue(\Drupal::service('theme_installer')->install(['stable']));
Chris@0 51 $this->drupalGet('admin/appearance/settings/stable');
Chris@0 52 $this->assertResponse(404, 'The theme settings form URL for a hidden theme is unavailable.');
Chris@0 53
Chris@0 54 // Specify a filesystem path to be used for the logo.
Chris@0 55 $file = current($this->drupalGetTestFiles('image'));
Chris@0 56 $file_relative = strtr($file->uri, ['public:/' => PublicStream::basePath()]);
Chris@0 57 $default_theme_path = 'core/themes/classy';
Chris@0 58
Chris@0 59 $supported_paths = [
Chris@0 60 // Raw stream wrapper URI.
Chris@0 61 $file->uri => [
Chris@0 62 'form' => file_uri_target($file->uri),
Chris@0 63 'src' => file_url_transform_relative(file_create_url($file->uri)),
Chris@0 64 ],
Chris@0 65 // Relative path within the public filesystem.
Chris@0 66 file_uri_target($file->uri) => [
Chris@0 67 'form' => file_uri_target($file->uri),
Chris@0 68 'src' => file_url_transform_relative(file_create_url($file->uri)),
Chris@0 69 ],
Chris@0 70 // Relative path to a public file.
Chris@0 71 $file_relative => [
Chris@0 72 'form' => $file_relative,
Chris@0 73 'src' => file_url_transform_relative(file_create_url($file->uri)),
Chris@0 74 ],
Chris@0 75 // Relative path to an arbitrary file.
Chris@0 76 'core/misc/druplicon.png' => [
Chris@0 77 'form' => 'core/misc/druplicon.png',
Chris@0 78 'src' => base_path() . 'core/misc/druplicon.png',
Chris@0 79 ],
Chris@0 80 // Relative path to a file in a theme.
Chris@0 81 $default_theme_path . '/logo.svg' => [
Chris@0 82 'form' => $default_theme_path . '/logo.svg',
Chris@0 83 'src' => base_path() . $default_theme_path . '/logo.svg',
Chris@0 84 ],
Chris@0 85 ];
Chris@0 86 foreach ($supported_paths as $input => $expected) {
Chris@0 87 $edit = [
Chris@0 88 'default_logo' => FALSE,
Chris@0 89 'logo_path' => $input,
Chris@0 90 ];
Chris@0 91 $this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration'));
Chris@0 92 $this->assertNoText('The custom logo path is invalid.');
Chris@0 93 $this->assertFieldByName('logo_path', $expected['form']);
Chris@0 94
Chris@0 95 // Verify logo path examples.
Chris@0 96 $elements = $this->xpath('//div[contains(@class, :item)]/div[@class=:description]/code', [
Chris@0 97 ':item' => 'js-form-item-logo-path',
Chris@0 98 ':description' => 'description',
Chris@0 99 ]);
Chris@0 100 // Expected default values (if all else fails).
Chris@0 101 $implicit_public_file = 'logo.svg';
Chris@0 102 $explicit_file = 'public://logo.svg';
Chris@0 103 $local_file = $default_theme_path . '/logo.svg';
Chris@0 104 // Adjust for fully qualified stream wrapper URI in public filesystem.
Chris@0 105 if (file_uri_scheme($input) == 'public') {
Chris@0 106 $implicit_public_file = file_uri_target($input);
Chris@0 107 $explicit_file = $input;
Chris@0 108 $local_file = strtr($input, ['public:/' => PublicStream::basePath()]);
Chris@0 109 }
Chris@0 110 // Adjust for fully qualified stream wrapper URI elsewhere.
Chris@0 111 elseif (file_uri_scheme($input) !== FALSE) {
Chris@0 112 $explicit_file = $input;
Chris@0 113 }
Chris@0 114 // Adjust for relative path within public filesystem.
Chris@0 115 elseif ($input == file_uri_target($file->uri)) {
Chris@0 116 $implicit_public_file = $input;
Chris@0 117 $explicit_file = 'public://' . $input;
Chris@0 118 $local_file = PublicStream::basePath() . '/' . $input;
Chris@0 119 }
Chris@0 120 $this->assertEqual((string) $elements[0], $implicit_public_file);
Chris@0 121 $this->assertEqual((string) $elements[1], $explicit_file);
Chris@0 122 $this->assertEqual((string) $elements[2], $local_file);
Chris@0 123
Chris@0 124 // Verify the actual 'src' attribute of the logo being output in a site
Chris@0 125 // branding block.
Chris@0 126 $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
Chris@0 127 $this->drupalGet('');
Chris@0 128 $elements = $this->xpath('//header//a[@rel=:rel]/img', [
Chris@0 129 ':rel' => 'home',
Chris@0 130 ]
Chris@0 131 );
Chris@0 132 $this->assertEqual((string) $elements[0]['src'], $expected['src']);
Chris@0 133 }
Chris@0 134 $unsupported_paths = [
Chris@0 135 // Stream wrapper URI to non-existing file.
Chris@0 136 'public://whatever.png',
Chris@0 137 'private://whatever.png',
Chris@0 138 'temporary://whatever.png',
Chris@0 139 // Bogus stream wrapper URIs.
Chris@0 140 'public:/whatever.png',
Chris@0 141 '://whatever.png',
Chris@0 142 ':whatever.png',
Chris@0 143 'public://',
Chris@0 144 // Relative path within the public filesystem to non-existing file.
Chris@0 145 'whatever.png',
Chris@0 146 // Relative path to non-existing file in public filesystem.
Chris@0 147 PublicStream::basePath() . '/whatever.png',
Chris@0 148 // Semi-absolute path to non-existing file in public filesystem.
Chris@0 149 '/' . PublicStream::basePath() . '/whatever.png',
Chris@0 150 // Relative path to arbitrary non-existing file.
Chris@0 151 'core/misc/whatever.png',
Chris@0 152 // Semi-absolute path to arbitrary non-existing file.
Chris@0 153 '/core/misc/whatever.png',
Chris@0 154 // Absolute paths to any local file (even if it exists).
Chris@14 155 \Drupal::service('file_system')->realpath($file->uri),
Chris@0 156 ];
Chris@0 157 $this->drupalGet('admin/appearance/settings');
Chris@0 158 foreach ($unsupported_paths as $path) {
Chris@0 159 $edit = [
Chris@0 160 'default_logo' => FALSE,
Chris@0 161 'logo_path' => $path,
Chris@0 162 ];
Chris@0 163 $this->drupalPostForm(NULL, $edit, t('Save configuration'));
Chris@0 164 $this->assertText('The custom logo path is invalid.');
Chris@0 165 }
Chris@0 166
Chris@0 167 // Upload a file to use for the logo.
Chris@0 168 $edit = [
Chris@0 169 'default_logo' => FALSE,
Chris@0 170 'logo_path' => '',
Chris@14 171 'files[logo_upload]' => \Drupal::service('file_system')->realpath($file->uri),
Chris@0 172 ];
Chris@0 173 $this->drupalPostForm('admin/appearance/settings', $edit, t('Save configuration'));
Chris@0 174
Chris@0 175 $fields = $this->xpath($this->constructFieldXpath('name', 'logo_path'));
Chris@0 176 $uploaded_filename = 'public://' . $fields[0]['value'];
Chris@0 177
Chris@0 178 $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
Chris@0 179 $this->drupalGet('');
Chris@0 180 $elements = $this->xpath('//header//a[@rel=:rel]/img', [
Chris@0 181 ':rel' => 'home',
Chris@0 182 ]
Chris@0 183 );
Chris@0 184 $this->assertEqual($elements[0]['src'], file_url_transform_relative(file_create_url($uploaded_filename)));
Chris@0 185
Chris@0 186 $this->container->get('theme_handler')->install(['bartik']);
Chris@0 187
Chris@0 188 // Ensure only valid themes are listed in the local tasks.
Chris@0 189 $this->drupalPlaceBlock('local_tasks_block', ['region' => 'header']);
Chris@0 190 $this->drupalGet('admin/appearance/settings');
Chris@0 191 $theme_handler = \Drupal::service('theme_handler');
Chris@0 192 $this->assertLink($theme_handler->getName('classy'));
Chris@0 193 $this->assertLink($theme_handler->getName('bartik'));
Chris@0 194 $this->assertNoLink($theme_handler->getName('stable'));
Chris@0 195
Chris@0 196 // If a hidden theme is an admin theme it should be viewable.
Chris@0 197 \Drupal::configFactory()->getEditable('system.theme')->set('admin', 'stable')->save();
Chris@0 198 \Drupal::service('router.builder')->rebuildIfNeeded();
Chris@0 199 $this->drupalPlaceBlock('local_tasks_block', ['region' => 'header', 'theme' => 'stable']);
Chris@0 200 $this->drupalGet('admin/appearance/settings');
Chris@0 201 $this->assertLink($theme_handler->getName('stable'));
Chris@0 202 $this->drupalGet('admin/appearance/settings/stable');
Chris@0 203 $this->assertResponse(200, 'The theme settings form URL for a hidden theme that is the admin theme is available.');
Chris@0 204
Chris@0 205 // Ensure default logo and favicons are not triggering custom path
Chris@0 206 // validation errors if their custom paths are set on the form.
Chris@0 207 $edit = [
Chris@0 208 'default_logo' => TRUE,
Chris@0 209 'logo_path' => 'public://whatever.png',
Chris@0 210 'default_favicon' => TRUE,
Chris@0 211 'favicon_path' => 'public://whatever.ico',
Chris@0 212 ];
Chris@0 213 $this->drupalPostForm('admin/appearance/settings', $edit, 'Save configuration');
Chris@0 214 $this->assertNoText('The custom logo path is invalid.');
Chris@0 215 $this->assertNoText('The custom favicon path is invalid.');
Chris@0 216 }
Chris@0 217
Chris@0 218 /**
Chris@0 219 * Test the theme settings logo form.
Chris@0 220 */
Chris@0 221 public function testThemeSettingsLogo() {
Chris@0 222 // Visit Bartik's theme settings page to replace the logo.
Chris@0 223 $this->container->get('theme_handler')->install(['bartik']);
Chris@0 224 $this->drupalGet('admin/appearance/settings/bartik');
Chris@0 225 $edit = [
Chris@0 226 'default_logo' => FALSE,
Chris@0 227 'logo_path' => 'core/misc/druplicon.png',
Chris@0 228 ];
Chris@0 229 $this->drupalPostForm('admin/appearance/settings/bartik', $edit, t('Save configuration'));
Chris@0 230 $this->assertFieldByName('default_logo', FALSE);
Chris@0 231 $this->assertFieldByName('logo_path', 'core/misc/druplicon.png');
Chris@0 232
Chris@0 233 // Make sure the logo and favicon settings are not available when the file
Chris@0 234 // module is not enabled.
Chris@0 235 \Drupal::service('module_installer')->uninstall(['file']);
Chris@0 236 $this->drupalGet('admin/appearance/settings');
Chris@0 237 $this->assertNoText('Logo image settings');
Chris@0 238 $this->assertNoText('Shortcut icon settings');
Chris@0 239 }
Chris@0 240
Chris@0 241 /**
Chris@0 242 * Test the administration theme functionality.
Chris@0 243 */
Chris@0 244 public function testAdministrationTheme() {
Chris@0 245 $this->container->get('theme_handler')->install(['seven']);
Chris@0 246
Chris@0 247 // Install an administration theme and show it on the node admin pages.
Chris@0 248 $edit = [
Chris@0 249 'admin_theme' => 'seven',
Chris@0 250 'use_admin_theme' => TRUE,
Chris@0 251 ];
Chris@0 252 $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
Chris@0 253
Chris@0 254 $this->drupalGet('admin/config');
Chris@0 255 $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
Chris@0 256
Chris@0 257 $this->drupalGet('node/' . $this->node->id());
Chris@0 258 $this->assertRaw('core/themes/classy', 'Site default theme used on node page.');
Chris@0 259
Chris@0 260 $this->drupalGet('node/add');
Chris@0 261 $this->assertRaw('core/themes/seven', 'Administration theme used on the add content page.');
Chris@0 262
Chris@0 263 $this->drupalGet('node/' . $this->node->id() . '/edit');
Chris@0 264 $this->assertRaw('core/themes/seven', 'Administration theme used on the edit content page.');
Chris@0 265
Chris@0 266 // Disable the admin theme on the node admin pages.
Chris@0 267 $edit = [
Chris@0 268 'use_admin_theme' => FALSE,
Chris@0 269 ];
Chris@0 270 $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
Chris@0 271
Chris@0 272 $this->drupalGet('admin/config');
Chris@0 273 $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
Chris@0 274
Chris@0 275 // Ensure that the admin theme is also visible on the 403 page.
Chris@0 276 $normal_user = $this->drupalCreateUser(['view the administration theme']);
Chris@0 277 $this->drupalLogin($normal_user);
Chris@0 278 $this->drupalGet('admin/config');
Chris@0 279 $this->assertResponse(403);
Chris@0 280 $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.');
Chris@0 281 $this->drupalLogin($this->adminUser);
Chris@0 282
Chris@0 283 $this->drupalGet('node/add');
Chris@0 284 $this->assertRaw('core/themes/classy', 'Site default theme used on the add content page.');
Chris@0 285
Chris@0 286 // Reset to the default theme settings.
Chris@0 287 $edit = [
Chris@0 288 'admin_theme' => '0',
Chris@0 289 'use_admin_theme' => FALSE,
Chris@0 290 ];
Chris@0 291 $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
Chris@0 292
Chris@0 293 $this->drupalGet('admin');
Chris@0 294 $this->assertRaw('core/themes/classy', 'Site default theme used on administration page.');
Chris@0 295
Chris@0 296 $this->drupalGet('node/add');
Chris@0 297 $this->assertRaw('core/themes/classy', 'Site default theme used on the add content page.');
Chris@0 298 }
Chris@0 299
Chris@0 300 /**
Chris@0 301 * Test switching the default theme.
Chris@0 302 */
Chris@0 303 public function testSwitchDefaultTheme() {
Chris@0 304 /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
Chris@0 305 $theme_handler = \Drupal::service('theme_handler');
Chris@0 306 // First, install Stark and set it as the default theme programmatically.
Chris@0 307 $theme_handler->install(['stark']);
Chris@0 308 $this->config('system.theme')->set('default', 'stark')->save();
Chris@0 309
Chris@0 310 // Install Bartik and set it as the default theme.
Chris@0 311 $theme_handler->install(['bartik']);
Chris@0 312 $this->drupalGet('admin/appearance');
Chris@0 313 $this->clickLink(t('Set as default'));
Chris@0 314 $this->assertEqual($this->config('system.theme')->get('default'), 'bartik');
Chris@0 315
Chris@0 316 // Test the default theme on the secondary links (blocks admin page).
Chris@0 317 $this->drupalGet('admin/structure/block');
Chris@0 318 $this->assertText('Bartik(' . t('active tab') . ')', 'Default local task on blocks admin page is the default theme.');
Chris@0 319 // Switch back to Stark and test again to test that the menu cache is cleared.
Chris@0 320 $this->drupalGet('admin/appearance');
Chris@0 321 // Stark is the first 'Set as default' link.
Chris@0 322 $this->clickLink(t('Set as default'));
Chris@0 323 $this->drupalGet('admin/structure/block');
Chris@0 324 $this->assertText('Stark(' . t('active tab') . ')', 'Default local task on blocks admin page has changed.');
Chris@0 325 }
Chris@0 326
Chris@0 327 /**
Chris@0 328 * Test themes can't be installed when the base theme or engine is missing.
Chris@0 329 *
Chris@0 330 * Include test for themes that have a missing base theme somewhere further up
Chris@0 331 * the chain than the immediate base theme.
Chris@0 332 */
Chris@0 333 public function testInvalidTheme() {
Chris@0 334 // theme_page_test_system_info_alter() un-hides all hidden themes.
Chris@0 335 $this->container->get('module_installer')->install(['theme_page_test']);
Chris@0 336 // Clear the system_list() and theme listing cache to pick up the change.
Chris@0 337 $this->container->get('theme_handler')->reset();
Chris@0 338 $this->drupalGet('admin/appearance');
Chris@0 339 $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', ['@base_theme' => 'not_real_test_basetheme']));
Chris@0 340 $this->assertText(t('This theme requires the base theme @base_theme to operate correctly.', ['@base_theme' => 'test_invalid_basetheme']));
Chris@0 341 $this->assertText(t('This theme requires the theme engine @theme_engine to operate correctly.', ['@theme_engine' => 'not_real_engine']));
Chris@0 342 // Check for the error text of a theme with the wrong core version.
Chris@0 343 $this->assertText("This theme is not compatible with Drupal 8.x. Check that the .info.yml file contains the correct 'core' value.");
Chris@0 344 // Check for the error text of a theme without a content region.
Chris@0 345 $this->assertText("This theme is missing a 'content' region.");
Chris@0 346 }
Chris@0 347
Chris@0 348 /**
Chris@0 349 * Test uninstalling of themes works.
Chris@0 350 */
Chris@0 351 public function testUninstallingThemes() {
Chris@0 352 // Install Bartik and set it as the default theme.
Chris@0 353 \Drupal::service('theme_handler')->install(['bartik']);
Chris@0 354 // Set up seven as the admin theme.
Chris@0 355 \Drupal::service('theme_handler')->install(['seven']);
Chris@0 356 $edit = [
Chris@0 357 'admin_theme' => 'seven',
Chris@0 358 'use_admin_theme' => TRUE,
Chris@0 359 ];
Chris@0 360 $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
Chris@0 361 $this->drupalGet('admin/appearance');
Chris@0 362 $this->clickLink(t('Set as default'));
Chris@0 363
Chris@0 364 // Check that seven cannot be uninstalled as it is the admin theme.
Chris@0 365 $this->assertNoRaw('Uninstall Seven theme', 'A link to uninstall the Seven theme does not appear on the theme settings page.');
Chris@0 366 // Check that bartik cannot be uninstalled as it is the default theme.
Chris@0 367 $this->assertNoRaw('Uninstall Bartik theme', 'A link to uninstall the Bartik theme does not appear on the theme settings page.');
Chris@0 368 // Check that the classy theme cannot be uninstalled as it is a base theme
Chris@0 369 // of seven and bartik.
Chris@0 370 $this->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
Chris@0 371
Chris@0 372 // Install Stark and set it as the default theme.
Chris@0 373 \Drupal::service('theme_handler')->install(['stark']);
Chris@0 374
Chris@0 375 $edit = [
Chris@0 376 'admin_theme' => 'stark',
Chris@0 377 'use_admin_theme' => TRUE,
Chris@0 378 ];
Chris@0 379 $this->drupalPostForm('admin/appearance', $edit, t('Save configuration'));
Chris@0 380
Chris@0 381 // Check that seven can be uninstalled now.
Chris@0 382 $this->assertRaw('Uninstall Seven theme', 'A link to uninstall the Seven theme does appear on the theme settings page.');
Chris@0 383 // Check that the classy theme still cannot be uninstalled as it is a
Chris@0 384 // base theme of bartik.
Chris@0 385 $this->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
Chris@0 386
Chris@0 387 // Change the default theme to stark, stark is second in the list.
Chris@0 388 $this->clickLink(t('Set as default'), 1);
Chris@0 389
Chris@0 390 // Check that bartik can be uninstalled now.
Chris@0 391 $this->assertRaw('Uninstall Bartik theme', 'A link to uninstall the Bartik theme does appear on the theme settings page.');
Chris@0 392
Chris@14 393 // Check that the classy theme still can't be uninstalled as neither of its
Chris@0 394 // base themes have been.
Chris@0 395 $this->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
Chris@0 396
Chris@0 397 // Uninstall each of the three themes starting with Bartik.
Chris@0 398 $this->clickLink(t('Uninstall'));
Chris@0 399 $this->assertRaw('The <em class="placeholder">Bartik</em> theme has been uninstalled');
Chris@0 400 // Seven is the second in the list.
Chris@0 401 $this->clickLink(t('Uninstall'));
Chris@0 402 $this->assertRaw('The <em class="placeholder">Seven</em> theme has been uninstalled');
Chris@0 403
Chris@0 404 // Check that the classy theme still can't be uninstalled as it is hidden.
Chris@0 405 $this->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
Chris@0 406 }
Chris@0 407
Chris@0 408 /**
Chris@0 409 * Tests installing a theme and setting it as default.
Chris@0 410 */
Chris@0 411 public function testInstallAndSetAsDefault() {
Chris@0 412 $this->drupalGet('admin/appearance');
Chris@0 413 // Bartik is uninstalled in the test profile and has the third "Install and
Chris@0 414 // set as default" link.
Chris@0 415 $this->clickLink(t('Install and set as default'), 2);
Chris@0 416 // Test the confirmation message.
Chris@0 417 $this->assertText('Bartik is now the default theme.');
Chris@0 418 // Make sure Bartik is now set as the default theme in config.
Chris@0 419 $this->assertEqual($this->config('system.theme')->get('default'), 'bartik');
Chris@0 420
Chris@0 421 // This checks for a regression. See https://www.drupal.org/node/2498691.
Chris@0 422 $this->assertNoText('The bartik theme was not found.');
Chris@0 423
Chris@0 424 $themes = \Drupal::service('theme_handler')->rebuildThemeData();
Chris@0 425 $version = $themes['bartik']->info['version'];
Chris@0 426
Chris@0 427 // Confirm Bartik is indicated as the default theme.
Chris@0 428 $this->assertTextPattern('/Bartik ' . preg_quote($version) . '\s{2,}\(default theme\)/');
Chris@0 429 }
Chris@0 430
Chris@16 431 /**
Chris@16 432 * Test the theme settings form when logo and favicon features are disabled.
Chris@16 433 */
Chris@16 434 public function testThemeSettingsNoLogoNoFavicon() {
Chris@16 435 // Install theme with no logo and no favicon feature.
Chris@16 436 $this->container->get('theme_handler')->install(['test_theme_settings_features']);
Chris@16 437 // Visit this theme's settings page.
Chris@16 438 $this->drupalGet('admin/appearance/settings/test_theme_settings_features');
Chris@16 439 $edit = [];
Chris@16 440 $this->drupalPostForm('admin/appearance/settings/test_theme_settings_features', $edit, t('Save configuration'));
Chris@16 441 $this->assertText('The configuration options have been saved.');
Chris@16 442 }
Chris@16 443
Chris@0 444 }