function ModuleHandlerTest::testResetImplementations

Same name in other branches
  1. 9 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()

Test internal implementation cache reset.

@covers ::resetImplementations

File

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

Class

ModuleHandlerTest
@coversDefaultClass \Drupal\Core\Extension\ModuleHandler @runTestsInSeparateProcesses

Namespace

Drupal\Tests\Core\Extension

Code

public function testResetImplementations() {
    $module_handler = $this->getModuleHandler();
    // Prime caches
    $module_handler->getImplementations('hook');
    $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->getImplementations('hook');
}

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