Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 4.4:
  [PhpUnitBridge] add PolyfillTestCaseTrait::expectExceptionMessageMatches to provide FC with recent phpunit versions
  [Messenger] Make sure redis transports are initialized correctly
  Remove return type for Twig function workflow_metadata()
  [DI] fix typo
  • Loading branch information
nicolas-grekas committed Apr 15, 2020
2 parents 21322ff + 518595a commit e608fcd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 8 additions & 0 deletions Tests/Transport/RedisExt/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public function testFromDsnWithOptions()
);
}

public function testFromDsnWithOptionsAndTrailingSlash()
{
$this->assertEquals(
Connection::fromDsn('redis://localhost/', ['stream' => 'queue', 'group' => 'group1', 'consumer' => 'consumer1', 'auto_setup' => false, 'serializer' => 2]),
Connection::fromDsn('redis://localhost/queue/group1/consumer1?serializer=2&auto_setup=0')
);
}

public function testFromDsnWithQueryOptions()
{
$this->assertEquals(
Expand Down
4 changes: 2 additions & 2 deletions Tests/Transport/Serialization/PhpSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testDecodingFailsWithMissingBodyKey()
public function testDecodingFailsWithBadFormat()
{
$this->expectException(MessageDecodingFailedException::class);
$this->expectExceptionMessageRegExp('/Could not decode/');
$this->expectExceptionMessageMatches('/Could not decode/');

$serializer = new PhpSerializer();

Expand All @@ -56,7 +56,7 @@ public function testDecodingFailsWithBadFormat()
public function testDecodingFailsWithBadClass()
{
$this->expectException(MessageDecodingFailedException::class);
$this->expectExceptionMessageRegExp('/class "ReceivedSt0mp" not found/');
$this->expectExceptionMessageMatches('/class "ReceivedSt0mp" not found/');

$serializer = new PhpSerializer();

Expand Down
8 changes: 7 additions & 1 deletion Transport/RedisExt/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public function __construct(array $configuration, array $connectionCredentials =
throw new InvalidArgumentException('Redis connection failed: '.$redis->getLastError());
}

foreach (['stream', 'group', 'consumer'] as $key) {
if (isset($configuration[$key]) && '' === $configuration[$key]) {
throw new InvalidArgumentException(sprintf('"%s" should be configured, got an empty string.', $key));
}
}

$this->stream = $configuration['stream'] ?? self::DEFAULT_OPTIONS['stream'];
$this->group = $configuration['group'] ?? self::DEFAULT_OPTIONS['group'];
$this->consumer = $configuration['consumer'] ?? self::DEFAULT_OPTIONS['consumer'];
Expand All @@ -77,7 +83,7 @@ public static function fromDsn(string $dsn, array $redisOptions = [], \Redis $re
throw new InvalidArgumentException(sprintf('The given Redis DSN "%s" is invalid.', $dsn));
}

$pathParts = explode('/', $parsedUrl['path'] ?? '');
$pathParts = explode('/', rtrim($parsedUrl['path'] ?? '', '/'));

$stream = $pathParts[1] ?? $redisOptions['stream'] ?? null;
$group = $pathParts[2] ?? $redisOptions['group'] ?? null;
Expand Down

0 comments on commit e608fcd

Please sign in to comment.