public function ColorTest::testOverrideAndResetScheme in Drupal 9
Same name and namespace in other branches
- 8 core/modules/color/tests/src/Functional/ColorTest.php \Drupal\Tests\color\Functional\ColorTest::testOverrideAndResetScheme()
Tests whether the scheme can be set, viewed anonymously and reset.
File
- core/
modules/ color/ tests/ src/ Functional/ ColorTest.php, line 207
Class
- ColorTest
- Modify the Bartik theme colors and make sure the changes are reflected on the frontend.
Namespace
Drupal\Tests\color\FunctionalCode
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('');
// Make sure the color logo is not being used.
$this
->assertSession()
->responseNotContains('files/color/bartik-');
// Make sure the original bartik logo exists.
$this
->assertSession()
->responseContains('bartik/logo.svg');
// Log in and set the color scheme to 'slate'.
$this
->drupalLogin($this->bigUser);
$edit['scheme'] = 'slate';
$this
->drupalGet($settings_path);
$this
->submitForm($edit, 'Save configuration');
// Visit the homepage and ensure color changes.
$this
->drupalLogout();
$this
->drupalGet('');
// Make sure the color logo is being used.
$this
->assertSession()
->responseContains('files/color/bartik-');
// Make sure the original bartik logo does not exist.
$this
->assertSession()
->responseNotContains('bartik/logo.svg');
// Log in and set the color scheme back to default (delete config).
$this
->drupalLogin($this->bigUser);
$edit['scheme'] = 'default';
$this
->drupalGet($settings_path);
$this
->submitForm($edit, 'Save configuration');
// Log out and ensure there is no color and we have the original logo.
$this
->drupalLogout();
$this
->drupalGet('');
// Make sure the color logo is not being used.
$this
->assertSession()
->responseNotContains('files/color/bartik-');
// Make sure the original bartik logo exists.
$this
->assertSession()
->responseContains('bartik/logo.svg');
}