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()
This commit is contained in:
commit
d0da49d201
@ -20,12 +20,12 @@ class DsnTest extends TestCase
|
||||
/**
|
||||
* @dataProvider fromStringProvider
|
||||
*/
|
||||
public function testFromString(string $string, Dsn $dsn): void
|
||||
public function testFromString(string $string, Dsn $dsn)
|
||||
{
|
||||
$this->assertEquals($dsn, Dsn::fromString($string));
|
||||
}
|
||||
|
||||
public function testGetOption(): void
|
||||
public function testGetOption()
|
||||
{
|
||||
$options = ['with_value' => 'some value', 'nullable' => null];
|
||||
$dsn = new Dsn('smtp', 'example.com', null, null, null, $options);
|
||||
@ -38,7 +38,7 @@ class DsnTest extends TestCase
|
||||
/**
|
||||
* @dataProvider invalidDsnProvider
|
||||
*/
|
||||
public function testInvalidDsn(string $dsn, string $exceptionMessage): void
|
||||
public function testInvalidDsn(string $dsn, string $exceptionMessage)
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
|
@ -21,7 +21,7 @@ use Symfony\Component\Messenger\Bridge\AmazonSqs\Transport\Connection;
|
||||
*/
|
||||
class AmazonSqsIntegrationTest extends TestCase
|
||||
{
|
||||
public function testConnectionSendToFifoQueueAndGet(): void
|
||||
public function testConnectionSendToFifoQueueAndGet()
|
||||
{
|
||||
if (!getenv('MESSENGER_SQS_FIFO_QUEUE_DSN')) {
|
||||
$this->markTestSkipped('The "MESSENGER_SQS_FIFO_QUEUE_DSN" environment variable is required.');
|
||||
@ -30,7 +30,7 @@ class AmazonSqsIntegrationTest extends TestCase
|
||||
$this->execute(getenv('MESSENGER_SQS_FIFO_QUEUE_DSN'));
|
||||
}
|
||||
|
||||
public function testConnectionSendAndGet(): void
|
||||
public function testConnectionSendAndGet()
|
||||
{
|
||||
if (!getenv('MESSENGER_SQS_DSN')) {
|
||||
$this->markTestSkipped('The "MESSENGER_SQS_DSN" environment variable is required.');
|
||||
|
@ -26,7 +26,7 @@ class StopWorkerOnFailureLimitListenerTest extends TestCase
|
||||
/**
|
||||
* @dataProvider countProvider
|
||||
*/
|
||||
public function testWorkerStopsWhenMaximumCountReached(int $max, bool $shouldStop): void
|
||||
public function testWorkerStopsWhenMaximumCountReached(int $max, bool $shouldStop)
|
||||
{
|
||||
$worker = $this->createMock(Worker::class);
|
||||
$worker->expects($shouldStop ? $this->atLeastOnce() : $this->never())->method('stop');
|
||||
@ -53,7 +53,7 @@ class StopWorkerOnFailureLimitListenerTest extends TestCase
|
||||
yield [4, false];
|
||||
}
|
||||
|
||||
public function testWorkerLogsMaximumCountReachedWhenLoggerIsGiven(): void
|
||||
public function testWorkerLogsMaximumCountReachedWhenLoggerIsGiven()
|
||||
{
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
$logger->expects($this->once())->method('info')
|
||||
|
@ -121,7 +121,7 @@ JSON;
|
||||
];
|
||||
|
||||
$client = new MockHttpClient(function (string $method, string $url, array $options = []) use ($response, $expectedBody): ResponseInterface {
|
||||
$this->assertEquals($expectedBody, json_decode($options['body'], true));
|
||||
$this->assertSame($expectedBody, json_decode($options['body'], true));
|
||||
|
||||
return $response;
|
||||
});
|
||||
@ -177,7 +177,7 @@ JSON;
|
||||
];
|
||||
|
||||
$client = new MockHttpClient(function (string $method, string $url, array $options = []) use ($response, $expectedBody): ResponseInterface {
|
||||
$this->assertEquals($expectedBody, json_decode($options['body'], true));
|
||||
$this->assertSame($expectedBody, json_decode($options['body'], true));
|
||||
|
||||
return $response;
|
||||
});
|
||||
|
@ -15,12 +15,12 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Notifier\Exception\InvalidArgumentException;
|
||||
use Symfony\Component\Notifier\Transport\Dsn;
|
||||
|
||||
class DsnTest extends TestCase
|
||||
final class DsnTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider fromStringProvider
|
||||
*/
|
||||
public function testFromString(string $string, Dsn $expectedDsn): void
|
||||
public function testFromString(string $string, Dsn $expectedDsn)
|
||||
{
|
||||
$actualDsn = Dsn::fromString($string);
|
||||
|
||||
@ -42,6 +42,26 @@ class DsnTest extends TestCase
|
||||
new Dsn('scheme', 'localhost', null, null, null, [], null),
|
||||
];
|
||||
|
||||
yield 'simple dsn including @ sign, but no user/password/token' => [
|
||||
'scheme://@localhost',
|
||||
new Dsn('scheme', 'localhost', null, null),
|
||||
];
|
||||
|
||||
yield 'simple dsn including : sign and @ sign, but no user/password/token' => [
|
||||
'scheme://:@localhost',
|
||||
new Dsn('scheme', 'localhost', null, null),
|
||||
];
|
||||
|
||||
yield 'simple dsn including user, : sign and @ sign, but no password' => [
|
||||
'scheme://user1:@localhost',
|
||||
new Dsn('scheme', 'localhost', 'user1', null),
|
||||
];
|
||||
|
||||
yield 'simple dsn including : sign, password, and @ sign, but no user' => [
|
||||
'scheme://:pass@localhost',
|
||||
new Dsn('scheme', 'localhost', null, 'pass'),
|
||||
];
|
||||
|
||||
yield 'dsn with user and pass' => [
|
||||
'scheme://u$er:pa$s@localhost',
|
||||
new Dsn('scheme', 'localhost', 'u$er', 'pa$s', null, [], null),
|
||||
@ -66,7 +86,7 @@ class DsnTest extends TestCase
|
||||
/**
|
||||
* @dataProvider invalidDsnProvider
|
||||
*/
|
||||
public function testInvalidDsn(string $dsn, string $exceptionMessage): void
|
||||
public function testInvalidDsn(string $dsn, string $exceptionMessage)
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage($exceptionMessage);
|
||||
@ -91,7 +111,7 @@ class DsnTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function testGetOption(): void
|
||||
public function testGetOption()
|
||||
{
|
||||
$options = ['with_value' => 'some value', 'nullable' => null];
|
||||
$dsn = new Dsn('scheme', 'localhost', 'u$er', 'pa$s', '8000', $options, '/channel');
|
||||
|
@ -54,8 +54,8 @@ final class Dsn
|
||||
throw new InvalidArgumentException(sprintf('The "%s" notifier DSN must contain a host (use "default" by default).', $dsn));
|
||||
}
|
||||
|
||||
$user = isset($parsedDsn['user']) ? urldecode($parsedDsn['user']) : null;
|
||||
$password = isset($parsedDsn['pass']) ? urldecode($parsedDsn['pass']) : null;
|
||||
$user = '' !== ($parsedDsn['user'] ?? '') ? urldecode($parsedDsn['user']) : null;
|
||||
$password = '' !== ($parsedDsn['pass'] ?? '') ? urldecode($parsedDsn['pass']) : null;
|
||||
$port = $parsedDsn['port'] ?? null;
|
||||
$path = $parsedDsn['path'] ?? null;
|
||||
parse_str($parsedDsn['query'] ?? '', $query);
|
||||
|
@ -23,7 +23,7 @@ class ExpressionLanguageSyntaxValidatorTest extends ConstraintValidatorTestCase
|
||||
return new ExpressionLanguageSyntaxValidator(new ExpressionLanguage());
|
||||
}
|
||||
|
||||
public function testExpressionValid(): void
|
||||
public function testExpressionValid()
|
||||
{
|
||||
$this->validator->validate('1 + 1', new ExpressionLanguageSyntax([
|
||||
'message' => 'myMessage',
|
||||
@ -33,7 +33,7 @@ class ExpressionLanguageSyntaxValidatorTest extends ConstraintValidatorTestCase
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testExpressionWithoutNames(): void
|
||||
public function testExpressionWithoutNames()
|
||||
{
|
||||
$this->validator->validate('1 + 1', new ExpressionLanguageSyntax([
|
||||
'message' => 'myMessage',
|
||||
@ -42,7 +42,7 @@ class ExpressionLanguageSyntaxValidatorTest extends ConstraintValidatorTestCase
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testExpressionWithAllowedVariableName(): void
|
||||
public function testExpressionWithAllowedVariableName()
|
||||
{
|
||||
$this->validator->validate('a + 1', new ExpressionLanguageSyntax([
|
||||
'message' => 'myMessage',
|
||||
@ -52,7 +52,7 @@ class ExpressionLanguageSyntaxValidatorTest extends ConstraintValidatorTestCase
|
||||
$this->assertNoViolation();
|
||||
}
|
||||
|
||||
public function testExpressionIsNotValid(): void
|
||||
public function testExpressionIsNotValid()
|
||||
{
|
||||
$this->validator->validate('a + 1', new ExpressionLanguageSyntax([
|
||||
'message' => 'myMessage',
|
||||
|
Reference in New Issue
Block a user