Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 22
SesTransportFactoryTest
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 5
30
0.00% covered (danger)
0.00%
0 / 22
 getFactory
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 supportsProvider
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 6
 createProvider
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 13
 unsupportedSchemeProvider
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 incompleteDsnProvider
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Mailer\Bridge\Amazon\Tests\Transport;
13
14use AsyncAws\Core\Configuration;
15use AsyncAws\Ses\SesClient;
16use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesApiAsyncAwsTransport;
17use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesHttpAsyncAwsTransport;
18use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesSmtpTransport;
19use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
20use Symfony\Component\Mailer\Test\TransportFactoryTestCase;
21use Symfony\Component\Mailer\Transport\Dsn;
22use Symfony\Component\Mailer\Transport\TransportFactoryInterface;
23
24class SesTransportFactoryTest extends TransportFactoryTestCase
25{
26    public function getFactory(): TransportFactoryInterface
27    {
28        return new SesTransportFactory($this->getDispatcher(), $this->getClient(), $this->getLogger());
29    }
30
31    public function supportsProvider(): iterable
32    {
33        yield [
34            new Dsn('ses+api', 'default'),
35            true,
36        ];
37
38        yield [
39            new Dsn('ses+https', 'default'),
40            true,
41        ];
42
43        yield [
44            new Dsn('ses', 'default'),
45            true,
46        ];
47
48        yield [
49            new Dsn('ses+smtp', 'default'),
50            true,
51        ];
52
53        yield [
54            new Dsn('ses+smtps', 'default'),
55            true,
56        ];
57
58        yield [
59            new Dsn('ses+smtp', 'example.com'),
60            true,
61        ];
62    }
63
64    public function createProvider(): iterable
65    {
66        $client = $this->getClient();
67        $dispatcher = $this->getDispatcher();
68        $logger = $this->getLogger();
69
70        yield [
71            new Dsn('ses+api', 'default', self::USER, self::PASSWORD),
72            new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1']), null, $client, $logger), $dispatcher, $logger),
73        ];
74
75        yield [
76            new Dsn('ses+api', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-2']),
77            new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2']), null, $client, $logger), $dispatcher, $logger),
78        ];
79
80        yield [
81            new Dsn('ses+api', 'example.com', self::USER, self::PASSWORD, 8080),
82            new SesApiAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080']), null, $client, $logger), $dispatcher, $logger),
83        ];
84
85        yield [
86            new Dsn('ses+https', 'default', self::USER, self::PASSWORD),
87            new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1']), null, $client, $logger), $dispatcher, $logger),
88        ];
89
90        yield [
91            new Dsn('ses', 'default', self::USER, self::PASSWORD),
92            new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1']), null, $client, $logger), $dispatcher, $logger),
93        ];
94
95        yield [
96            new Dsn('ses+https', 'example.com', self::USER, self::PASSWORD, 8080),
97            new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-1', 'endpoint' => 'https://example.com:8080']), null, $client, $logger), $dispatcher, $logger),
98        ];
99
100        yield [
101            new Dsn('ses+https', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-2']),
102            new SesHttpAsyncAwsTransport(new SesClient(Configuration::create(['accessKeyId' => self::USER, 'accessKeySecret' => self::PASSWORD, 'region' => 'eu-west-2']), null, $client, $logger), $dispatcher, $logger),
103        ];
104
105        yield [
106            new Dsn('ses+smtp', 'default', self::USER, self::PASSWORD),
107            new SesSmtpTransport(self::USER, self::PASSWORD, null, $dispatcher, $logger),
108        ];
109
110        yield [
111            new Dsn('ses+smtp', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-1']),
112            new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', $dispatcher, $logger),
113        ];
114
115        yield [
116            new Dsn('ses+smtps', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu-west-1']),
117            new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', $dispatcher, $logger),
118        ];
119    }
120
121    public function unsupportedSchemeProvider(): iterable
122    {
123        yield [
124            new Dsn('ses+foo', 'default', self::USER, self::PASSWORD),
125            'The "ses+foo" scheme is not supported; supported schemes for mailer "ses" are: "ses", "ses+api", "ses+https", "ses+smtp", "ses+smtps".',
126        ];
127    }
128
129    public function incompleteDsnProvider(): iterable
130    {
131        yield [new Dsn('ses+smtp', 'default', self::USER)];
132    }
133}