You are here

public function ModuleHandlerTest::testResetImplementations in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 450
Contains \Drupal\Tests\Core\Extension\ModuleHandlerTest.

Class

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

Namespace

Drupal\Tests\Core\Extension

Code

public function testResetImplementations() {

  // Prime caches
  $this->moduleHandler
    ->getImplementations('hook');
  $this->moduleHandler
    ->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'));
  $this->moduleHandler
    ->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'));
  $this->moduleHandler
    ->getImplementations('hook');
}