Skip to content

Commit 25914d4

Browse files
authored
Merge pull request #19 from Vendic/feature/redis-mandatory
Redis Connection added enforce_redis constructor param
2 parents a9f87fe + c7a909f commit 25914d4

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Checks/RedisConnection.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ class RedisConnection implements CheckInterface
1919
public function __construct(
2020
private DeploymentConfig $deploymentConfig,
2121
private Cache $cache,
22-
private CheckResultFactory $checkResultFactory
22+
private CheckResultFactory $checkResultFactory,
23+
private bool $enforceRedis = false
2324
) {
2425
}
2526

@@ -41,7 +42,9 @@ public function run(): CheckResultInterface
4142
);
4243

4344
if ($this->checkisRedisEnabled($deploymentConfig) === false) {
44-
$checkResult->setStatus(CheckStatus::STATUS_SKIPPED);
45+
$checkResult->setStatus(
46+
$this->enforceRedis ? CheckStatus::STATUS_FAILED : CheckStatus::STATUS_SKIPPED
47+
);
4548
$checkResult->setShortSummary('Redis disabled');
4649
$checkResult->setNotificationMessage('Redis is not enabled');
4750
return $checkResult;

Test/Integration/Checks/RedisConnectionTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,20 @@ public function testRedisConnectionWarning(): void
2525
'Redis connection check should be skipped when Redis is not enabled'
2626
);
2727
}
28+
29+
public function testRedisConnectionEnforceRedis(): void
30+
{
31+
/** @var RedisConnection $redisConnectionCheck */
32+
$redisConnectionCheck = Bootstrap::getObjectManager()->create(RedisConnection::class, [
33+
'enforceRedis' => true,
34+
]);
35+
36+
$output = $redisConnectionCheck->run();
37+
$this->assertEquals('redis_connection', $output->getName());
38+
$this->assertEquals(
39+
CheckStatus::STATUS_FAILED,
40+
$output->getStatus(),
41+
'Redis connection check should be skipped when Redis is not enabled'
42+
);
43+
}
2844
}

0 commit comments

Comments
 (0)