Skip to content

Commit 51a3619

Browse files
committed
Added tests for #855
1 parent a7412d3 commit 51a3619

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lib/Phpfastcache/Drivers/Solr/Driver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public function getStats(): DriverStatistic
257257
. rtrim($this->config->getPath(), '/')
258258
. '/solr/admin/info/system';
259259

260-
if (($content = \file_get_contents($adminSystemInfoUrl)) !== false) {
260+
if (($content = @\file_get_contents($adminSystemInfoUrl)) !== false) {
261261
try {
262262
$serverSystemInfo = \json_decode($content, true, 512, \JSON_THROW_ON_ERROR);
263263
} catch (\JsonException) {

tests/lib/Helper/TestHelper.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,12 @@ public function accessInaccessibleMember($obj, $prop): mixed
305305
*/
306306
public function errorHandler(int $errno, string $errstr, string $errfile, int $errline): void
307307
{
308-
$errorType = '';
308+
// Silenced errors
309+
if (!(error_reporting() & $errno)){
310+
return;
311+
}
309312

313+
$errorType = '';
310314
switch ($errno) {
311315
case E_PARSE:
312316
case E_ERROR:
@@ -393,6 +397,18 @@ public function runCRUDTests(ExtendedCacheItemPoolInterface|PhpfastcacheAbstract
393397
$cacheItem = $pool->getItem($cacheKey);
394398
$this->printInfoText('Using cache key: ' . $cacheKey);
395399

400+
/**
401+
* Default TTL - 1sec is for dealing with potential script execution delay
402+
* @see https://github.com/PHPSocialNetwork/phpfastcache/issues/855
403+
*/
404+
if($cacheItem->getTtl() < $pool->getConfig()->getDefaultTtl() - 1) {
405+
$this->assertFail(\sprintf(
406+
'The expected TTL of the cache item was ~%ds, got %ds',
407+
$pool->getConfig()->getDefaultTtl(),
408+
$cacheItem->getTtl()
409+
));
410+
}
411+
396412
$cacheItem->set($cacheValue)
397413
->addTags([$cacheTag, $cacheTag2]);
398414

0 commit comments

Comments
 (0)