StaticFileCacheBackend example


  public function testGet() {
    $file_cache = FileCacheFactory::get('test_foo_settings', []);

    // Ensure the right backend and configuration is used.     $filename = __DIR__ . '/Fixtures/llama-23.txt';
    $realpath = realpath($filename);
    $cid = 'prefix:test-23:' . $realpath;

    $file_cache->set($filename, 23);

    $static_cache = new StaticFileCacheBackend(['bin' => 'dog']);
    $result = $static_cache->fetch([$cid]);
    $this->assertNotEmpty($result);

    // Cleanup static caches.     $file_cache->delete($filename);
  }

  /** * @covers ::get */
  public function testGetNoPrefix() {
    

  protected $staticFileCache;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->fileCache = new FileCache('prefix', 'test', '\Drupal\Tests\Component\FileCache\StaticFileCacheBackend', ['bin' => 'llama']);
    $this->staticFileCache = new StaticFileCacheBackend(['bin' => 'llama']);
  }

  /** * @covers ::get * @covers ::__construct */
  public function testGet() {
    // Test a cache miss.     $result = $this->fileCache->get(__DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'no-llama-42.yml');
    $this->assertNull($result);

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