class ClaroTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/FunctionalTests/Theme/ClaroTest.php \Drupal\FunctionalTests\Theme\ClaroTest
  2. 10 core/tests/Drupal/FunctionalTests/Theme/ClaroTest.php \Drupal\FunctionalTests\Theme\ClaroTest
  3. 8.9.x core/tests/Drupal/FunctionalTests/Theme/ClaroTest.php \Drupal\FunctionalTests\Theme\ClaroTest

Tests the Claro theme.

@group claro

Hierarchy

Expanded class hierarchy of ClaroTest

File

core/tests/Drupal/FunctionalTests/Theme/ClaroTest.php, line 12

Namespace

Drupal\FunctionalTests\Theme
View source
class ClaroTest extends BrowserTestBase {
  
  /**
   * Modules to enable.
   *
   * Install the shortcut module so that claro.settings has its schema checked.
   * There's currently no way for Claro to provide a default and have valid
   * configuration as themes cannot react to a module install.
   *
   * @var string[]
   */
  protected static $modules = [
    'shortcut',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'claro';
  
  /**
   * Testing that Claro theme's global library is always attached.
   *
   * @see claro.info.yml
   */
  public function testRegressionMissingElementsCss() {
    $this->drupalGet('');
    $this->assertSession()
      ->statusCodeEquals(200);
    // This can be any CSS file from the global library.
    $this->assertSession()
      ->responseContains('claro/css/base/elements.css');
  }
  
  /**
   * Tests Claro's configuration schema.
   */
  public function testConfigSchema() {
    $this->drupalLogin($this->rootUser);
    $this->drupalGet('admin/modules');
    $this->assertSession()
      ->elementNotExists('css', '#block-claro-help');
    // Install the block module to ensure Claro's configuration is valid
    // according to schema.
    \Drupal::service('module_installer')->install([
      'block',
      'help',
    ]);
    $this->rebuildAll();
    $this->drupalGet('admin/modules');
    $this->assertSession()
      ->elementExists('css', '#block-claro-help');
  }
  
  /**
   * Tests that the Claro theme can be uninstalled.
   */
  public function testIsUninstallable() {
    $this->drupalLogin($this->drupalCreateUser([
      'access administration pages',
      'administer themes',
    ]));
    $this->drupalGet('admin/appearance');
    $this->cssSelect('a[title="Install <strong>Test theme</strong> as default theme"]')[0]
      ->click();
    $this->cssSelect('a[title="Uninstall Claro theme"]')[0]
      ->click();
    $this->assertSession()
      ->pageTextContains('The Claro theme has been uninstalled.');
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.