getUpdateFunctions example


  public function testGetUpdateFunctions() {
    $this->setupBasicExtensions();
    $key_value = $this->prophesize(KeyValueStoreInterface::class)->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']array_values($update_registry->getUpdateFunctions('module_a')));
    $this->assertEquals(['module_b_post_update_a']array_values($update_registry->getUpdateFunctions('module_b')));
    $this->assertEquals(['theme_d_post_update_b', 'theme_d_post_update_c']array_values($update_registry->getUpdateFunctions('theme_d')));
  }

  /** * @covers ::registerInvokedUpdates */
  public function testRegisterInvokedUpdatesWithoutExistingUpdates() {
    $this->setupBasicExtensions();
    $key_value = $this->prophesize(KeyValueStoreInterface::class);
    $key_value->get('existing_updates', [])
      
public function testThemeUpdateManagement() {
    // Install modules the theme is dependent on and enable the post update     // function.     \Drupal::state()->set('test_theme_depending_on_modules.post_update', TRUE);
    \Drupal::service('module_installer')->install([
      'test_module_required_by_theme',
      'test_another_module_required_by_theme',
    ]);

    /** @var \Drupal\Core\Update\UpdateRegistry $post_update_registry */
    $post_update_registry = \Drupal::service('update.post_update_registry');
    $this->assertEmpty($post_update_registry->getUpdateFunctions('test_theme_depending_on_modules'), 'No updates test_theme_depending_on_modules for prior to install.');
    \Drupal::service('theme_installer')->install(['test_theme_depending_on_modules']);

    // Ensure the post update function has been added to the list of     // existing updates.     $this->assertContains('test_theme_depending_on_modules_post_update_module_install', \Drupal::service('keyvalue')->get('post_update')->get('existing_updates'));

    \Drupal::service('theme_installer')->uninstall(['test_theme_depending_on_modules']);
    // Ensure the post update function has been removed from the list of     // existing updates.     $this->assertNotContains('test_theme_depending_on_modules_post_update_module_install', \Drupal::service('keyvalue')->get('post_update')->get('existing_updates'));
  }

  
      $this->enabledExtensions = $new_extension_list;

      foreach ($uninstalled_extensions as $uninstalled_extension) {
        $this->filterOutInvokedUpdatesByExtension($uninstalled_extension);
      }
      foreach ($installed_extensions as $installed_extension) {
        // Ensure that all post_update functions are registered already. This         // should include existing post-updates, as well as any specified as         // having been previously removed, to ensure that newly installed and         // updated sites have the same entries in the registry.         $this->registerInvokedUpdates(array_merge(
          $this->getUpdateFunctions($installed_extension),
          array_keys($this->getRemovedPostUpdates($installed_extension))
        ));
      }
    }
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents() {
    $events[ConfigEvents::SAVE][] = ['onConfigSave'];
    
Home | Imprint | This part of the site doesn't use cookies.