8000 Merge branch '5.0' · symfony/cache@f438f8e · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit f438f8e

Browse files
Merge branch '5.0'
* 5.0: Use PHP 7.2 minimum in tests run with github actions Fix exception messages containing exception messages
2 parents 7ec37c6 + 9dc4137 commit f438f8e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Tests/Adapter/RedisAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testCreateConnection(string $dsnScheme)
7171
public function testFailedCreateConnection(string $dsn)
7272
{
7373
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
74-
$this->expectExceptionMessage('Redis connection failed');
74+
$this->expectExceptionMessage('Redis connection ');
7575
RedisAdapter::createConnection($dsn);
7676
}
7777

Tests/Adapter/RedisClusterAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function createCachePool(int $defaultLifetime = 0): CacheItemPoolInterfac
4747
public function testFailedCreateConnection(string $dsn)
4848
{
4949
$this->expectException('Symfony\Component\Cache\Exception\InvalidArgumentException');
50-
$this->expectExceptionMessage('Redis connection failed');
50+
$this->expectExceptionMessage('Redis connection ');
5151
RedisAdapter::createConnection($dsn);
5252
}
5353

Traits/RedisTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,23 +174,23 @@ public static function createConnection($dsn, array $options = [])
174174
try {
175175
@$redis->{$connect}($hosts[0]['host'] ?? $hosts[0]['path'], $hosts[0]['port'] ?? null, $params['timeout'], (string) $params['persistent_id'], $params['retry_interval']);
176176
} catch (\RedisException $e) {
177-
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
177+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
178178
}
179179

180180
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
181181
$isConnected = $redis->isConnected();
182182
restore_error_handler();
183183
if (!$isConnected) {
184184
$error = preg_match('/^Redis::p?connect\(\): (.*)/', $error, $error) ? sprintf(' (%s)', $error[1]) : '';
185-
throw new InvalidArgumentException(sprintf('Redis connection failed%s: "%s".', $error, $dsn));
185+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$error.'.');
186186
}
187187

188188
if ((null !== $auth && !$redis->auth($auth))
189189
|| ($params['dbindex'] && !$redis->select($params['dbindex']))
190190
|| ($params['read_timeout'] && !$redis->setOption(\Redis::OPT_READ_TIMEOUT, $params['read_timeout']))
191191
) {
192192
$e = preg_replace('/^ERR /', '', $redis->getLastError());
193-
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e, $dsn));
193+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e.'.');
194194
}
195195

196196
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
@@ -215,7 +215,7 @@ public static function createConnection($dsn, array $options = [])
215215
try {
216216
$redis = new $class($hosts, $params);
217217
} catch (\RedisClusterException $e) {
218-
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
218+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
219219
}
220220

221221
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
@@ -230,7 +230,7 @@ public static function createConnection($dsn, array $options = [])
230230
try {
231231
$redis = new $class(null, $hosts, $params['timeout'], $params['read_timeout'], (bool) $params['persistent']);
232232
} catch (\RedisClusterException $e) {
233-
throw new InvalidArgumentException(sprintf('Redis connection failed (%s): "%s".', $e->getMessage(), $dsn));
233+
throw new InvalidArgumentException(sprintf('Redis connection "%s" failed: ', $dsn).$e->getMessage());
234234
}
235235

236236
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {

0 commit comments

Comments
 (0)
0