Skip to content

Commit 8e24385

Browse files
committed
Merge branch '5.1' into 5.2
* 5.1: [Notifier] Fix parsing Dsn with empty user/password Remove void return type from test methods [Notifier] Use assertSame()
2 parents 325e5d4 + 9051158 commit 8e24385

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

Tests/Transport/DsnTest.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
use Symfony\Component\Notifier\Exception\InvalidArgumentException;
1616
use Symfony\Component\Notifier\Transport\Dsn;
1717

18-
class DsnTest extends TestCase
18+
final class DsnTest extends TestCase
1919
{
2020
/**
2121
* @dataProvider fromStringProvider
2222
*/
23-
public function testFromString(string $string, Dsn $expectedDsn): void
23+
public function testFromString(string $string, Dsn $expectedDsn)
2424
{
2525
$actualDsn = Dsn::fromString($string);
2626

@@ -42,6 +42,26 @@ public function fromStringProvider(): iterable
4242
new Dsn('scheme', 'localhost', null, null, null, [], null),
4343
];
4444

45+
yield 'simple dsn including @ sign, but no user/password/token' => [
46+
'scheme://@localhost',
47+
new Dsn('scheme', 'localhost', null, null),
48+
];
49+
50+
yield 'simple dsn including : sign and @ sign, but no user/password/token' => [
51+
'scheme://:@localhost',
52+
new Dsn('scheme', 'localhost', null, null),
53+
];
54+
55+
yield 'simple dsn including user, : sign and @ sign, but no password' => [
56+
'scheme://user1:@localhost',
57+
new Dsn('scheme', 'localhost', 'user1', null),
58+
];
59+
60+
yield 'simple dsn including : sign, password, and @ sign, but no user' => [
61+
'scheme://:pass@localhost',
62+
new Dsn('scheme', 'localhost', null, 'pass'),
63+
];
64+
4565
yield 'dsn with user and pass' => [
4666
'scheme://u$er:pa$s@localhost',
4767
new Dsn('scheme', 'localhost', 'u$er', 'pa$s', null, [], null),
@@ -66,7 +86,7 @@ public function fromStringProvider(): iterable
6686
/**
6787
* @dataProvider invalidDsnProvider
6888
*/
69-
public function testInvalidDsn(string $dsn, string $exceptionMessage): void
89+
public function testInvalidDsn(string $dsn, string $exceptionMessage)
7090
{
7191
$this->expectException(InvalidArgumentException::class);
7292
$this->expectExceptionMessage($exceptionMessage);
@@ -91,7 +111,7 @@ public function invalidDsnProvider(): iterable
91111
];
92112
}
93113

94-
public function testGetOption(): void
114+
public function testGetOption()
95115
{
96116
$options = ['with_value' => 'some value', 'nullable' => null];
97117
$dsn = new Dsn('scheme', 'localhost', 'u$er', 'pa$s', '8000', $options, '/channel');

Transport/Dsn.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ public static function fromString(string $dsn): self
5454
throw new InvalidArgumentException(sprintf('The "%s" notifier DSN must contain a host (use "default" by default).', $dsn));
5555
}
5656

57-
$user = isset($parsedDsn['user']) ? urldecode($parsedDsn['user']) : null;
58-
$password = isset($parsedDsn['pass']) ? urldecode($parsedDsn['pass']) : null;
57+
$user = '' !== ($parsedDsn['user'] ?? '') ? urldecode($parsedDsn['user']) : null;
58+
$password = '' !== ($parsedDsn['pass'] ?? '') ? urldecode($parsedDsn['pass']) : null;
5959
$port = $parsedDsn['port'] ?? null;
6060
$path = $parsedDsn['path'] ?? null;
6161
parse_str($parsedDsn['query'] ?? '', $query);

0 commit comments

Comments
 (0)