Skip to content

Commit c1752b8

Browse files
committed
Fixed randomly failing test Github-#560
1 parent 629ebbe commit c1752b8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/issues/Github-560.test.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
$cacheItem = $cacheInstance->getItem($cacheKey);
3535
$cacheItem->set($string);
3636
$cacheInstance->save($cacheItem);
37-
$now = time();
3837

3938
/**
4039
* Delete memory references
@@ -45,10 +44,15 @@
4544
$cacheInstance->detachAllItems();
4645
$cacheItem = $cacheInstance->getItem($cacheKey);
4746

48-
if($cacheItem->getTtl() === $defaultTTl){
47+
/**
48+
* Round up to the nearest 10 to avoid a potential issue
49+
* due to the time spend to write the cache on disk that will
50+
* loss 1 second to the cache ttl :/
51+
*/
52+
if((int) ceil($cacheItem->getTtl() / 10) * 10 === $defaultTTl){
4953
$testHelper->printPassText('The cache Item TTL matches the default TTL after 30 days.');
5054
}else{
51-
$testHelper->printFailText('The cache Item TTL des not matches the default TTL after 30 days, got the following value: ' . $cacheItem->getTtl());
55+
$testHelper->printFailText('The cache Item TTL des not matches the default TTL after 30 days, got the following value: ' . ceil($cacheItem->getTtl() / 10) * 10);
5256
}
5357

5458
$testHelper->terminateTest();

0 commit comments

Comments
 (0)