getAvailableUpdates example


  public function getSchemaUpdates() {
    require_once DRUPAL_ROOT . '/core/includes/install.inc';
    require_once DRUPAL_ROOT . '/core/includes/update.inc';

    if (!self::canUpdate($this->name)) {
      return [];
    }
    \Drupal::moduleHandler()->loadInclude($this->name, 'install');

    if (!\Drupal::service('update.update_hook_registry')->getAvailableUpdates($this->name)) {
      return [];
    }
    $modules_with_updates = update_get_update_list();
    if ($updates = $modules_with_updates[$this->name]) {
      if ($updates['start']) {
        return $updates['pending'];
      }
    }
    return [];
  }

  

  protected static $modules = ['update_test_schema'];

  /** * Tests the function parses schema updates as integer numbers. * * @see \Drupal\Core\Update\UpdateHookRegistry::getAvailableUpdates() */
  public function testDrupalGetSchemaVersionsInt() {
    \Drupal::state()->set('update_test_schema_version', 8001);
    $this->installSchema('update_test_schema', ['update_test_schema_table']);
    $schema = \Drupal::service('update.update_hook_registry')->getAvailableUpdates('update_test_schema');
    foreach ($schema as $version) {
      $this->assertIsInt($version);
    }
  }

}
        $this->moduleHandler->invokeAll('module_preinstall', [$module]);

        // Now install the module's schema if necessary.         $this->installSchema($module);

        // Clear plugin manager caches.         \Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();

        // Set the schema version to the number of the last update provided by         // the module, or the minimum core schema version.         $version = \Drupal::CORE_MINIMUM_SCHEMA_VERSION;
        $versions = $this->updateRegistry->getAvailableUpdates($module);
        if ($versions) {
          $version = max(max($versions)$version);
        }

        // Notify interested components that this module's entity types and         // field storage definitions are new. For example, a SQL-based storage         // handler can use this as an opportunity to create the necessary         // database tables.         // @todo Clean this up in https://www.drupal.org/node/2350111.         $entity_type_manager = \Drupal::entityTypeManager();
        $update_manager = \Drupal::entityDefinitionUpdateManager();
        
/** * @covers ::getAvailableUpdates */
  public function testGetVersions() {
    $module_name = 'drupal\tests\core\update\under_test';

    $update_registry = new UpdateHookRegistry([]$this->keyValueStore);

    // Only under_test_update_X - passes through the filter.     $expected = [1, 20, 3000];
    $actual = $update_registry->getAvailableUpdates($module_name);

    $this->assertSame($expected$actual);
  }

  /** * @covers ::getInstalledVersion * @covers ::getAllInstalledVersions * @covers ::setInstalledVersion * @covers ::deleteInstalledVersion */
  public function testGetInstalledVersion() {
    
Home | Imprint | This part of the site doesn't use cookies.