Skip to content

Commit

Permalink
Add failing test for #20300
Browse files Browse the repository at this point in the history
  • Loading branch information
rob006 committed Dec 30, 2024
1 parent b4efeb3 commit f8dc4e3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/framework/caching/FileCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,24 @@ public function testKeyPrefix()
$this->assertTrue(is_dir(dirname($cacheFile)), 'File not found ' . $cacheFile);
$this->assertEquals($value, $refMethodGet->invoke($cache, $key));
}

public function testStatCache()
{
$cache = $this->getCacheInstance();
$cache->set(__FUNCTION__, 'cache1', 2);

$normalizeKey = $cache->buildKey(__FUNCTION__);
$refClass = new \ReflectionClass($cache);
$refMethodGetCacheFile = $refClass->getMethod('getCacheFile');
$refMethodGetCacheFile->setAccessible(true);
$cacheFile = $refMethodGetCacheFile->invoke($cache, $normalizeKey);

// simulate cache expire 10 seconds ago
touch($cacheFile, time() - 10);
clearstatcache();

$this->assertFalse($cache->get(__FUNCTION__));
$this->assertTrue($cache->set(__FUNCTION__, 'cache2', 2));
$this->assertSame('cache2', $cache->get(__FUNCTION__));
}
}

0 comments on commit f8dc4e3

Please sign in to comment.