Skip to content

Commit c5be35e

Browse files
committed
deprecate not implementing data provider methods
1 parent 2ef8410 commit c5be35e

File tree

94 files changed

+663
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+663
-237
lines changed

UPGRADE-7.2.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,21 @@ Ldap
4040

4141
* Add methods for `saslBind()` and `whoami()` to `ConnectionInterface` and `LdapInterface`
4242

43+
Mailer
44+
------
45+
46+
* Deprecate not implementing `incompleteDsnProvider()` and `unsupportedSchemeProvider()` when extending `TransportFactoryTestCase`
47+
4348
Messenger
4449
---------
4550

4651
* Add `getRetryDelay()` method to `RecoverableExceptionInterface`
4752

53+
Notifier
54+
--------
55+
56+
* Deprecate not implementing `incompleteDsnProvider()`, `missingRequiredOptionProvider` and `unsupportedSchemeProvider()` when extending `TransportFactoryTestCase`
57+
4858
Security
4959
--------
5060

@@ -70,6 +80,7 @@ String
7080
Translation
7181
-----------
7282

83+
* Deprecate not implementing `incompleteDsnProvider()` and `unsupportedSchemeProvider()` when extending `ProviderFactoryTestCase`
7384
* Deprecate passing an escape character to `CsvFileLoader::setCsvControl()`
7485

7586
TwigBridge

src/Symfony/Component/Mailer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
7.2
55
---
66

7+
* Deprecate not implementing `incompleteDsnProvider()` and `unsupportedSchemeProvider()` when extending `TransportFactoryTestCase`
78
* Make `TransportFactoryTestCase` compatible with PHPUnit 10+
89

910
7.1

src/Symfony/Component/Mailer/Test/TransportFactoryTestCase.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ abstract public static function createProvider(): iterable;
5353
*/
5454
public static function unsupportedSchemeProvider(): iterable
5555
{
56+
trigger_deprecation('symfony/mailer', '7.2', 'Not implementing "%s()" in "%s" is deprecated. This method will be abstract in Symfony 8.0.', __METHOD__, static::class);
57+
5658
return [];
5759
}
5860

@@ -61,6 +63,8 @@ public static function unsupportedSchemeProvider(): iterable
6163
*/
6264
public static function incompleteDsnProvider(): iterable
6365
{
66+
trigger_deprecation('symfony/mailer', '7.2', 'Not implementing "%s()" in "%s" is deprecated. This method will be abstract in Symfony 8.0.', __METHOD__, static::class);
67+
6468
return [];
6569
}
6670

@@ -109,8 +113,12 @@ public function testUnsupportedSchemeException(Dsn $dsn, ?string $message = null
109113
* @dataProvider incompleteDsnProvider
110114
*/
111115
#[DataProvider('incompleteDsnProvider')]
112-
public function testIncompleteDsnException(Dsn $dsn)
116+
public function testIncompleteDsnException(?Dsn $dsn)
113117
{
118+
if (null === $dsn) {
119+
$this->markTestIncomplete();
120+
}
121+
114122
$factory = $this->getFactory();
115123

116124
$this->expectException(IncompleteDsnException::class);

src/Symfony/Component/Mailer/Tests/Transport/NullTransportFactoryTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,14 @@ public static function createProvider(): iterable
4141
new NullTransport(null, new NullLogger()),
4242
];
4343
}
44+
45+
public static function unsupportedSchemeProvider(): iterable
46+
{
47+
yield [new Dsn('smtp', 'localhost')];
48+
}
49+
50+
public static function incompleteDsnProvider(): iterable
51+
{
52+
yield [null];
53+
}
4454
}

src/Symfony/Component/Mailer/Tests/Transport/SendmailTransportFactoryTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,9 @@ public static function unsupportedSchemeProvider(): iterable
5454
'The "sendmail+http" scheme is not supported; supported schemes for mailer "sendmail" are: "sendmail", "sendmail+smtp".',
5555
];
5656
}
57+
58+
public static function incompleteDsnProvider(): iterable
59+
{
60+
yield [null];
61+
}
5762
}

src/Symfony/Component/Mailer/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,14 @@ public static function createProvider(): iterable
181181
$transport,
182182
];
183183
}
184+
185+
public static function unsupportedSchemeProvider(): iterable
186+
{
187+
yield [new Dsn('null', '')];
188+
}
189+
190+
public static function incompleteDsnProvider(): iterable
191+
{
192+
yield [null];
193+
}
184194
}

src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransportFactory.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Mailer\Transport\Smtp;
1313

14+
use Symfony\Component\Mailer\Exception\UnsupportedSchemeException;
1415
use Symfony\Component\Mailer\Transport\AbstractTransportFactory;
1516
use Symfony\Component\Mailer\Transport\Dsn;
1617
use Symfony\Component\Mailer\Transport\Smtp\Stream\SocketStream;
@@ -23,6 +24,10 @@ final class EsmtpTransportFactory extends AbstractTransportFactory
2324
{
2425
public function create(Dsn $dsn): TransportInterface
2526
{
27+
if (!in_array($dsn->getScheme(), $this->getSupportedSchemes(), true)) {
28+
throw new UnsupportedSchemeException($dsn, 'smtp', $this->getSupportedSchemes());
29+
}
30+
2631
$autoTls = '' === $dsn->getOption('auto_tls') || filter_var($dsn->getOption('auto_tls', true), \FILTER_VALIDATE_BOOL);
2732
$tls = 'smtps' === $dsn->getScheme() ? true : ($autoTls ? null : false);
2833
$port = $dsn->getPort(0);

src/Symfony/Component/Mailer/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"egulias/email-validator": "^2.1.10|^3|^4",
2121
"psr/event-dispatcher": "^1",
2222
"psr/log": "^1|^2|^3",
23+
"symfony/deprecation-contracts": "^2.5|^3",
2324
"symfony/event-dispatcher": "^6.4|^7.0",
2425
"symfony/mime": "^6.4|^7.0",
2526
"symfony/service-contracts": "^2.5|^3"

src/Symfony/Component/Notifier/Bridge/AllMySms/Tests/AllMySmsTransportFactoryTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
namespace Symfony\Component\Notifier\Bridge\AllMySms\Tests;
1313

1414
use Symfony\Component\Notifier\Bridge\AllMySms\AllMySmsTransportFactory;
15-
use Symfony\Component\Notifier\Test\TransportFactoryTestCase;
15+
use Symfony\Component\Notifier\Test\AbstractTransportFactoryTestCase;
16+
use Symfony\Component\Notifier\Test\IncompleteDsnTestTrait;
1617

17-
final class AllMySmsTransportFactoryTest extends TransportFactoryTestCase
18+
final class AllMySmsTransportFactoryTest extends AbstractTransportFactoryTestCase
1819
{
20+
use IncompleteDsnTestTrait;
21+
1922
public function createFactory(): AllMySmsTransportFactory
2023
{
2124
return new AllMySmsTransportFactory();
@@ -44,4 +47,10 @@ public static function unsupportedSchemeProvider(): iterable
4447
{
4548
yield ['somethingElse://login:apiKey@default'];
4649
}
50+
51+
public static function incompleteDsnProvider(): iterable
52+
{
53+
yield ['allmysms://login@default'];
54+
yield ['allmysms://:apiKey@default'];
55+
}
4756
}

src/Symfony/Component/Notifier/Bridge/AmazonSns/Tests/AmazonSnsTransportFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
namespace Symfony\Component\Notifier\Bridge\AmazonSns\Tests;
1313

1414
use Symfony\Component\Notifier\Bridge\AmazonSns\AmazonSnsTransportFactory;
15-
use Symfony\Component\Notifier\Test\TransportFactoryTestCase;
15+
use Symfony\Component\Notifier\Test\AbstractTransportFactoryTestCase;
1616

17-
class AmazonSnsTransportFactoryTest extends TransportFactoryTestCase
17+
class AmazonSnsTransportFactoryTest extends AbstractTransportFactoryTestCase
1818
{
1919
public function createFactory(): AmazonSnsTransportFactory
2020
{

0 commit comments

Comments
 (0)