You are here

protected function InstallUninstallTest::assertInstallModuleUpdates in Zircon Profile 8

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

Asserts the module post update functions after install.

Parameters

string $module: The module that got installed.

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

File

core/modules/system/src/Tests/Module/InstallUninstallTest.php, line 248
Contains \Drupal\system\Tests\Module\InstallUninstallTest.

Class

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

Namespace

Drupal\system\Tests\Module

Code

protected function assertInstallModuleUpdates($module) {

  /** @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) {
    list($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 'block':
      $this
        ->assertFalse(array_diff([
        'block_post_update_disable_blocks_with_missing_contexts',
      ], $existing_updates));
      break;
    case 'update_test_postupdate':
      $this
        ->assertFalse(array_diff([
        'update_test_postupdate_post_update_first',
        'update_test_postupdate_post_update_second',
        'update_test_postupdate_post_update_test1',
        'update_test_postupdate_post_update_test0',
      ], $existing_updates));
      break;
  }
}