You are here

public function ColorTest::testOverrideAndResetScheme in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/color/tests/src/Functional/ColorTest.php \Drupal\Tests\color\Functional\ColorTest::testOverrideAndResetScheme()

Test whether the scheme can be set, viewed anonymously and reset.

File

core/modules/color/tests/src/Functional/ColorTest.php, line 201

Class

ColorTest
Modify the Bartik theme colors and make sure the changes are reflected on the frontend.

Namespace

Drupal\Tests\color\Functional

Code

public function testOverrideAndResetScheme() {
  $settings_path = 'admin/appearance/settings/bartik';
  $this
    ->config('system.theme')
    ->set('default', 'bartik')
    ->save();

  // Place branding block with site name and slogan into header region.
  $this
    ->drupalPlaceBlock('system_branding_block', [
    'region' => 'header',
  ]);
  $this
    ->drupalGet('');
  $this
    ->assertNoRaw('files/color/bartik-', 'Make sure the color logo is not being used.');
  $this
    ->assertRaw('bartik/logo.svg', 'Make sure the original bartik logo exists.');

  // Log in and set the color scheme to 'slate'.
  $this
    ->drupalLogin($this->bigUser);
  $edit['scheme'] = 'slate';
  $this
    ->drupalPostForm($settings_path, $edit, t('Save configuration'));

  // Visit the homepage and ensure color changes.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('');
  $this
    ->assertRaw('files/color/bartik-', 'Make sure the color logo is being used.');
  $this
    ->assertNoRaw('bartik/logo.svg', 'Make sure the original bartik logo does not exist.');

  // Log in and set the color scheme back to default (delete config).
  $this
    ->drupalLogin($this->bigUser);
  $edit['scheme'] = 'default';
  $this
    ->drupalPostForm($settings_path, $edit, t('Save configuration'));

  // Log out and ensure there is no color and we have the original logo.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('');
  $this
    ->assertNoRaw('files/color/bartik-', 'Make sure the color logo is not being used.');
  $this
    ->assertRaw('bartik/logo.svg', 'Make sure the original bartik logo exists.');
}