UpdateRegistry example

/** * @covers ::getPendingUpdateFunctions */
  public function testGetPendingUpdateFunctionsNoExistingUpdates() {
    $this->setupBasicExtensions();

    $key_value = $this->prophesize(KeyValueStoreInterface::class);
    $key_value->get('existing_updates', [])->willReturn([]);
    $key_value = $key_value->reveal();

    $update_registry = new UpdateRegistry('vfs://drupal', 'sites/default', [
      'module_a',
      'module_b',
      'theme_d',
    ]$key_value, FALSE);

    $this->assertEquals([
      'module_a_post_update_a',
      'module_a_post_update_b',
      'module_b_post_update_a',
      'theme_d_post_update_b',
      'theme_d_post_update_c',
    ],
use ContainerAwareTrait;

  /** * Creates a new UpdateRegistry instance. * * @return \Drupal\Core\Update\UpdateRegistry * The update registry instance. */
  public function create() {
    $extensions = array_merge(array_keys($this->container->get('module_handler')->getModuleList())array_keys($this->container->get('theme_handler')->listInfo()));
    return new UpdateRegistry($this->container->getParameter('app.root')$this->container->getParameter('site.path')$extensions$this->container->get('keyvalue')->get('post_update'));
  }

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