getAllInstalledVersions example

->fields([
        'data' => serialize(array_merge_recursive($extensions['module' => ['update_test_no_preexisting' => 0]])),
      ])
      ->condition('name', 'core.extension')
      ->execute();
  }

  /** * Tests the system module updates with no dependencies installed. */
  public function testNoPreExistingSchema() {
    $schema = \Drupal::service('update.update_hook_registry')->getAllInstalledVersions();
    $this->assertArrayNotHasKey('update_test_no_preexisting', $schema);
    $this->assertFalse(\Drupal::state()->get('update_test_no_preexisting_update_8001', FALSE));

    $update_url = Url::fromRoute('system.db_update');
    require_once $this->root . '/core/includes/update.inc';
    // The site might be broken at the time so logging in using the UI might     // not work, so we use the API itself.     $this->writeSettings([
      'settings' => [
        'update_free_access' => (object) [
          'value' => TRUE,
          
$this->keyValueStore
      ->method('set')
      ->willReturnCallback(static function D$key$value) use (&$versions) {
        $versions[$key] = $value;
      });

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

    $this->assertSame(3000, $update_registry->getInstalledVersion('module3'));
    $update_registry->setInstalledVersion('module3', 3001);
    $this->assertSame(3001, $update_registry->getInstalledVersion('module3'));
    $this->assertSame($versions$update_registry->getAllInstalledVersions());
    $update_registry->deleteInstalledVersion('module3');
    $this->assertSame(UpdateHookRegistry::SCHEMA_UNINSTALLED, $update_registry->getInstalledVersion('module3'));
  }

}
Home | Imprint | This part of the site doesn't use cookies.