public function MultiThemeTest::testNoJsStyleSwitching in Style Switcher 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/MultiThemeTest.php \Drupal\Tests\styleswitcher\Functional\MultiThemeTest::testNoJsStyleSwitching()
Tests style switching without javascript.
File
- tests/
src/ Functional/ MultiThemeTest.php, line 154
Class
- MultiThemeTest
- Tests with themes that have styleswitcher config.
Namespace
Drupal\Tests\styleswitcher\FunctionalCode
public function testNoJsStyleSwitching() {
$assert = $this
->assertSession();
// Open a page where the test theme is active. The theme's default style
// must be active at first.
$this
->drupalGet('styleswitcher-test-theme-per-page/styleswitcher_test_theme');
$this
->checkStyleFullyApplied('blue_back', 'styleswitcher_test_theme', TRUE);
// Test style switching.
$this
->click('a.style-switcher.style-green-text');
// Test we're on the same page after the click.
$assert
->addressEquals('styleswitcher-test-theme-per-page/styleswitcher_test_theme');
$this
->checkStyleFullyApplied('green_text', 'styleswitcher_test_theme');
// Leave the shared style (provided by a base theme) as active for this
// theme before going to the base theme.
$this
->click('a.style-switcher.style-yellow-on-purple');
$this
->checkStyleFullyApplied('yellow_on_purple', 'styleswitcher_test_theme');
// Open a page where the base theme is active. Although the shared style is
// active for the child theme, it must not be active for this one. This
// theme doesn't have own default style, so the blank style must be active.
$this
->drupalGet('styleswitcher-test-theme-per-page/styleswitcher_test_base_theme');
$this
->checkStyleFullyApplied('default', 'styleswitcher_test_base_theme', TRUE);
$this
->click('a.style-switcher.style-yellow-on-purple');
// Test we're on the same page after the click.
$assert
->addressEquals('styleswitcher-test-theme-per-page/styleswitcher_test_base_theme');
$this
->checkStyleFullyApplied('yellow_on_purple', 'styleswitcher_test_base_theme');
// Test the blank style resets others.
$this
->click('a.style-switcher.style-default');
$this
->checkStyleFullyApplied('default', 'styleswitcher_test_base_theme');
// Test the active style on the previous theme is preserved.
$this
->drupalGet('styleswitcher-test-theme-per-page/styleswitcher_test_theme');
$this
->checkStyleFullyApplied('yellow_on_purple', 'styleswitcher_test_theme');
}