HighContrastStyleSheetTest.php in High contrast 8
File
tests/src/FunctionalJavascript/HighContrastStyleSheetTest.php
View source
<?php
namespace Drupal\Tests\high_contrast\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\high_contrast\HighContrastTrait;
class HighContrastStyleSheetTest extends WebDriverTestBase {
use HighContrastTrait;
public static $modules = [
'block',
'high_contrast',
'page_cache',
'dynamic_page_cache',
];
private $values = [];
protected function setUp() {
parent::setUp();
$this->values = [
'colors_background' => '#123123',
'colors_text' => '#abcabc',
'colors_hyperlinks' => '#defdef',
];
$this
->config('high_contrast.settings')
->setData($this->values)
->save();
}
public function testStyleSheetGenerated() {
$file_path = HIGH_CONTRAST_CSS_LOCATION;
$this
->assertFileExists($file_path);
$css_file = file_get_contents($file_path);
foreach ($this->values as $definition => $color) {
$this
->assertContains($color, $css_file, "Color {$color} has been applied for {$definition}.");
}
$new_values = [
'colors_background' => '#456456',
'colors_text' => '#789789',
'colors_hyperlinks' => '#012345',
];
$this
->config('high_contrast.settings')
->setData($new_values)
->save();
$css_file = file_get_contents($file_path);
foreach ($this->values as $definition => $color) {
$this
->assertNotContains($color, $css_file, "Color {$color} has not been applied for {$definition}.");
}
foreach ($new_values as $definition => $color) {
$this
->assertContains($color, $css_file, "Color {$color} has been applied for {$definition}.");
}
}
}