public function InitialStateTest::testDynamicLink in Style Switcher 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/InitialStateTest.php \Drupal\Tests\styleswitcher\Functional\InitialStateTest::testDynamicLink()
Tests the dynamic link tag exists and it's the last of stylesheets.
File
- tests/
src/ Functional/ InitialStateTest.php, line 29
Class
- InitialStateTest
- Tests the module in its initial state.
Namespace
Drupal\Tests\styleswitcher\FunctionalCode
public function testDynamicLink() {
$assert = $this
->assertSession();
$this
->drupalGet('');
$link = $assert
->elementExists('css', 'head > link:last-child[rel="stylesheet"]');
$this
->assertSame('styleswitcher-css', $link
->getAttribute('id'));
$this
->assertSame('all', $link
->getAttribute('media'));
// The href may contain path prefix and query params.
if (floatval(\Drupal::VERSION) >= 8.800000000000001) {
$this
->assertStringContainsString("/styleswitcher/css/{$this->defaultTheme}", $link
->getAttribute('href'));
}
else {
$this
->assertContains("/styleswitcher/css/{$this->defaultTheme}", $link
->getAttribute('href'));
}
}