Skip to content

Commit fbc5afa

Browse files
authored
test: fix a bug that caused MemcachedHandlerTest::testGetMetaData() to fail in rare cases
1 parent 72cd330 commit fbc5afa

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/system/Cache/Handlers/MemcachedHandlerTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,14 @@ public function testGetMetaData()
191191
$this->assertFalse($this->memcachedHandler->getMetaData(self::$dummy));
192192

193193
$actual = $this->memcachedHandler->getMetaData(self::$key1);
194-
$this->assertLessThanOrEqual(60, $actual['expire'] - $time);
194+
195+
// This test is time-dependent, and depending on the timing,
196+
// seconds in `$time` (e.g. 12:00:00.9999) and seconds of
197+
// `$this->memcachedHandler->save()` (e.g. 12:00:01.0000)
198+
// may be off by one second. In that case, the following calculation
199+
// will result in maximum of (60 + 1).
200+
$this->assertLessThanOrEqual(60 + 1, $actual['expire'] - $time);
201+
195202
$this->assertLessThanOrEqual(1, $actual['mtime'] - $time);
196203
$this->assertSame('value', $actual['data']);
197204
}

0 commit comments

Comments
 (0)