reverted: --- b/core/modules/color/lib/Drupal/color/Tests/ColorTest.php +++ a/core/modules/color/lib/Drupal/color/Tests/ColorTest.php @@ -26,7 +26,7 @@ * * @var \Drupal\user\UserInterface */ + protected $big_user; - protected $bigUser; /** * An associative array of settings for themes. @@ -45,9 +45,6 @@ */ protected $colorTests; - /** - * {@inheritdoc} - */ public static function getInfo() { return array( 'name' => 'Color functionality', @@ -59,11 +56,11 @@ /** * {@inheritdoc} */ + function setUp() { - public function setUp() { parent::setUp(); // Create user. + $this->big_user = $this->drupalCreateUser(array('administer themes')); - $this->bigUser = $this->drupalCreateUser(array('administer themes')); // This tests the color module in Bartik. $this->themes = array( @@ -97,9 +94,9 @@ /** * Tests the Color module functionality. */ + function testColor() { - public function testColor() { foreach ($this->themes as $theme => $test_values) { + $this->_testColor($theme, $test_values); - $this->subTestColor($theme, $test_values); } } @@ -112,13 +109,13 @@ * An associative array of test settings (i.e. 'Main background', 'Text * color', 'Color set', etc) for the theme which being tested. */ + function _testColor($theme, $test_values) { - public function subTestColor($theme, $test_values) { \Drupal::config('system.theme') ->set('default', $theme) ->save(); $settings_path = 'admin/appearance/settings/' . $theme; + $this->drupalLogin($this->big_user); - $this->drupalLogin($this->bigUser); $this->drupalGet($settings_path); $this->assertResponse(200); $edit['scheme'] = ''; @@ -129,7 +126,7 @@ $stylesheets = \Drupal::config('color.' . $theme)->get('stylesheets'); foreach ($stylesheets as $stylesheet) { $this->assertPattern('|' . file_create_url($stylesheet) . '|', 'Make sure the color stylesheet is included in the content. (' . $theme . ')'); + $stylesheet_content = join("\n", file($stylesheet)); - $stylesheet_content = implode("\n", file($stylesheet)); $this->assertTrue(strpos($stylesheet_content, 'color: #123456') !== FALSE, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')'); } @@ -141,7 +138,7 @@ $this->drupalGet(''); $stylesheets = \Drupal::config('color.' . $theme)->get('stylesheets'); foreach ($stylesheets as $stylesheet) { + $stylesheet_content = join("\n", file($stylesheet)); - $stylesheet_content = implode("\n", file($stylesheet)); $this->assertTrue(strpos($stylesheet_content, 'color: ' . $test_values['scheme_color']) !== FALSE, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')'); } @@ -153,7 +150,7 @@ $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: array(); $stylesheet_content = ''; foreach ($stylesheets as $uri) { + $stylesheet_content .= join("\n", file(drupal_realpath($uri))); - $stylesheet_content .= implode("\n", file(drupal_realpath($uri))); } $this->assertTrue(strpos($stylesheet_content, 'public://') === FALSE, 'Make sure the color paths have been translated to local paths. (' . $theme . ')'); $config->set('css.preprocess', 0); @@ -163,20 +160,20 @@ /** * Tests whether the provided color is valid. */ + function testValidColor() { - public function testValidColor() { \Drupal::config('system.theme') ->set('default', 'bartik') ->save(); $settings_path = 'admin/appearance/settings/bartik'; + $this->drupalLogin($this->big_user); - $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) { - if ($is_valid) { $this->assertText('The configuration options have been saved.'); } else { only in patch2: unchanged: --- a/core/modules/color/src/Tests/ColorTest.php +++ b/core/modules/color/src/Tests/ColorTest.php @@ -29,7 +29,7 @@ class ColorTest extends WebTestBase { * * @var \Drupal\user\UserInterface */ - protected $big_user; + protected $bigUser; /** * An associative array of settings for themes. @@ -51,11 +51,11 @@ class ColorTest extends WebTestBase { /** * {@inheritdoc} */ - function setUp() { + public function setUp() { parent::setUp(); // Create user. - $this->big_user = $this->drupalCreateUser(array('administer themes')); + $this->bigUser = $this->drupalCreateUser(array('administer themes')); // This tests the color module in Bartik. $this->themes = array( @@ -89,9 +89,9 @@ function setUp() { /** * Tests the Color module functionality. */ - function testColor() { + public function testColor() { foreach ($this->themes as $theme => $test_values) { - $this->_testColor($theme, $test_values); + $this->subTestColor($theme, $test_values); } } @@ -104,13 +104,13 @@ function testColor() { * An associative array of test settings (i.e. 'Main background', 'Text * color', 'Color set', etc) for the theme which being tested. */ - function _testColor($theme, $test_values) { + public function subTestColor($theme, $test_values) { \Drupal::config('system.theme') ->set('default', $theme) ->save(); $settings_path = 'admin/appearance/settings/' . $theme; - $this->drupalLogin($this->big_user); + $this->drupalLogin($this->bigUser); $this->drupalGet($settings_path); $this->assertResponse(200); $this->assertUniqueText('Color set'); @@ -122,7 +122,7 @@ function _testColor($theme, $test_values) { $stylesheets = \Drupal::config('color.theme.' . $theme)->get('stylesheets'); foreach ($stylesheets as $stylesheet) { $this->assertPattern('|' . file_create_url($stylesheet) . '|', 'Make sure the color stylesheet is included in the content. (' . $theme . ')'); - $stylesheet_content = join("\n", file($stylesheet)); + $stylesheet_content = implode("\n", file($stylesheet)); $this->assertTrue(strpos($stylesheet_content, 'color: #123456') !== FALSE, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')'); } @@ -134,7 +134,7 @@ function _testColor($theme, $test_values) { $this->drupalGet(''); $stylesheets = \Drupal::config('color.theme.' . $theme)->get('stylesheets'); foreach ($stylesheets as $stylesheet) { - $stylesheet_content = join("\n", file($stylesheet)); + $stylesheet_content = implode("\n", file($stylesheet)); $this->assertTrue(strpos($stylesheet_content, 'color: ' . $test_values['scheme_color']) !== FALSE, 'Make sure the color we changed is in the color stylesheet. (' . $theme . ')'); } @@ -146,7 +146,7 @@ function _testColor($theme, $test_values) { $stylesheets = \Drupal::state()->get('drupal_css_cache_files') ?: array(); $stylesheet_content = ''; foreach ($stylesheets as $uri) { - $stylesheet_content .= join("\n", file(drupal_realpath($uri))); + $stylesheet_content .= implode("\n", file(drupal_realpath($uri))); } $this->assertTrue(strpos($stylesheet_content, 'public://') === FALSE, 'Make sure the color paths have been translated to local paths. (' . $theme . ')'); $config->set('css.preprocess', 0); @@ -156,20 +156,20 @@ function _testColor($theme, $test_values) { /** * Tests whether the provided color is valid. */ - function testValidColor() { + public function testValidColor() { \Drupal::config('system.theme') ->set('default', 'bartik') ->save(); $settings_path = 'admin/appearance/settings/bartik'; - $this->drupalLogin($this->big_user); + $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) { + if ($is_valid) { $this->assertText('The configuration options have been saved.'); } else {