11
11
12
12
namespace Symfony \Component \Mailer \Test ;
13
13
14
- use PHPUnit \Framework \Attributes \DataProvider ;
15
- use PHPUnit \Framework \TestCase ;
16
14
use Psr \Log \LoggerInterface ;
17
- use Symfony \Component \Mailer \Exception \IncompleteDsnException ;
18
- use Symfony \Component \Mailer \Exception \UnsupportedSchemeException ;
19
15
use Symfony \Component \Mailer \Transport \Dsn ;
20
- use Symfony \Component \Mailer \Transport \TransportFactoryInterface ;
21
- use Symfony \Component \Mailer \Transport \TransportInterface ;
22
16
use Symfony \Contracts \EventDispatcher \EventDispatcherInterface ;
23
17
use Symfony \Contracts \HttpClient \HttpClientInterface ;
24
18
25
19
/**
26
20
* A test case to ease testing Transport Factory.
27
21
*
28
22
* @author Konstantin Myakshin <[email protected] >
23
+ *
24
+ * @deprecated since Symfony 7.2, use AbstractTransportFactoryTestCase instead
29
25
*/
30
- abstract class TransportFactoryTestCase extends TestCase
26
+ abstract class TransportFactoryTestCase extends AbstractTransportFactoryTestCase
31
27
{
32
- protected const USER = 'u$er ' ;
33
- protected const PASSWORD = 'pa$s ' ;
28
+ use IncompleteDsnTestTrait;
34
29
35
30
protected EventDispatcherInterface $ dispatcher ;
36
31
protected HttpClientInterface $ client ;
37
32
protected LoggerInterface $ logger ;
38
33
39
- abstract public function getFactory (): TransportFactoryInterface ;
40
-
41
- /**
42
- * @psalm-return iterable<array{0: Dsn, 1: bool}>
43
- */
44
- abstract public static function supportsProvider (): iterable ;
45
-
46
- /**
47
- * @psalm-return iterable<array{0: Dsn, 1: TransportInterface}>
48
- */
49
- abstract public static function createProvider (): iterable ;
50
-
51
34
/**
52
35
* @psalm-return iterable<array{0: Dsn, 1?: string|null}>
53
36
*/
@@ -64,59 +47,6 @@ public static function incompleteDsnProvider(): iterable
64
47
return [];
65
48
}
66
49
67
- /**
68
- * @dataProvider supportsProvider
69
- */
70
- #[DataProvider('supportsProvider ' )]
71
- public function testSupports (Dsn $ dsn , bool $ supports )
72
- {
73
- $ factory = $ this ->getFactory ();
74
-
75
- $ this ->assertSame ($ supports , $ factory ->supports ($ dsn ));
76
- }
77
-
78
- /**
79
- * @dataProvider createProvider
80
- */
81
- #[DataProvider('createProvider ' )]
82
- public function testCreate (Dsn $ dsn , TransportInterface $ transport )
83
- {
84
- $ factory = $ this ->getFactory ();
85
-
86
- $ this ->assertEquals ($ transport , $ factory ->create ($ dsn ));
87
- if (str_contains ('smtp ' , $ dsn ->getScheme ())) {
88
- $ this ->assertStringMatchesFormat ($ dsn ->getScheme ().'://%S ' .$ dsn ->getHost ().'%S ' , (string ) $ transport );
89
- }
90
- }
91
-
92
- /**
93
- * @dataProvider unsupportedSchemeProvider
94
- */
95
- #[DataProvider('unsupportedSchemeProvider ' )]
96
- public function testUnsupportedSchemeException (Dsn $ dsn , ?string $ message = null )
97
- {
98
- $ factory = $ this ->getFactory ();
99
-
100
- $ this ->expectException (UnsupportedSchemeException::class);
101
- if (null !== $ message ) {
102
- $ this ->expectExceptionMessage ($ message );
103
- }
104
-
105
- $ factory ->create ($ dsn );
106
- }
107
-
108
- /**
109
- * @dataProvider incompleteDsnProvider
110
- */
111
- #[DataProvider('incompleteDsnProvider ' )]
112
- public function testIncompleteDsnException (Dsn $ dsn )
113
- {
114
- $ factory = $ this ->getFactory ();
115
-
116
- $ this ->expectException (IncompleteDsnException::class);
117
- $ factory ->create ($ dsn );
118
- }
119
-
120
50
protected function getDispatcher (): EventDispatcherInterface
121
51
{
122
52
return $ this ->dispatcher ??= $ this ->createMock (EventDispatcherInterface::class);
0 commit comments