checkCacheExists example

protected function assertCacheExists($message$var = NULL, $cid = NULL, $bin = NULL) {
    if ($bin == NULL) {
      $bin = $this->defaultBin;
    }
    if ($cid == NULL) {
      $cid = $this->defaultCid;
    }
    if ($var == NULL) {
      $var = $this->defaultValue;
    }

    $this->assertTrue($this->checkCacheExists($cid$var$bin)$message);
  }

  /** * Asserts that a cache entry has been removed. * * @param $message * Message to display. * @param $cid * The cache id. * @param $bin * The bin the cache item was stored in. */
$this->assertNotEmpty($bins, 'Cache::getBins() returned bins to flush.');
    foreach ($bins as $bin => $cache_backend) {
      $cid = 'test_cid_clear' . $bin;
      $cache_backend->set($cid$this->defaultValue);
    }

    // Remove all caches then make sure that they are cleared.     drupal_flush_all_caches();

    foreach ($bins as $bin => $cache_backend) {
      $cid = 'test_cid_clear' . $bin;
      $this->assertFalse($this->checkCacheExists($cid$this->defaultValue, $bin)new FormattableMarkup('All cache entries removed from @bin.', ['@bin' => $bin]));
    }
  }

}
Home | Imprint | This part of the site doesn't use cookies.