function ModuleHandlerTest::testResetImplementations

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testResetImplementations()
  2. 10 core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testResetImplementations()
  3. 11.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testResetImplementations()

Tests internal implementation cache reset.

@covers ::resetImplementations

File

core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php, line 524

Class

ModuleHandlerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Extension%21ModuleHandler.php/class/ModuleHandler/9" title="Class that manages modules in a Drupal installation." class="local">\Drupal\Core\Extension\ModuleHandler</a> @runTestsInSeparateProcesses

Namespace

Drupal\Tests\Core\Extension

Code

public function testResetImplementations() {
    $module_handler = $this->getModuleHandler();
    // Prime caches
    $module_handler->invokeAllWith('hook', function (callable $hook, string $module) {
    });
    $module_handler->getHookInfo();
    // Reset all caches internal and external.
    $this->cacheBackend
        ->expects($this->once())
        ->method('delete')
        ->with('hook_info');
    $this->cacheBackend
        ->expects($this->exactly(2))
        ->method('set')
        ->with($this->logicalOr('module_implements', 'hook_info'));
    $module_handler->resetImplementations();
    // Request implementation and ensure hook_info and module_implements skip
    // local caches.
    $this->cacheBackend
        ->expects($this->exactly(2))
        ->method('get')
        ->with($this->logicalOr('module_implements', 'hook_info'));
    $module_handler->invokeAllWith('hook', function (callable $hook, string $module) {
    });
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.