Skip to content

Commit 99fb834

Browse files
committed
Skip Redis tests if REDIS_URIS is not defined
1 parent b10b0a0 commit 99fb834

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
**[Requirements](#requirements)** |
22
**[Installation](#installation)** |
33
**[Usage](#usage)** |
4-
**[License](#license)** |
4+
**[License](#license)**
55

66
# php-lock/lock
77

tests/mutex/MutexConcurrencyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ public static function provideExecutionIsSerializedWhenLockedCases(): iterable
279279
}];
280280
}
281281

282-
$uris = getenv('REDIS_URIS') !== false ? explode(',', getenv('REDIS_URIS')) : false;
282+
if (getenv('REDIS_URIS')) {
283+
$uris = explode(',', getenv('REDIS_URIS'));
283284

284-
if ($uris) {
285285
$cases['PredisMutex'] = [static function ($timeout = 3) use ($uris): Mutex {
286286
$clients = array_map(
287287
static function ($uri) {

tests/mutex/PHPRedisMutexTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ protected function setUp(): void
7474
{
7575
parent::setUp();
7676

77-
$uris = explode(',', getenv('REDIS_URIS') ?: 'redis://localhost'); // @phpstan-ignore ternary.shortNotAllowed
77+
if (!getenv('REDIS_URIS')) {
78+
self::markTestSkipped('Redis server is needed');
79+
}
80+
81+
$redisUris = explode(',', getenv('REDIS_URIS'));
7882

79-
foreach ($uris as $redisUri) {
83+
foreach ($redisUris as $redisUri) {
8084
$uri = parse_url($redisUri);
8185

8286
// original Redis::set and Redis::eval calls will reopen the connection
@@ -241,14 +245,14 @@ public static function provideSerializersAndCompressorsCases(): iterable
241245
[\Redis::SERIALIZER_PHP, \Redis::COMPRESSION_NONE],
242246
];
243247

244-
if (defined('Redis::SERIALIZER_IGBINARY')) {
248+
if (defined('Redis::SERIALIZER_IGBINARY') && extension_loaded('igbinary')) {
245249
$options[] = [
246250
constant('Redis::SERIALIZER_IGBINARY'),
247251
\Redis::COMPRESSION_NONE,
248252
];
249253
}
250254

251-
if (defined('Redis::COMPRESSION_LZF')) {
255+
if (defined('Redis::COMPRESSION_LZF') && extension_loaded('lzf')) {
252256
$options[] = [
253257
\Redis::SERIALIZER_NONE,
254258
constant('Redis::COMPRESSION_LZF'),
@@ -258,7 +262,7 @@ public static function provideSerializersAndCompressorsCases(): iterable
258262
constant('Redis::COMPRESSION_LZF'),
259263
];
260264

261-
if (defined('Redis::SERIALIZER_IGBINARY')) {
265+
if (defined('Redis::SERIALIZER_IGBINARY') && extension_loaded('igbinary')) {
262266
$options[] = [
263267
constant('Redis::SERIALIZER_IGBINARY'),
264268
constant('Redis::COMPRESSION_LZF'),

0 commit comments

Comments
 (0)