You are here

protected function InstallUninstallTest::assertInstallModuleUpdates in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php \Drupal\Tests\system\Functional\Module\InstallUninstallTest::assertInstallModuleUpdates()
  2. 9 core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php \Drupal\Tests\system\Functional\Module\InstallUninstallTest::assertInstallModuleUpdates()

Asserts the module post update functions after install.

@internal

Parameters

string $module: The module that got installed.

1 call to InstallUninstallTest::assertInstallModuleUpdates()
InstallUninstallTest::testInstallUninstall in core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php
Tests that a fixed set of modules can be installed and uninstalled.

File

core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php, line 341

Class

InstallUninstallTest
Install/uninstall core module and confirm table creation/deletion.

Namespace

Drupal\Tests\system\Functional\Module

Code

protected function assertInstallModuleUpdates(string $module) : void {

  /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
  $post_update_registry = \Drupal::service('update.post_update_registry');
  $all_update_functions = $post_update_registry
    ->getPendingUpdateFunctions();
  $empty_result = TRUE;
  foreach ($all_update_functions as $function) {
    [
      $function_module,
    ] = explode('_post_update_', $function);
    if ($module === $function_module) {
      $empty_result = FALSE;
      break;
    }
  }
  $this
    ->assertTrue($empty_result, 'Ensures that no pending post update functions are available.');
  $existing_updates = \Drupal::keyValue('post_update')
    ->get('existing_updates', []);
  switch ($module) {
    case 'update_test_postupdate':
      $expected = [
        'update_test_postupdate_post_update_first',
        'update_test_postupdate_post_update_second',
        'update_test_postupdate_post_update_test1',
        'update_test_postupdate_post_update_test0',
        'update_test_postupdate_post_update_foo',
        'update_test_postupdate_post_update_bar',
        'update_test_postupdate_post_update_baz',
      ];
      $this
        ->assertSame($expected, $existing_updates);
      break;
  }
}