resetImplementations example

->method('buildImplementationInfo')
      ->with('hook')
      ->willReturnOnConsecutiveCalls(
        [],
        ['mymodule' => FALSE],
      );

    // ModuleHandler::buildImplementationInfo mock returns no implementations.     $this->assertFalse($module_handler->hasImplementations('hook'));

    // Reset static caches.     $module_handler->resetImplementations();

    // ModuleHandler::buildImplementationInfo mock returns an implementation.     $this->assertTrue($module_handler->hasImplementations('hook'));
  }

  /** * Tests getImplementations. * * @covers ::invokeAllWith */
  public function testCachedGetImplementations() {
    
$module_filenames = $module_handler->getModuleList();
    $extension_config = $this->config('core.extension');
    foreach ($modules as $module) {
      if (!$module_handler->moduleExists($module)) {
        throw new \LogicException("$module module cannot be uninstalled because it is not installed.");
      }
      unset($module_filenames[$module]);
      $extension_config->clear('module.' . $module);
    }
    $extension_config->save();
    $module_handler->setModuleList($module_filenames);
    $module_handler->resetImplementations();
    // Update the kernel to remove their services.     $this->container->get('kernel')->updateModules($module_filenames$module_filenames);

    // Ensure isLoaded() is TRUE in order to make     // \Drupal\Core\Theme\ThemeManagerInterface::render() work.     // Note that the kernel has rebuilt the container; this $module_handler is     // no longer the $module_handler instance from above.     $module_handler = $this->container->get('module_handler');
    $module_handler->reload();
    foreach ($modules as $module) {
      if ($module_handler->moduleExists($module)) {
        

    throw new UnknownExtensionException(sprintf('The module %s does not exist.', $name));
  }

  /** * {@inheritdoc} */
  public function setModuleList(array $module_list = []) {
    $this->moduleList = $module_list;
    // Reset the implementations, so a new call triggers a reloading of the     // available hooks.     $this->resetImplementations();
  }

  /** * {@inheritdoc} */
  public function addModule($name$path) {
    $this->add('module', $name$path);
  }

  /** * {@inheritdoc} */
$data = [];
          $this->moduleHandler->alter($hook$data);
          break;

        default:
          $this->moduleHandler->invoke('views_test_data', $hook);
      }

      $this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook)new FormattableMarkup('The %hook hook was invoked.', ['%hook' => $hook]));
      // Reset the module implementations cache, so we ensure that the       // .views.inc file is loaded actively.       $this->moduleHandler->resetImplementations();
    }
  }

  /** * Tests how hook_views_form_substitutions() makes substitutions. * * @see views_test_data_views_form_substitutions() * @see \Drupal\views\Form\ViewsFormMainForm::preRenderViewsForm() */
  public function testViewsFormMainFormPreRender() {
    $element = [
      
    // regardless of the internal page cache module.     $this->container->get('module_installer')->uninstall(['page_cache']);

    $this->drupalGet('page_cache_form_test_immutability');

    $this->assertSession()->pageTextContains("Immutable: TRUE");

    // The immutable flag is set unconditionally by system_form_alter(), set     // a flag to tell page_cache_form_test_module_implements_alter() to disable     // that implementation.     \Drupal::state()->set('page_cache_bypass_form_immutability', TRUE);
    \Drupal::moduleHandler()->resetImplementations();
    Cache::invalidateTags(['rendered']);

    $this->drupalGet('page_cache_form_test_immutability');

    $this->assertSession()->pageTextContains("Immutable: FALSE");
  }

  /** * Tests cacheability of a CacheableResponse. * * Tests the difference between having a controller return a plain Symfony * Response object versus returning a Response object that implements the * CacheableResponseInterface. */
    // constraint and the automatically added EntityChanged constraint.     $entity_type = $this->entityTypeManager->getDefinition('entity_test_constraints');
    $default_constraints = [
      'NotNull' => [],
      'EntityChanged' => NULL,
      'EntityUntranslatableFields' => NULL,
    ];
    $this->assertEquals($default_constraints$entity_type->getConstraints());

    // Enable our test module and test extending constraints.     $this->enableModules(['entity_test_constraints']);
    $this->container->get('module_handler')->resetImplementations();

    $extra_constraints = ['Test' => []];
    $this->state->set('entity_test_constraints.build', $extra_constraints);
    // Re-fetch the entity type manager from the new container built after the     // new modules were enabled.     $this->entityTypeManager = $this->container->get('entity_type.manager');
    $this->entityTypeManager->clearCachedDefinitions();
    $entity_type = $this->entityTypeManager->getDefinition('entity_test_constraints');
    $this->assertEquals($default_constraints + $extra_constraints$entity_type->getConstraints());

    // Test altering constraints.
Home | Imprint | This part of the site doesn't use cookies.