You are here

protected function MultiThemeTest::checkStyleFullyApplied in Style Switcher 3.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/MultiThemeTest.php \Drupal\Tests\styleswitcher\Functional\MultiThemeTest::checkStyleFullyApplied()

Checks the style is fully applied.

Parameters

string $name: Style name.

string $theme: Theme name.

bool $no_cookie: (optional) Whether a cookie is unset or set.

1 call to MultiThemeTest::checkStyleFullyApplied()
MultiThemeTest::testNoJsStyleSwitching in tests/src/Functional/MultiThemeTest.php
Tests style switching without javascript.

File

tests/src/Functional/MultiThemeTest.php, line 203

Class

MultiThemeTest
Tests with themes that have styleswitcher config.

Namespace

Drupal\Tests\styleswitcher\Functional

Code

protected function checkStyleFullyApplied(string $name, string $theme, bool $no_cookie = FALSE) {
  $styles = [
    'default' => [
      'type' => 'custom',
      'css_suffix' => 'styleswitcher/css/' . $theme,
    ],
    'yellow_on_purple' => [
      'type' => 'theme',
      'css_suffix' => '/yellow-on-purple.css',
    ],
    'green_text' => [
      'type' => 'theme',
      'css_suffix' => '/green-fg.css',
    ],
    'blue_back' => [
      'type' => 'theme',
      'css_suffix' => '/blue-bg.css',
    ],
  ];
  $session = $this
    ->getSession();

  // Test the cookie.
  $cookie = $no_cookie ? NULL : $styles[$name]['type'] . '/' . $name;
  $this
    ->assertSame($cookie, $session
    ->getCookie('styleswitcher[' . $theme . ']'));

  // Test an active style's CSS URL.
  $this
    ->assertActiveStylePath($styles[$name]['css_suffix'], $theme);

  // Return to the HTML page.
  $this
    ->drupalGet('styleswitcher-test-theme-per-page/' . $theme);
}