function FileCacheFactoryTest::testGet

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php \Drupal\Tests\Component\FileCache\FileCacheFactoryTest::testGet()
  2. 8.9.x core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php \Drupal\Tests\Component\FileCache\FileCacheFactoryTest::testGet()
  3. 10 core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php \Drupal\Tests\Component\FileCache\FileCacheFactoryTest::testGet()

@covers ::get

File

core/tests/Drupal/Tests/Component/FileCache/FileCacheFactoryTest.php, line 41

Class

FileCacheFactoryTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Component%21FileCache%21FileCacheFactory.php/class/FileCacheFactory/11.x" title="Creates a FileCache object." class="local">\Drupal\Component\FileCache\FileCacheFactory</a> @group FileCache

Namespace

Drupal\Tests\Component\FileCache

Code

public function testGet() : void {
    $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);
}

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