Skip to content

Commit ef959fe

Browse files
committed
Fixes
1 parent c796b5d commit ef959fe

File tree

9 files changed

+25
-15
lines changed

9 files changed

+25
-15
lines changed

src/Config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private static function getEnvConfig(array $config): array {
6262
}
6363

6464
/**
65-
* Convert ENV variable to an array.
65+
* Convert an ENV variable to an array.
6666
*
6767
* It allows the app to use ENV variables and config.php together.
6868
*

src/Dashboards/DashboardInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface DashboardInterface {
1515
public static function check(): bool;
1616

1717
/**
18-
* Array that contains key, name, and optionally an icon or colors.
18+
* Array that contains a key, name, and optionally an icon or colors.
1919
*
2020
* @return array<string, array<int, string>|string>
2121
*/

src/Dashboards/Redis/Compatibility/Cluster/RedisCluster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function size(string $key): int {
195195
/**
196196
* @throws RedisClusterException
197197
*/
198-
public function flushDatabase(): mixed {
198+
public function flushDatabase(): bool {
199199
$nodes = $this->_masters();
200200

201201
foreach ($nodes as $node) {

src/Dashboards/Redis/Compatibility/Predis.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ public function size(string $key): int {
174174
return is_int($size) ? $size : 0;
175175
}
176176

177-
public function flushDatabase(): mixed {
178-
return $this->flushdb();
177+
public function flushDatabase(): bool {
178+
return (string) $this->flushdb() === 'OK';
179179
}
180180

181181
public function databaseSize(): int {

src/Dashboards/Redis/Compatibility/Redis.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Redis extends \Redis implements RedisCompatibilityInterface {
3030
];
3131

3232
/**
33-
* @param array<string, int|string> $server
33+
* @param array<string, mixed> $server
3434
*
3535
* @throws DashboardException
3636
*/

src/Dashboards/Redis/Compatibility/RedisCompatibilityInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function size(string $key): int;
6868
/**
6969
* Alias to a flushDB().
7070
*/
71-
public function flushDatabase(): mixed;
71+
public function flushDatabase(): bool;
7272

7373
/**
7474
* Alias to a dbSize().

src/Dashboards/Redis/Compatibility/RedisJson.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
namespace RobiNN\Pca\Dashboards\Redis\Compatibility;
1010

11-
use RedisException;
11+
use Exception;
1212

1313
trait RedisJson {
1414
/**
15-
* @throws RedisException
15+
* @throws Exception
1616
*/
1717
public function jsonGet(string $key): string {
1818
return $this->rawCommand('JSON.GET', $key);
1919
}
2020

2121
/**
22-
* @throws RedisException
22+
* @throws Exception
2323
*/
2424
public function jsonSet(string $key, mixed $value): bool {
2525
$raw = $this->rawCommand('JSON.SET', $key, '$', $value);

tests/Dashboards/Redis/PredisTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@
1212

1313
class PredisTest extends RedisTestCase {
1414
public static function setUpBeforeClass(): void {
15+
parent::setUpBeforeClass();
16+
1517
if (!class_exists(Client::class)) {
1618
self::markTestSkipped('Predis is not installed. Skipping tests.');
1719
}
20+
21+
if (self::$is_cluster) {
22+
self::markTestSkipped('There is currently no support for clusters with Predis. Skipping tests.');
23+
}
1824
}
1925

2026
protected string $client = 'predis';

tests/Dashboards/Redis/RedisTestCase.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ abstract class RedisTestCase extends TestCase {
3030

3131
protected string $client;
3232

33-
protected bool $is_cluster = false;
33+
protected static bool $is_cluster = false;
34+
35+
public static function setUpBeforeClass(): void {
36+
parent::setUpBeforeClass();
37+
38+
self::$is_cluster = !empty(Config::get('redis')[0]['nodes']);
39+
}
3440

3541
/**
3642
* @throws DashboardException
@@ -39,10 +45,8 @@ protected function setUp(): void {
3945
$this->template = new Template();
4046
$this->dashboard = new RedisDashboard($this->template, $this->client);
4147

42-
$this->is_cluster = !empty(getenv('CLUSTER'));
43-
44-
if ($this->is_cluster) {
45-
$config = ['nodes' => ['127.0.0.1:6380', '127.0.0.1:6381', '127.0.0.1:6382']];
48+
if (self::$is_cluster) {
49+
$config = ['nodes' => Config::get('redis')[0]['nodes']];
4650
} else {
4751
$config = [
4852
'host' => Config::get('redis')[0]['host'],

0 commit comments

Comments
 (0)