function FileCacheTest::testSet

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/FileCache/FileCacheTest.php \Drupal\Tests\Component\FileCache\FileCacheTest::testSet()
  2. 8.9.x core/tests/Drupal/Tests/Component/FileCache/FileCacheTest.php \Drupal\Tests\Component\FileCache\FileCacheTest::testSet()
  3. 11.x core/tests/Drupal/Tests/Component/FileCache/FileCacheTest.php \Drupal\Tests\Component\FileCache\FileCacheTest::testSet()

@covers ::set

File

core/tests/Drupal/Tests/Component/FileCache/FileCacheTest.php, line 106

Class

FileCacheTest
@coversDefaultClass \Drupal\Component\FileCache\FileCache @group FileCache

Namespace

Drupal\Tests\Component\FileCache

Code

public function testSet() : void {
    $filename = __DIR__ . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'llama-23.txt';
    $realpath = realpath($filename);
    $cid = 'prefix:test:' . $realpath;
    $data = [
        'mtime' => filemtime($realpath),
        'filepath' => $realpath,
        'data' => 23,
    ];
    $this->fileCache
        ->set($filename, 23);
    $result = $this->staticFileCache
        ->fetch([
        $cid,
    ]);
    $this->assertEquals([
        $cid => $data,
    ], $result);
    // Cleanup static caches.
    $this->fileCache
        ->delete($filename);
}

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