fix: stabilize filesystem touch test

This commit is contained in:
Torsten Dittmann committed 2026-05-08 17:10:56 +04:00
1 parent bef0ec00c4
commit 759794356e
2 files changed
+10 -4

No files matched your search

+7 -1
View File
@@ -106,7 +106,13 @@ class Filesystem implements Adapter
{
$file = $this->getPath($key);
return file_exists($file) && touch($file);
if (! file_exists($file) || ! touch($file)) {
return false;
}
clearstatcache(true, $file);
return true;
}
/**
+3 -3
View File
@@ -62,11 +62,11 @@ abstract class Base extends TestCase
$result = self::$cache->save('touch-key', 'touch data', 'touch-key');
$this->assertEquals('touch data', $result);
sleep(2);
sleep(3);
$this->assertEquals(false, self::$cache->load('touch-key', 1, 'touch-key'));
$this->assertEquals(false, self::$cache->load('touch-key', 2, 'touch-key'));
$this->assertEquals(true, self::$cache->touch('touch-key', 'touch-key'));
$this->assertEquals('touch data', self::$cache->load('touch-key', 1, 'touch-key'));
$this->assertEquals('touch data', self::$cache->load('touch-key', 2, 'touch-key'));
$this->assertEquals(false, self::$cache->touch('missing-touch-key', 'missing-touch-key'));
self::$cache->purge('touch-key');