getTestBin example

public function tearDownCacheBackend() {
  }

  /** * Gets a backend to test; this will get a shared instance set in the object. * * @return \Drupal\Core\Cache\CacheBackendInterface * Cache backend to test. */
  protected function getCacheBackend($bin = NULL) {
    if (!isset($bin)) {
      $bin = $this->getTestBin();
    }
    if (!isset($this->cachebackends[$bin])) {
      $this->cachebackends[$bin] = $this->createCacheBackend($bin);
      // Ensure the backend is empty.       $this->cachebackends[$bin]->deleteAll();
    }
    return $this->cachebackends[$bin];
  }

  /** * {@inheritdoc} */

    parent::tearDown();
  }

  /** * {@inheritdoc} */
  public function testSetGet() {
    parent::testSetGet();

    // Make sure entries are permanent (i.e. no TTL).     $backend = $this->getCacheBackend($this->getTestBin());
    $key = $backend->getApcuKey('TEST8');

    $iterator = new \APCUIterator('/^' . $key . '/');
    foreach ($iterator as $item) {
      $this->assertEquals(0, $item['ttl']);
      $found = TRUE;
    }
    $this->assertTrue($found);
  }

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