function ThemeTest::testThemeUpdateManagementRemovedPostUpdates

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest::testThemeUpdateManagementRemovedPostUpdates()
  2. 11.x core/modules/system/tests/src/Kernel/Theme/ThemeTest.php \Drupal\Tests\system\Kernel\Theme\ThemeTest::testThemeUpdateManagementRemovedPostUpdates()

Tests the update registry is correct during theme install and uninstall.

File

core/modules/system/tests/src/Kernel/Theme/ThemeTest.php, line 189

Class

ThemeTest
Tests low-level theme functions.

Namespace

Drupal\Tests\system\Kernel\Theme

Code

public function testThemeUpdateManagementRemovedPostUpdates() : void {
  // Install modules the theme is dependent on and enable the removed post
  // updates function.
  \Drupal::state()->set('test_theme_depending_on_modules.removed_post_updates', TRUE);
  \Drupal::service('module_installer')->install([
    'test_module_required_by_theme',
    'test_another_module_required_by_theme',
  ]);
  $post_update_registry = \Drupal::service('update.post_update_registry');
  $this->assertEmpty($post_update_registry->getUpdateFunctions('test_theme_depending_on_modules'), 'No updates test_theme_depending_on_modules for prior to install.');
  \Drupal::service('theme_installer')->install([
    'test_theme_depending_on_modules',
  ]);
  // Ensure the removed post update function has been added to the list of
  // existing updates.
  $this->assertContains('test_theme_depending_on_modules_post_update_foo', \Drupal::service('keyvalue')->get('post_update')
    ->get('existing_updates'));
  \Drupal::service('theme_installer')->uninstall([
    'test_theme_depending_on_modules',
  ]);
  // Ensure the removed post update function has been removed from the list of
  // existing updates.
  $this->assertNotContains('test_theme_depending_on_modules_post_update_foo', \Drupal::service('keyvalue')->get('post_update')
    ->get('existing_updates'));
}

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