function ModuleHandlerTest::testWriteCache

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

Tests that write cache calls through to cache library correctly.

@covers ::writeCache

File

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

Class

ModuleHandlerTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Extension%21ModuleHandler.php/class/ModuleHandler/11.x" 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 testWriteCache() : void {
    $module_handler = $this->getModuleHandler();
    $this->cacheBackend
        ->expects($this->exactly(2))
        ->method('get')
        ->willReturn(NULL);
    $this->cacheBackend
        ->expects($this->exactly(2))
        ->method('set')
        ->with($this->logicalOr('module_implements', 'hook_info'));
    $module_handler->invokeAllWith('hook', function (callable $hook, string $module) {
    });
    $module_handler->writeCache();
}

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