Skip to content

Commit

Permalink
Skip Redis tests if REDIS_URIS is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 4, 2024
1 parent b10b0a0 commit 99fb834
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
**[Requirements](#requirements)** |
**[Installation](#installation)** |
**[Usage](#usage)** |
**[License](#license)** |
**[License](#license)**

# php-lock/lock

Expand Down
4 changes: 2 additions & 2 deletions tests/mutex/MutexConcurrencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ public static function provideExecutionIsSerializedWhenLockedCases(): iterable
}];
}

$uris = getenv('REDIS_URIS') !== false ? explode(',', getenv('REDIS_URIS')) : false;
if (getenv('REDIS_URIS')) {
$uris = explode(',', getenv('REDIS_URIS'));

if ($uris) {
$cases['PredisMutex'] = [static function ($timeout = 3) use ($uris): Mutex {
$clients = array_map(
static function ($uri) {
Expand Down
14 changes: 9 additions & 5 deletions tests/mutex/PHPRedisMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ protected function setUp(): void
{
parent::setUp();

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

$redisUris = explode(',', getenv('REDIS_URIS'));

foreach ($uris as $redisUri) {
foreach ($redisUris as $redisUri) {
$uri = parse_url($redisUri);

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

if (defined('Redis::SERIALIZER_IGBINARY')) {
if (defined('Redis::SERIALIZER_IGBINARY') && extension_loaded('igbinary')) {
$options[] = [
constant('Redis::SERIALIZER_IGBINARY'),
\Redis::COMPRESSION_NONE,
];
}

if (defined('Redis::COMPRESSION_LZF')) {
if (defined('Redis::COMPRESSION_LZF') && extension_loaded('lzf')) {
$options[] = [
\Redis::SERIALIZER_NONE,
constant('Redis::COMPRESSION_LZF'),
Expand All @@ -258,7 +262,7 @@ public static function provideSerializersAndCompressorsCases(): iterable
constant('Redis::COMPRESSION_LZF'),
];

if (defined('Redis::SERIALIZER_IGBINARY')) {
if (defined('Redis::SERIALIZER_IGBINARY') && extension_loaded('igbinary')) {
$options[] = [
constant('Redis::SERIALIZER_IGBINARY'),
constant('Redis::COMPRESSION_LZF'),
Expand Down

0 comments on commit 99fb834

Please sign in to comment.