function ColorTest::testValidColor

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

Tests whether the provided color is valid.

File

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

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 testValidColor() {
    $this->config('system.theme')
        ->set('default', 'bartik')
        ->save();
    $settings_path = 'admin/appearance/settings/bartik';
    $this->drupalLogin($this->bigUser);
    $edit['scheme'] = '';
    foreach ($this->colorTests as $color => $is_valid) {
        $edit['palette[bg]'] = $color;
        $this->drupalPostForm($settings_path, $edit, t('Save configuration'));
        if ($is_valid) {
            $this->assertText('The configuration options have been saved.');
        }
        else {
            $this->assertText('You must enter a valid hexadecimal color value for Main background.');
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.