Skip to content

Commit 5f61077

Browse files
committed
Add tests
1 parent cb3646a commit 5f61077

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Symfony\Component\Mailer\Bridge\MicrosoftGraph\Tests\Transport;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Symfony\Component\Cache\Adapter\NullAdapter;
7+
use Symfony\Component\Mailer\Bridge\MicrosoftGraph\Transport\MicrosoftGraphTransport;
8+
use Symfony\Component\Mailer\Bridge\MicrosoftGraph\Transport\MicrosoftGraphTransportFactory;
9+
use Symfony\Component\Mailer\Transport\Dsn;
10+
use Symfony\Component\Mime\Email;
11+
12+
class MicrosoftGraphTransportTest extends TestCase
13+
{
14+
15+
// TEST PRIVATE FUNCTION ?
16+
17+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd"
5+
backupGlobals="false"
6+
colors="true"
7+
bootstrap="vendor/autoload.php"
8+
failOnRisky="true"
9+
failOnWarning="true"
10+
>
11+
<php>
12+
<ini name="error_reporting" value="-1"/>
13+
</php>
14+
<testsuites>
15+
<testsuite name="Symfony Microsoft Graph API Bridge Test Suite">
16+
<directory>./Tests/</directory>
17+
</testsuite>
18+
</testsuites>
19+
<coverage/>
20+
<source>
21+
<include>
22+
<directory>./</directory>
23+
</include>
24+
<exclude>
25+
<directory>./Tests</directory>
26+
<directory>./vendor</directory>
27+
</exclude>
28+
</source>
29+
</phpunit>

0 commit comments

Comments
 (0)