Skip to content

Commit 0e62116

Browse files
Merge branch '5.4' into 6.2
* 5.4: [Translation][Mailer] Convert `$this` calls to static ones in data providers [BC Break] Make data providers for abstract test cases static use TestCase suffix for abstract tests in Tests directories Fix Request locale property doc types Bump absolute lowest dep to 4.4
2 parents cad785a + 82f4321 commit 0e62116

File tree

6 files changed

+47
-33
lines changed

6 files changed

+47
-33
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ CHANGELOG
1818

1919
* The `HttpTransportException` class takes a string at first argument
2020

21+
5.4.21
22+
------
23+
24+
* [BC BREAK] The following data providers for `TransportFactoryTestCase` are now static:
25+
`supportsProvider()`, `createProvider()`, `unsupportedSchemeProvider()`and `incompleteDsnProvider()`
26+
* [BC BREAK] The following data providers for `TransportTestCase` are now static:
27+
`toStringProvider()`, `supportedMessagesProvider()` and `unsupportedMessagesProvider()`
28+
2129
5.4
2230
---
2331

Test/TransportFactoryTestCase.php

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Psr\Log\LoggerInterface;
16+
use Psr\Log\NullLogger;
17+
use Symfony\Component\HttpClient\MockHttpClient;
1618
use Symfony\Component\Mailer\Exception\IncompleteDsnException;
1719
use Symfony\Component\Mailer\Exception\UnsupportedSchemeException;
1820
use Symfony\Component\Mailer\Transport\Dsn;
@@ -31,22 +33,22 @@ abstract class TransportFactoryTestCase extends TestCase
3133
protected const USER = 'u$er';
3234
protected const PASSWORD = 'pa$s';
3335

34-
protected $dispatcher;
35-
protected $client;
36-
protected $logger;
36+
protected static $dispatcher;
37+
protected static $client;
38+
protected static $logger;
3739

38-
abstract public function getFactory(): TransportFactoryInterface;
40+
abstract public static function getFactory(): TransportFactoryInterface;
3941

40-
abstract public function supportsProvider(): iterable;
42+
abstract public static function supportsProvider(): iterable;
4143

42-
abstract public function createProvider(): iterable;
44+
abstract public static function createProvider(): iterable;
4345

44-
public function unsupportedSchemeProvider(): iterable
46+
public static function unsupportedSchemeProvider(): iterable
4547
{
4648
return [];
4749
}
4850

49-
public function incompleteDsnProvider(): iterable
51+
public static function incompleteDsnProvider(): iterable
5052
{
5153
return [];
5254
}
@@ -100,18 +102,22 @@ public function testIncompleteDsnException(Dsn $dsn)
100102
$factory->create($dsn);
101103
}
102104

103-
protected function getDispatcher(): EventDispatcherInterface
105+
protected static function getDispatcher(): EventDispatcherInterface
104106
{
105-
return $this->dispatcher ??= $this->createMock(EventDispatcherInterface::class);
107+
return self::$dispatcher ??= new class() implements EventDispatcherInterface {
108+
public function dispatch($event, string $eventName = null): object
109+
{
110+
}
111+
};
106112
}
107113

108-
protected function getClient(): HttpClientInterface
114+
protected static function getClient(): HttpClientInterface
109115
{
110-
return $this->client ??= $this->createMock(HttpClientInterface::class);
116+
return self::$client ??= new MockHttpClient();
111117
}
112118

113-
protected function getLogger(): LoggerInterface
119+
protected static function getLogger(): LoggerInterface
114120
{
115-
return $this->logger ??= $this->createMock(LoggerInterface::class);
121+
return self::$logger ??= new NullLogger();
116122
}
117123
}

Tests/Transport/NullTransportFactoryTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,24 @@
1919

2020
class NullTransportFactoryTest extends TransportFactoryTestCase
2121
{
22-
public function getFactory(): TransportFactoryInterface
22+
public static function getFactory(): TransportFactoryInterface
2323
{
24-
return new NullTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger());
24+
return new NullTransportFactory(self::getDispatcher(), self::getClient(), self::getLogger());
2525
}
2626

27-
public function supportsProvider(): iterable
27+
public static function supportsProvider(): iterable
2828
{
2929
yield [
3030
new Dsn('null', ''),
3131
true,
3232
];
3333
}
3434

35-
public function createProvider(): iterable
35+
public static function createProvider(): iterable
3636
{
3737
yield [
3838
new Dsn('null', 'null'),
39-
new NullTransport($this->getDispatcher(), $this->getLogger()),
39+
new NullTransport(self::getDispatcher(), self::getLogger()),
4040
];
4141
}
4242
}

Tests/Transport/SendmailTransportFactoryTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,33 @@
1919

2020
class SendmailTransportFactoryTest extends TransportFactoryTestCase
2121
{
22-
public function getFactory(): TransportFactoryInterface
22+
public static function getFactory(): TransportFactoryInterface
2323
{
24-
return new SendmailTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger());
24+
return new SendmailTransportFactory(self::getDispatcher(), self::getClient(), self::getLogger());
2525
}
2626

27-
public function supportsProvider(): iterable
27+
public static function supportsProvider(): iterable
2828
{
2929
yield [
3030
new Dsn('sendmail+smtp', 'default'),
3131
true,
3232
];
3333
}
3434

35-
public function createProvider(): iterable
35+
public static function createProvider(): iterable
3636
{
3737
yield [
3838
new Dsn('sendmail+smtp', 'default'),
39-
new SendmailTransport(null, $this->getDispatcher(), $this->getLogger()),
39+
new SendmailTransport(null, self::getDispatcher(), self::getLogger()),
4040
];
4141

4242
yield [
4343
new Dsn('sendmail+smtp', 'default', null, null, null, ['command' => '/usr/sbin/sendmail -oi -t']),
44-
new SendmailTransport('/usr/sbin/sendmail -oi -t', $this->getDispatcher(), $this->getLogger()),
44+
new SendmailTransport('/usr/sbin/sendmail -oi -t', self::getDispatcher(), self::getLogger()),
4545
];
4646
}
4747

48-
public function unsupportedSchemeProvider(): iterable
48+
public static function unsupportedSchemeProvider(): iterable
4949
{
5050
yield [
5151
new Dsn('sendmail+http', 'default'),

Tests/Transport/Smtp/EsmtpTransportFactoryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
class EsmtpTransportFactoryTest extends TransportFactoryTestCase
2222
{
23-
public function getFactory(): TransportFactoryInterface
23+
public static function getFactory(): TransportFactoryInterface
2424
{
25-
return new EsmtpTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger());
25+
return new EsmtpTransportFactory(self::getDispatcher(), self::getClient(), self::getLogger());
2626
}
2727

28-
public function supportsProvider(): iterable
28+
public static function supportsProvider(): iterable
2929
{
3030
yield [
3131
new Dsn('smtp', 'example.com'),
@@ -43,10 +43,10 @@ public function supportsProvider(): iterable
4343
];
4444
}
4545

46-
public function createProvider(): iterable
46+
public static function createProvider(): iterable
4747
{
48-
$eventDispatcher = $this->getDispatcher();
49-
$logger = $this->getLogger();
48+
$eventDispatcher = self::getDispatcher();
49+
$logger = self::getLogger();
5050

5151
$transport = new EsmtpTransport('localhost', 25, false, $eventDispatcher, $logger);
5252

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"require-dev": {
2828
"symfony/console": "^5.4|^6.0",
29-
"symfony/http-client-contracts": "^1.1|^2|^3",
29+
"symfony/http-client": "^5.4|^6.0",
3030
"symfony/messenger": "^6.2",
3131
"symfony/twig-bridge": "^6.2"
3232
},

0 commit comments

Comments
 (0)