diff --git a/composer.json b/composer.json index eb1caf8..cc30f60 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "ext-json": "*", "php": ">=8.2", "nette/di": "^3.2.4", - "predis/predis": "^2.3.0" + "predis/predis": "^2.3.0 || ^3.0" }, "suggest": { "ext-igbinary": "For Igbinary serialization", diff --git a/tests/Cases/Caching/RedisStorage.phpt b/tests/Cases/Caching/RedisStorage.phpt index 31fd8e0..a02c23e 100644 --- a/tests/Cases/Caching/RedisStorage.phpt +++ b/tests/Cases/Caching/RedisStorage.phpt @@ -15,8 +15,10 @@ require_once __DIR__ . '/../../bootstrap.php'; Toolkit::test(function (): void { $storage = (object) ['unserialized' => 'unserialized']; - $conn = Mockery::mock(ConnectionInterface::class) - ->shouldReceive('executeCommand') + $conn = Mockery::mock(ConnectionInterface::class); + $conn->shouldReceive('getParameters') + ->andReturn((object) ['database' => 0, 'protocol' => 2]); + $conn->shouldReceive('executeCommand') ->andReturnUsing(function (Command $command) use ($storage) { switch ($command->getId()) { case 'SET': @@ -37,7 +39,7 @@ Toolkit::test(function (): void { default: return $storage->{$command->getArguments()[0]} ?? null; } - })->getMock(); + }); $redis = new RedisStorage(new Client($conn)); $redis->write('foo', 'bar', []); diff --git a/tests/Cases/E2E/Predis.phpt b/tests/Cases/E2E/Predis.phpt index 79f5b99..7d3c611 100644 --- a/tests/Cases/E2E/Predis.phpt +++ b/tests/Cases/E2E/Predis.phpt @@ -8,6 +8,7 @@ use Contributte\Tester\Toolkit; use Nette\Caching\Cache; use Predis\Client; use Predis\Connection\ConnectionException; +use Throwable; use stdClass; use Tester\Assert; use Tester\Environment; @@ -20,8 +21,12 @@ try { $journal = new RedisJournal($client); $storage = new RedisStorage($client, $journal); $cache = new Cache($storage); -} catch (ConnectionException $e) { - Environment::skip('Redis not found: ' . $e->getMessage()); +} catch (Throwable $e) { + if ($e instanceof ConnectionException || str_contains($e::class, 'StreamInitException') || str_contains($e::class, 'Connection')) { + Environment::skip('Redis not found: ' . $e->getMessage()); + } + + throw $e; } // Helper function for journal related tests