public function MultiThemeTest::testConfigThemeForms 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::testConfigThemeForms()
Tests config theme forms.
File
- tests/
src/ Functional/ MultiThemeTest.php, line 79
Class
- MultiThemeTest
- Tests with themes that have styleswitcher config.
Namespace
Drupal\Tests\styleswitcher\FunctionalCode
public function testConfigThemeForms() {
$assert = $this
->assertSession();
$user = $this
->drupalCreateUser([
'administer styleswitcher',
]);
$this
->drupalLogin($user);
foreach ($this->themeStyles as $theme => $styles) {
$styles = $styles['back'];
// Test the tab exists.
$this
->drupalGet('admin/config/user-interface/styleswitcher');
$tabs = $this
->getSession()
->getPage()
->find('css', '#block-local-tasks-block');
$theme_config_path = '/admin/config/user-interface/styleswitcher/settings/' . $theme;
$tab = $assert
->elementExists('css', 'a[href$="' . $theme_config_path . '"]', $tabs);
// Test the form exists.
$tab
->click();
$form = $assert
->elementExists('css', 'form#styleswitcher-config-theme');
// Test the number of styles.
$rows = $form
->findAll('css', '#styleswitcher-styles-table tbody tr');
$this
->assertCount(count($styles), $rows);
// Test styles are in order.
foreach ($styles as $i => $label) {
$label_cell = $rows[$i]
->find('css', 'td:first-child');
if (floatval(\Drupal::VERSION) >= 8.800000000000001) {
$this
->assertStringContainsString($label, $label_cell
->getText());
}
else {
$this
->assertContains($label, $label_cell
->getText());
}
}
}
}