function StableUninstallUpdateTest::testUpdateStableNotInstalled

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

File

core/modules/system/tests/src/Functional/Update/StableUninstallUpdateTest.php, line 45

Class

StableUninstallUpdateTest
Ensures that update hook uninstalls Stable when it's no longer needed.

Namespace

Drupal\Tests\system\Functional\Update

Code

public function testUpdateStableNotInstalled() {
    
    /** @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 Stable is not installed anymore.
    $theme_handler->refreshInfo();
    $this->assertFalse($theme_handler->themeExists('stable'));
    $this->runUpdates();
    $theme_handler->refreshInfo();
    $this->assertFalse($theme_handler->themeExists('stable'));
}

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