You are here

public function ClassyUninstallUpdateTest::testUpdateClassyNotInstalled in Drupal 9

Ensures that updates run without errors when Classy is not installed.

File

core/modules/system/tests/src/Functional/Update/ClassyUninstallUpdateTest.php, line 44

Class

ClassyUninstallUpdateTest
Ensures that update hook uninstalls Classy when it's no longer needed.

Namespace

Drupal\Tests\system\Functional\Update

Code

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'));
}