ClaroTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace Drupal\FunctionalTests\Theme;
  3. use Drupal\Tests\BrowserTestBase;
  4. /**
  5. * Tests the Claro theme.
  6. *
  7. * @group claro
  8. */
  9. class ClaroTest extends BrowserTestBase {
  10. /**
  11. * Modules to enable.
  12. *
  13. * Install the shortcut module so that claro.settings has its schema checked.
  14. * There's currently no way for Claro to provide a default and have valid
  15. * configuration as themes cannot react to a module install.
  16. *
  17. * @var string[]
  18. */
  19. public static $modules = ['shortcut'];
  20. /**
  21. * {@inheritdoc}
  22. */
  23. protected $defaultTheme = 'claro';
  24. /**
  25. * Testing that Claro theme's global library is always attached.
  26. *
  27. * @see claro.info.yml
  28. */
  29. public function testRegressionMissingElementsCss() {
  30. $this->drupalGet('');
  31. $this->assertSession()->statusCodeEquals(200);
  32. // This can be any CSS file from the global library.
  33. $this->assertSession()->responseContains('claro/css/base/elements.css');
  34. }
  35. /**
  36. * Test Claro's configuration schema.
  37. */
  38. public function testConfigSchema() {
  39. $this->drupalLogin($this->rootUser);
  40. $this->drupalGet('admin/modules');
  41. $this->assertSession()->elementNotExists('css', '#block-claro-help');
  42. // Install the block module to ensure Claro's configuration is valid
  43. // according to schema.
  44. \Drupal::service('module_installer')->install(['block', 'help']);
  45. $this->rebuildAll();
  46. $this->drupalGet('admin/modules');
  47. $this->assertSession()->elementExists('css', '#block-claro-help');
  48. }
  49. /**
  50. * Tests that the Claro theme can be uninstalled, despite being experimental.
  51. *
  52. * @todo Remove in https://www.drupal.org/project/drupal/issues/3066007
  53. */
  54. public function testIsUninstallable() {
  55. $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer themes']));
  56. $this->drupalGet('admin/appearance');
  57. $this->cssSelect('a[title="Install Seven as default theme"]')[0]->click();
  58. $this->cssSelect('a[title="Uninstall Claro theme"]')[0]->click();
  59. $this->assertText('The Claro theme has been uninstalled.');
  60. }
  61. }