|
| 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 | + |
| 12 | +namespace Symfony\Component\Mailer\Bridge\Google\Tests\Transport; |
| 13 | + |
| 14 | +use Symfony\Component\Cache\Adapter\NullAdapter; |
| 15 | +use Symfony\Component\Mailer\Bridge\MicrosoftGraph\Transport\MicrosoftGraphTransport; |
| 16 | +use Symfony\Component\Mailer\Bridge\MicrosoftGraph\Transport\MicrosoftGraphTransportFactory; |
| 17 | +use Symfony\Component\Mailer\Test\TransportFactoryTestCase; |
| 18 | +use Symfony\Component\Mailer\Transport\Dsn; |
| 19 | +use Symfony\Component\Mailer\Transport\TransportFactoryInterface; |
| 20 | + |
| 21 | +class MicrosoftGraphTransportFactoryTest extends TransportFactoryTestCase |
| 22 | +{ |
| 23 | + protected const TENANT = 'tenantId'; |
| 24 | + |
| 25 | + public function getFactory(): TransportFactoryInterface |
| 26 | + { |
| 27 | + return new MicrosoftGraphTransportFactory(new NullAdapter()); |
| 28 | + } |
| 29 | + |
| 30 | + public static function supportsProvider(): iterable |
| 31 | + { |
| 32 | + yield [ |
| 33 | + new Dsn('microsoft+graph', 'default'), |
| 34 | + true, |
| 35 | + ]; |
| 36 | + |
| 37 | + yield [ |
| 38 | + new Dsn('microsoft+graph', 'example.com'), |
| 39 | + true, |
| 40 | + ]; |
| 41 | + } |
| 42 | + |
| 43 | + public static function createProvider(): iterable |
| 44 | + { |
| 45 | + yield [ |
| 46 | + new Dsn('microsoft+graph', 'default', self::USER, self::PASSWORD, null, ["tenant" => self::TENANT]), |
| 47 | + new MicrosoftGraphTransport(self::USER, self::PASSWORD, 'https://login.microsoftonline.com/tenantId/oauth2/v2.0/token', 'https://graph.microsoft.com', new NullAdapter()), |
| 48 | + ]; |
| 49 | + yield [ |
| 50 | + new Dsn('microsoft+graph', 'https://example.com', self::USER, self::PASSWORD, null, ["tenant" => self::TENANT, "graphEndpoint" => "https://another-example.com"]), |
| 51 | + new MicrosoftGraphTransport(self::USER, self::PASSWORD, 'https://example.com/tenantId/oauth2/v2.0/token', 'https://another-example.com', new NullAdapter()), |
| 52 | + ]; |
| 53 | + } |
| 54 | + |
| 55 | + public static function unsupportedSchemeProvider(): iterable |
| 56 | + { |
| 57 | + yield [ |
| 58 | + new Dsn('microsoft+smtp', 'default', self::USER, self::PASSWORD), |
| 59 | + 'The "microsoft+smtp" scheme is not supported; supported schemes for mailer "microsoft graph" are: "microsoft+graph".', |
| 60 | + ]; |
| 61 | + } |
| 62 | + |
| 63 | + public static function incompleteDsnProvider(): iterable |
| 64 | + { |
| 65 | + yield [new Dsn('microsoft+graph', 'default', self::USER)]; |
| 66 | + |
| 67 | + yield [new Dsn('microsoft+graph', 'default', null, self::PASSWORD)]; |
| 68 | + } |
| 69 | +} |
0 commit comments