You are here

public function MultiThemeTest::testDynamicLink 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::testDynamicLink()

Tests the dynamic link tag.

File

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

Class

MultiThemeTest
Tests with themes that have styleswitcher config.

Namespace

Drupal\Tests\styleswitcher\Functional

Code

public function testDynamicLink() {
  $assert = $this
    ->assertSession();
  foreach (array_keys($this->themeStyles) as $theme) {

    // Open a page where the $theme is active.
    $this
      ->drupalGet('styleswitcher-test-theme-per-page/' . $theme);
    $link = $assert
      ->elementExists('css', 'head > link:last-child[rel="stylesheet"]');

    // The href may contain path prefix and query params.
    if (floatval(\Drupal::VERSION) >= 8.800000000000001) {
      $this
        ->assertStringContainsString('/styleswitcher/css/' . $theme, $link
        ->getAttribute('href'));
    }
    else {
      $this
        ->assertContains('/styleswitcher/css/' . $theme, $link
        ->getAttribute('href'));
    }
  }
}