writeCache example

public function testWriteCache() {
    $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 Dcallable $hook, string $module) {});
    $module_handler->writeCache();
  }

  /** * Tests hook_hook_info() fetching through getHookInfo(). * * @covers ::getHookInfo * @covers ::buildHookInfo */
  public function testGetHookInfo() {
    $module_handler = $this->getModuleHandler();
    // Set up some synthetic results.

  public function onTerminate(TerminateEvent $event) {
    $this->moduleHandler->writeCache();
  }

  /** * Registers the methods in this class that should be listeners. * * @return array * An array of event listener definitions. */
  public static function getSubscribedEvents(): array {
    $events[KernelEvents::TERMINATE][] = ['onTerminate', 100];

    
public function onKernelController(ControllerEvent $event) {
    // Set the cache key on the alias manager cache decorator.     if ($event->isMainRequest()) {
      $this->aliasManager->setCacheKey(rtrim($this->currentPath->getPath($event->getRequest()), '/'));
    }
  }

  /** * Ensures system paths for the request get cached. */
  public function onKernelTerminate(TerminateEvent $event) {
    $this->aliasManager->writeCache();
  }

  /** * Registers the methods in this class that should be listeners. * * @return array * An array of event listener definitions. */
  public static function getSubscribedEvents(): array {
    $events[KernelEvents::CONTROLLER][] = ['onKernelController', 200];
    $events[KernelEvents::TERMINATE][] = ['onKernelTerminate', 200];
    
->willReturn(NULL);

    $this->assertEquals($path$this->aliasManager->getAliasByPath($path));
    // Call it twice to test the static cache.     $this->assertEquals($path$this->aliasManager->getAliasByPath($path));

    // This needs to write out the cache.     $this->cache->expects($this->once())
      ->method('set')
      ->with($this->cacheKey, [$language->getId() => [$path]](int) $_SERVER['REQUEST_TIME'] + (60 * 60 * 24));

    $this->aliasManager->writeCache();
  }

  /** * Tests the getAliasByPath method for a path that has a matching alias. * * @covers ::getAliasByPath * @covers ::writeCache */
  public function testGetAliasByPathMatch() {
    $path_part1 = $this->randomMachineName();
    $path_part2 = $this->randomMachineName();
    
Home | Imprint | This part of the site doesn't use cookies.