diff --git a/CHANGELOG.md b/CHANGELOG.md index 772f5071..87262ce7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,12 @@ CHANGELOG ========= +6.2.7 +----- + + * [BC BREAK] The following data providers for `TransportFactoryTestCase` are now static: + `supportsProvider()`, `createProvider()`, `unsupportedSchemeProvider()`and `incompleteDsnProvider()` + 6.2 --- diff --git a/LICENSE b/LICENSE index 5c7ba055..f37c76b5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2019-2023 Fabien Potencier +Copyright (c) 2019-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Test/TransportFactoryTestCase.php b/Test/TransportFactoryTestCase.php index 1cf22e9b..7bcd8989 100644 --- a/Test/TransportFactoryTestCase.php +++ b/Test/TransportFactoryTestCase.php @@ -37,16 +37,16 @@ abstract class TransportFactoryTestCase extends TestCase abstract public function getFactory(): TransportFactoryInterface; - abstract public function supportsProvider(): iterable; + abstract public static function supportsProvider(): iterable; - abstract public function createProvider(): iterable; + abstract public static function createProvider(): iterable; - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { return []; } - public function incompleteDsnProvider(): iterable + public static function incompleteDsnProvider(): iterable { return []; } diff --git a/Tests/EventListener/MessageListenerTest.php b/Tests/EventListener/MessageListenerTest.php index 2b2e5dfe..5f5def70 100644 --- a/Tests/EventListener/MessageListenerTest.php +++ b/Tests/EventListener/MessageListenerTest.php @@ -36,7 +36,7 @@ public function testHeaders(Headers $initialHeaders, Headers $defaultHeaders, He $this->assertEquals($expectedHeaders, $event->getMessage()->getHeaders()); } - public function provideHeaders(): iterable + public static function provideHeaders(): iterable { $initialHeaders = new Headers(); $defaultHeaders = (new Headers()) diff --git a/Tests/Exception/UnsupportedSchemeExceptionTest.php b/Tests/Exception/UnsupportedSchemeExceptionTest.php index 56226dcd..445f028a 100644 --- a/Tests/Exception/UnsupportedSchemeExceptionTest.php +++ b/Tests/Exception/UnsupportedSchemeExceptionTest.php @@ -61,7 +61,7 @@ public function testMessageWhereSchemeIsPartOfSchemeToPackageMap(string $scheme, ); } - public function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generator + public static function messageWhereSchemeIsPartOfSchemeToPackageMapProvider(): \Generator { yield ['gmail', 'symfony/google-mailer']; yield ['infobip', 'symfony/infobip-mailer']; @@ -86,7 +86,7 @@ public function testMessageWhereSchemeIsNotPartOfSchemeToPackageMap(string $expe ); } - public function messageWhereSchemeIsNotPartOfSchemeToPackageMapProvider(): \Generator + public static function messageWhereSchemeIsNotPartOfSchemeToPackageMapProvider(): \Generator { yield [ 'The "somethingElse" scheme is not supported.', diff --git a/Tests/Transport/DsnTest.php b/Tests/Transport/DsnTest.php index 2816333f..f3c0a0bc 100644 --- a/Tests/Transport/DsnTest.php +++ b/Tests/Transport/DsnTest.php @@ -45,7 +45,7 @@ public function testInvalidDsn(string $dsn, string $exceptionMessage) Dsn::fromString($dsn); } - public function fromStringProvider(): iterable + public static function fromStringProvider(): iterable { yield 'simple smtp without user and pass' => [ 'smtp://example.com', @@ -88,7 +88,7 @@ public function fromStringProvider(): iterable ]; } - public function invalidDsnProvider(): iterable + public static function invalidDsnProvider(): iterable { yield [ 'some://', diff --git a/Tests/Transport/NativeTransportFactoryTest.php b/Tests/Transport/NativeTransportFactoryTest.php index 556a01ac..c253b4c7 100644 --- a/Tests/Transport/NativeTransportFactoryTest.php +++ b/Tests/Transport/NativeTransportFactoryTest.php @@ -47,7 +47,7 @@ function ini_get(\$key) public function testCreateWithNotSupportedScheme() { $this->expectException(UnsupportedSchemeException::class); - $this->expectErrorMessageMatches('#The ".*" scheme is not supported#'); + $this->expectExceptionMessage('The "sendmail" scheme is not supported'); $sut = new NativeTransportFactory(); $sut->create(Dsn::fromString('sendmail://default')); @@ -66,7 +66,7 @@ public function testCreateSendmailWithNoSendmailPath() $sut->create(Dsn::fromString('native://default')); } - public function provideCreateSendmailWithNoHostOrNoPort(): \Generator + public static function provideCreateSendmailWithNoHostOrNoPort(): \Generator { yield ['native://default', '', '', '']; yield ['native://default', '', 'localhost', '']; @@ -95,7 +95,7 @@ public function testCreateSendmailWithNoHostOrNoPort(string $dsn, string $sendma $sut->create(Dsn::fromString($dsn)); } - public function provideCreate(): \Generator + public static function provideCreate(): \Generator { yield ['native://default', '/usr/sbin/sendmail -t -i', '', '', new SendmailTransport('/usr/sbin/sendmail -t -i')]; diff --git a/Tests/Transport/NullTransportFactoryTest.php b/Tests/Transport/NullTransportFactoryTest.php index 9b39a614..b28935a7 100644 --- a/Tests/Transport/NullTransportFactoryTest.php +++ b/Tests/Transport/NullTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Test\TransportFactoryTestCase; use Symfony\Component\Mailer\Transport\Dsn; use Symfony\Component\Mailer\Transport\NullTransport; @@ -21,10 +23,10 @@ class NullTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new NullTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new NullTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('null', ''), @@ -32,11 +34,11 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ new Dsn('null', 'null'), - new NullTransport($this->getDispatcher(), $this->getLogger()), + new NullTransport(null, new NullLogger()), ]; } } diff --git a/Tests/Transport/SendmailTransportFactoryTest.php b/Tests/Transport/SendmailTransportFactoryTest.php index 55f893b0..a3d08f59 100644 --- a/Tests/Transport/SendmailTransportFactoryTest.php +++ b/Tests/Transport/SendmailTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Tests\Transport; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Test\TransportFactoryTestCase; use Symfony\Component\Mailer\Transport\Dsn; use Symfony\Component\Mailer\Transport\SendmailTransport; @@ -21,10 +23,10 @@ class SendmailTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new SendmailTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new SendmailTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('sendmail+smtp', 'default'), @@ -32,20 +34,20 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { yield [ new Dsn('sendmail+smtp', 'default'), - new SendmailTransport(null, $this->getDispatcher(), $this->getLogger()), + new SendmailTransport(null, null, new NullLogger()), ]; yield [ new Dsn('sendmail+smtp', 'default', null, null, null, ['command' => '/usr/sbin/sendmail -oi -t']), - new SendmailTransport('/usr/sbin/sendmail -oi -t', $this->getDispatcher(), $this->getLogger()), + new SendmailTransport('/usr/sbin/sendmail -oi -t', null, new NullLogger()), ]; } - public function unsupportedSchemeProvider(): iterable + public static function unsupportedSchemeProvider(): iterable { yield [ new Dsn('sendmail+http', 'default'), diff --git a/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php b/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php index 7b1b52f4..bcdf669b 100644 --- a/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php +++ b/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Mailer\Tests\Transport\Smtp; +use Psr\Log\NullLogger; +use Symfony\Component\HttpClient\MockHttpClient; use Symfony\Component\Mailer\Test\TransportFactoryTestCase; use Symfony\Component\Mailer\Transport\Dsn; use Symfony\Component\Mailer\Transport\Smtp\EsmtpTransport; @@ -22,10 +24,10 @@ class EsmtpTransportFactoryTest extends TransportFactoryTestCase { public function getFactory(): TransportFactoryInterface { - return new EsmtpTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger()); + return new EsmtpTransportFactory(null, new MockHttpClient(), new NullLogger()); } - public function supportsProvider(): iterable + public static function supportsProvider(): iterable { yield [ new Dsn('smtp', 'example.com'), @@ -43,19 +45,18 @@ public function supportsProvider(): iterable ]; } - public function createProvider(): iterable + public static function createProvider(): iterable { - $eventDispatcher = $this->getDispatcher(); - $logger = $this->getLogger(); + $logger = new NullLogger(); - $transport = new EsmtpTransport('localhost', 25, false, $eventDispatcher, $logger); + $transport = new EsmtpTransport('localhost', 25, false, null, $logger); yield [ new Dsn('smtp', 'localhost'), $transport, ]; - $transport = new EsmtpTransport('example.com', 99, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 99, true, null, $logger); $transport->setUsername(self::USER); $transport->setPassword(self::PASSWORD); @@ -64,21 +65,21 @@ public function createProvider(): iterable $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); yield [ new Dsn('smtps', 'example.com'), $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); yield [ new Dsn('smtps', 'example.com', '', '', 465), $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); /** @var SocketStream $stream */ $stream = $transport->getStream(); $streamOptions = $stream->getStreamOptions(); @@ -101,14 +102,14 @@ public function createProvider(): iterable $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); yield [ Dsn::fromString('smtps://:@example.com?verify_peer='), $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); $transport->setLocalDomain('example.com'); yield [ @@ -116,7 +117,7 @@ public function createProvider(): iterable $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); $transport->setMaxPerSecond(2.0); yield [ @@ -124,7 +125,7 @@ public function createProvider(): iterable $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); $transport->setRestartThreshold(10, 1); yield [ @@ -132,7 +133,7 @@ public function createProvider(): iterable $transport, ]; - $transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger); + $transport = new EsmtpTransport('example.com', 465, true, null, $logger); $transport->setPingThreshold(10); yield [ diff --git a/Tests/Transport/Smtp/Stream/AbstractStreamTest.php b/Tests/Transport/Smtp/Stream/AbstractStreamTest.php index cc901ccb..aeb2834c 100644 --- a/Tests/Transport/Smtp/Stream/AbstractStreamTest.php +++ b/Tests/Transport/Smtp/Stream/AbstractStreamTest.php @@ -29,7 +29,7 @@ public function testReplace(string $expected, string $from, string $to, array $c $this->assertSame($expected, $result); } - public function provideReplace() + public static function provideReplace() { yield ['ca', 'ab', 'c', ['a', 'b', 'a']]; yield ['ac', 'ab', 'c', ['a', 'ab']]; diff --git a/Tests/TransportTest.php b/Tests/TransportTest.php index 690b0eed..3ffd706c 100644 --- a/Tests/TransportTest.php +++ b/Tests/TransportTest.php @@ -34,7 +34,7 @@ public function testFromString(string $dsn, TransportInterface $transport) $this->assertEquals($transport, $transportFactory->fromString($dsn)); } - public function fromStringProvider(): iterable + public static function fromStringProvider(): iterable { $transportA = new DummyTransport('a'); $transportB = new DummyTransport('b'); @@ -68,7 +68,7 @@ public function testFromDsn(string $dsn, TransportInterface $transport) $this->assertEquals($transport, Transport::fromDsn($dsn)); } - public function fromDsnProvider(): iterable + public static function fromDsnProvider(): iterable { yield 'multiple transports' => [ 'failover(smtp://a smtp://b)', @@ -88,7 +88,7 @@ public function testFromWrongString(string $dsn, string $error) $transportFactory->fromString($dsn); } - public function fromWrongStringProvider(): iterable + public static function fromWrongStringProvider(): iterable { yield 'garbage at the end' => ['dummy://a some garbage here', 'The DSN has some garbage at the end: " some garbage here".']; diff --git a/Transport/Smtp/SmtpTransport.php b/Transport/Smtp/SmtpTransport.php index 675528ce..0f228191 100644 --- a/Transport/Smtp/SmtpTransport.php +++ b/Transport/Smtp/SmtpTransport.php @@ -246,6 +246,7 @@ protected function doSend(SentMessage $message): void /** * @internal since version 6.1, to be made private in 7.0 + * * @final since version 6.1, to be made private in 7.0 */ protected function doHeloCommand(): void diff --git a/Transport/Smtp/Stream/ProcessStream.php b/Transport/Smtp/Stream/ProcessStream.php index d178bc8b..dc3b8f05 100644 --- a/Transport/Smtp/Stream/ProcessStream.php +++ b/Transport/Smtp/Stream/ProcessStream.php @@ -35,7 +35,7 @@ public function initialize(): void $descriptorSpec = [ 0 => ['pipe', 'r'], 1 => ['pipe', 'w'], - 2 => ['pipe', 'w'], + 2 => ['pipe', '\\' === \DIRECTORY_SEPARATOR ? 'a' : 'w'], ]; $pipes = []; $this->stream = proc_open($this->command, $descriptorSpec, $pipes); diff --git a/composer.json b/composer.json index ded4309c..83fbecd9 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ }, "require-dev": { "symfony/console": "^5.4|^6.0", - "symfony/http-client-contracts": "^1.1|^2|^3", + "symfony/http-client": "^5.4|^6.0", "symfony/messenger": "^6.2", "symfony/twig-bridge": "^6.2" },