Unverified Commit 458e132a authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3115088 by lauriii, bnjmnm, tim.plunkett: Remove Classy as a base theme of core themes

parent b496f2d6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -13,5 +13,5 @@ dependencies:
  module:
    - block_test
  theme:
    - classy
    - stark
visibility: {  }
+0 −1
Original line number Diff line number Diff line
@@ -276,7 +276,6 @@ public function testBuildContentsCssJSSetting() {
    // Enable the Bartik theme, which specifies a CKEditor stylesheet.
    \Drupal::service('theme_installer')->install(['bartik']);
    $this->config('system.theme')->set('default', 'bartik')->save();
    $expected[] = file_url_transform_relative(file_create_url('core/themes/classy/css/components/media-embed-error.css')) . $query_string;
    $expected[] = file_url_transform_relative(file_create_url('core/themes/bartik/css/base/elements.css')) . $query_string;
    $expected[] = file_url_transform_relative(file_create_url('core/themes/bartik/css/components/captions.css')) . $query_string;
    $expected[] = file_url_transform_relative(file_create_url('core/themes/bartik/css/components/table.css')) . $query_string;
+6 −6
Original line number Diff line number Diff line
@@ -84,8 +84,8 @@ public function testImport() {
    $core_extension['module']['automated_cron'] = 0;
    $core_extension['module']['ban'] = 0;
    $core_extension['module'] = module_config_sort($core_extension['module']);
    // Bartik is a subtheme of classy so classy must be enabled.
    $core_extension['theme']['classy'] = 0;
    // Bartik is a subtheme of Stable so Stable must be enabled.
    $core_extension['theme']['stable'] = 0;
    $core_extension['theme']['bartik'] = 0;
    $sync->write('core.extension', $core_extension);

@@ -503,10 +503,10 @@ public function testExtensionValidation() {
    unset($core['module']['text']);
    $module_data = $this->container->get('extension.list.module')->getList();
    $this->assertTrue(isset($module_data['node']->requires['text']), 'The Node module depends on the Text module.');
    // Bartik depends on classy.
    unset($core['theme']['classy']);
    // Bartik depends on Stable.
    unset($core['theme']['stable']);
    $theme_data = \Drupal::service('theme_handler')->rebuildThemeData();
    $this->assertTrue(isset($theme_data['bartik']->requires['classy']), 'The Bartik theme depends on the Classy theme.');
    $this->assertTrue(isset($theme_data['bartik']->requires['stable']), 'The Bartik theme depends on the Stable theme.');
    // This module does not exist.
    $core['module']['does_not_exist'] = 0;
    // This theme does not exist.
@@ -516,7 +516,7 @@ public function testExtensionValidation() {
    $this->drupalPostForm('admin/config/development/configuration', [], t('Import all'));
    $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:');
    $this->assertText('Unable to uninstall the Text module since the Node module is installed.');
    $this->assertText('Unable to uninstall the Classy theme since the Bartik theme is installed.');
    $this->assertText('Unable to uninstall the Stable theme since the Bartik theme is installed.');
    $this->assertText('Unable to install the does_not_exist module since it does not exist.');
    $this->assertText('Unable to install the does_not_exist theme since it does not exist.');
  }
+16 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Extension\Exception\UnknownExtensionException;
use Drupal\Core\Field\Plugin\Field\FieldWidget\EntityReferenceAutocompleteWidget;

/**
@@ -316,3 +317,18 @@ function system_post_update_entity_revision_metadata_bc_cleanup() {
    $last_installed_schema_repository->setLastInstalledDefinition($entity_type);
  }
}

/**
 * Uninstall Classy if it is no longer needed.
 */
function system_post_update_uninstall_classy() {
  /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
  $theme_installer = \Drupal::getContainer()->get('theme_installer');
  try {
    $theme_installer->uninstall(['classy']);
  }
  catch (\InvalidArgumentException | UnknownExtensionException $exception) {
    // Exception is thrown if Classy wasn't installed or if there are themes
    // depending on it.
  }
}
+88 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\system\Functional\Update;

use Drupal\FunctionalTests\Update\UpdatePathTestBase;

/**
 * Ensures that update hook uninstalls Classy when it's no longer needed.
 *
 * @group Update
 * @see system_post_update_uninstall_classy()
 */
class ClassyUninstallUpdateTest extends UpdatePathTestBase {

  /**
   * {@inheritdoc}
   */
  protected function setDatabaseDumpFiles() {
    $this->databaseDumpFiles = [
      __DIR__ . '/../../../fixtures/update/drupal-8.8.0.bare.standard.php.gz',
    ];
  }

  /**
   * Ensures that Classy is disabled if it's no longer needed.
   */
  public function testUpdate() {
    /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
    $theme_handler = $this->container->get('theme_handler');
    $this->assertTrue($theme_handler->themeExists('classy'));

    $this->runUpdates();

    // Ensure that Classy is not installed after running updates.
    $theme_handler->refreshInfo();
    $this->assertFalse($theme_handler->themeExists('classy'));
    $this->assertTrue($theme_handler->themeExists('stable'));
  }

  /**
   * Ensures that updates run without errors when Classy is not installed.
   */
  public function testUpdateClassyNotInstalled() {
    /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
    $theme_handler = $this->container->get('theme_handler');
    $theme_list = array_keys($theme_handler->listInfo());
    /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
    $theme_installer = $this->container->get('theme_installer');
    $theme_installer->install(['stark']);
    $this->container->get('config.factory')
      ->getEditable('system.theme')
      ->set('default', 'stark')
      ->set('admin', '')
      ->save();
    $theme_handler->refreshInfo();

    // Uninstall all themes that were installed prior to enabling Stark.
    $theme_installer->uninstall($theme_list);

    // Ensure that Classy is not installed anymore.
    $theme_handler->refreshInfo();
    $this->assertFalse($theme_handler->themeExists('classy'));

    $this->runUpdates();

    $theme_handler->refreshInfo();
    $this->assertFalse($theme_handler->themeExists('classy'));
  }

  /**
   * Ensures that updates run without errors when Classy is still needed.
   */
  public function testUpdateClassyNeeded() {
    /** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
    $theme_handler = $this->container->get('theme_handler');
    /** @var \Drupal\Core\Extension\ThemeInstallerInterface $theme_installer */
    $theme_installer = $this->container->get('theme_installer');
    $theme_installer->install(['test_theme']);
    $this->assertTrue($theme_handler->themeExists('classy'));

    $this->runUpdates();

    // Ensure that Classy is still installed after running tests.
    $theme_handler->refreshInfo();
    $this->assertTrue($theme_handler->themeExists('classy'));
  }

}
Loading